Music player code in php

Reply

Join Date: Nov 2008
Posts: 20
Reputation: Narayan15 is an unknown quantity at this point 
Solved Threads: 0
Narayan15 Narayan15 is offline Offline
Newbie Poster

Music player code in php

 
0
  #1
Feb 13th, 2009
hi
i m very interested to make a online music website, so i need Music player code in php. please help me.

thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,518
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: Music player code in php

 
0
  #2
Feb 13th, 2009
Originally Posted by Narayan15 View Post
...
so i need Music player code in php.
...
Well if you are looking for a music player, how can the server play music on the clients computer. Sounds weird trying to get the server to play the music for the client and expect the client to be able to listen to the music. So your best options would be Flash and/or Java. Flash and Java are both client side languages meaning the will load on the users computer and not on the server (I am sure you want to music to load/play on the users computer and not on the server). Then perhaps php can tell Java or Flash where to download the file from. The only other option which I wouldn't recommend is a mixture of Javascript and html. But using Javascript and html it wouldn't look as great as Java or Flash and Javascript is widely disabled.

So those are the options but php itself can't play the music for the client. And after you have chosen one, I would suggest a google search on some client side web scripting tutorials and compilers (if using Java or Flash). Although it may not have been the answer that you wanted I hope it helps solve the problem.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - Oopy Doopy Do 2U2!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 20
Reputation: Narayan15 is an unknown quantity at this point 
Solved Threads: 0
Narayan15 Narayan15 is offline Offline
Newbie Poster

Re: Music player code in php

 
0
  #3
Feb 13th, 2009
Thank you for your reply. Yes, u r right, i want to play music on clients computers. But i don't know how to write music player code in java. How to connect Java to PHP. I tried a lot in google, but i couldn't get required code. Please help me.

Thank u in advance
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,384
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 167
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Music player code in php

 
0
  #4
Feb 13th, 2009
This works
Drop the file as index.php in a folder of mp3 or wma files and it produces a sorted list of filenames that click toplay
  1. <?php ob_start("ob_gzhandler"); ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <html xmlns="http://www.w3.org/TR/REC-html40">
  4. <head>
  5. <LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="../style.css.php">
  6. <script LANGUAGE="javascript" TYPE="text/javascript" SRC="../script.js.php"></script>
  7. <script type="text/javascript">
  8. <!--//
  9. function shrink(){
  10. document.getElementById("MediaPlayer1").style.width=384;
  11. document.getElementById("MediaPlayer1").style.height=300;
  12. }
  13. function enLarge(){
  14. document.getElementById("MediaPlayer1").style.width=480;
  15. document.getElementById("MediaPlayer1").style.height=402;
  16. }
  17. //-->
  18. </script>
  19. <title></title>
  20. </head><body><a name='top'></a><H3><center>Videos</center></h3>
  21. <p class='logo'>
  22. <button onclick="enLarge()">large</button>
  23. <button onclick="shrink()">small</button>
  24. <a href='..'>Main Menu</a>
  25. <A HREF="http://www.microsoft.com/windows/windowsmedia/player/download/"><IMG ALT="Get Windows Media Player" SRC="http://www.microsoft.com/windows/windowsmedia/images/logos/getwm/mp11_88x31_static.gif" WIDTH="88" HEIGHT="31" BORDER="0"></A><br>
  26. <OBJECT ID="MediaPlayer1" width=384 height=300 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
  27. <PARAM NAME="fileName" VALUE="">
  28. <PARAM NAME="showControls" VALUE="true">
  29. <PARAM NAME="PlayCount" VALUE="0">
  30. <PARAM NAME="animationatStart" VALUE="true">
  31. <PARAM NAME="transparentatStart" VALUE="true">
  32. <PARAM NAME="autoStart" VALUE="true">
  33. <EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="" name="MediaPlayer1" width=360 height=260 AutoStart=true></EMBED></object></p>
  34. <div style='float:left; text-align:left;'>
  35. <?php $p = split('/', $_SERVER['SCRIPT_FILENAME']);
  36. $script_name = $p[count($p)-1];
  37. $path = str_replace($script_name, '', $_SERVER['SCRIPT_FILENAME']);
  38. $dir_handle = @opendir($path) or die("Unable to open $path");
  39. Function get_Extension($m_FileName){
  40. $path_parts = pathinfo($m_FileName);
  41. if ($path_parts["extension"]) {
  42. $m_Extension = strtolower($path_parts["extension"]);
  43. return(strtoupper($m_Extension));
  44. }
  45. else { return "unknown"; }
  46. }
  47. function check_image($filename){
  48. $temp=strtoupper(get_Extension($filename));
  49. if(($temp=="MP3")||($temp=="WMA")||($temp=="WMV")||($temp=="ASF")) return (true);
  50. else return (false);
  51. }
  52. Function get_Files($path) {
  53. if ($handle = opendir($path)) {
  54. while (false !== ($file = readdir($handle))) {
  55. if(!is_dir($file) && substr($file,O,1) != "."){
  56. $m_Files[]=$file;
  57. }
  58. }
  59. closedir($handle);
  60. }
  61. if(sizeof($m_Files)>1)
  62. asort($m_Files);
  63. return $m_Files;
  64. }
  65. $files=get_Files($path);
  66. $filter_files=array_filter($files,"check_image");
  67. $maxnr=sizeof($filter_files)-1;
  68. sort($filter_files);
  69. for ($i=0;$i<sizeof($filter_files);$i++){
  70. echo "<a class='button' onclick=\"MediaPlayer1.SRC='$filter_files[$i]';MediaPlayer1.fileName='$filter_files[$i]';\">";
  71. echo substr($filter_files[$i], 0, strlen($filter_files[$i])-4);
  72. echo "</a><br>";
  73. }
  74. closedir($dir_handle); ?></table>
  75.  
  76. </body></html>
  77. <?php ob_flush(); ?>
It only understands wmv wma asf mp3

just one of many possibilities.
There are 'utube', flash player scripts for download, complete setups, Google search
Last edited by almostbob; Feb 13th, 2009 at 6:50 am. Reason: had my name in it :{(
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC