Jump to content

Recommended Posts

hey I’m trying to build a mp3 player, right now I got a mysql with artist and another one linking to their music,

but I been using EMBED because I can put a play list of their song, the only problem with this I’m trying to make my website XHTML 1.1 web standard and that’s the only thing giving me issues.

 

in short how can I make a play list with the OBJECT and php any one know of a good tutorial.

 

Link to comment
https://forums.phpfreaks.com/topic/65835-mp3-player/
Share on other sites

Personally I would just create a dynamic playlist file and deliver it to the browser. The user's default mp3 play should start with the tracks in the playlist. But, if you want an actual "player" that exists in the browser, then I don't have a suggestion. Good luck.

Link to comment
https://forums.phpfreaks.com/topic/65835-mp3-player/#findComment-329160
Share on other sites

to make a player... i suggest download an open source one and reverse engineer it.

 

but if you just want to stream individual MP3 files you want to convert them to M3U files on the fly so they stream in the users default player, instead of forcing the user to download the full MP3 file.

 

what i've done in the past is something like this:

 

user click:

<a href="play.php?id=32210493">Play Song</a>

 

play.php

<?php
$id= $_GET['id'];

//add some code that uses the id to look up the actual location of the file; end up with:
$file = "my/music/files/song.mp3"; 

header("Content-type: audio/m3u");
header("Content-Disposition: inline; filename=".$_GET['id'].".m3u");
?>
http://www.mydomain.com/<?php=$file ?>

Link to comment
https://forums.phpfreaks.com/topic/65835-mp3-player/#findComment-329161
Share on other sites

i guess the best way is to do a xml flash player,

 

but how would i make a file with the artists and their song?

 

because i know the extension has to be xml so i wouldn't know how to do that.

 

query the artist and their song into a xml files and that file has to update when ever a new song or artists is added.

 

 

any clue?

Link to comment
https://forums.phpfreaks.com/topic/65835-mp3-player/#findComment-329248
Share on other sites

i did something just like this not to long ago. i used Flash's media playback component to load and stream mp3 files on a my page. it's pretty easy and only takes a few lines of Actionscript.

 

Basically i started with data from a MySQL table with ID, Title, Artist, & Path columns.

 

for example,

using php to retrive song ID: 393 it loads the artist, title, path variables for that track display the title and artist variables in PHP:

 

<?php
$result = mysql_query("SELECT artist, title, path FROM music WHERE ID = `393` LIMIT 1"
while ($row = mysql_fetch_array($result)){
echo 'Artist: '.$row[0].'<br>';
echo 'Title: '.$row[1];
$file_path = $row[2];
}
?>

 

then pass the $file_path variable into flash like this (notice you have to pass it twice)


<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  codebase="http://download.macromedia.com/"  
  WIDTH="250" HEIGHT="300" id="player">
  <PARAM NAME=movie VALUE="player.swf[b]?path=<?php echo $file_path; ?>[/b]"> 
  <PARAM NAME=quality VALUE=high>
  <PARAM NAME=bgcolor VALUE=#FFFFFF> 
  <EMBED src="player.swf[b]?path=<?php echo $file_path; ?>[/b]" 
    quality=high bgcolor=#FFFFFF WIDTH="250" HEIGHT="300" NAME="player"
    TYPE="application/x-shockwave-flash" 
    PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
  </EMBED>
</OBJECT>

 

to create the empty player.

 

you should add flash's media playback component to a new Flash project. Set the instance name to "media" in the properties window and set it's media type to mp3 in the component inspector. Select the first (and only) frame of the movie and open the actions window. Pass the variable like this:

 

var passed:String = path;
media.setMedia(path);

 

export the flash movie as player.swf and save it in the same directory as the page retrieving the info from the database.

 

you should be all set!

Link to comment
https://forums.phpfreaks.com/topic/65835-mp3-player/#findComment-329288
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.