flash mp3player
Moderator: General Moderators
flash mp3player
hi!
i recently made a mp3player(swf file) which plays different (mp3,..) songs..
player gets its musiclist from .txt file...
example of player is here: http://www.hot.ee/antsman333
and the musiclist is located here: http://hot.ee/antsman333/list.txt
and my question is following: i want to create a php script, which can modify the musiclist file with new songs.
the script should have different kind forms, like where can I put the song name, URL, picture URL etc...
(if the script changes the .txt file, then it doesnt overwrites the existing songs)
could somebody help me?
i recently made a mp3player(swf file) which plays different (mp3,..) songs..
player gets its musiclist from .txt file...
example of player is here: http://www.hot.ee/antsman333
and the musiclist is located here: http://hot.ee/antsman333/list.txt
and my question is following: i want to create a php script, which can modify the musiclist file with new songs.
the script should have different kind forms, like where can I put the song name, URL, picture URL etc...
(if the script changes the .txt file, then it doesnt overwrites the existing songs)
could somebody help me?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: flash mp3player
Rather than making a PHP script that can modify the play list, make a PHP script that IS the play list. PHP is designed to generate scripts of different kinds. Just generate XML of whatever format the play list is.
(#10850)
Re: flash mp3player
ok thanks, but im not able to do it by myself (im noob)arborint wrote:Rather than making a PHP script that can modify the play list, make a PHP script that IS the play list. PHP is designed to generate scripts of different kinds. Just generate XML of whatever format the play list is.
could you give me some advice how to make it (first steps etc)..
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: flash mp3player
If the playlist was XML you could do something like this:
Code: Select all
$playlist = array(
1 => array(
'title' => 'Foo',
'filename' => 'foo.mp3',
),
2 => array(
'title' => 'Bar',
'filename' => 'bar.mp3',
),
);
$out = "<playlist>\n";
foreach ($playlist as $entry) {
$out .= " <entry>
<title>{$entry['title']}</title>
<filename>{$entry['filename']}</filename>
</entry>
";
}
$out .= "</playlist>\n";
echo $out;(#10850)
Re: flash mp3player
plz dont get mad, but could you explain it step-by-step.. im very n00barborint wrote:If the playlist was XML you could do something like this:Code: Select all
$playlist = array( 1 => array( 'title' => 'Foo', 'filename' => 'foo.mp3', ), 2 => array( 'title' => 'Bar', 'filename' => 'bar.mp3', ), ); $out = "<playlist>\n"; foreach ($playlist as $entry) { $out .= " <entry> <title>{$entry['title']}</title> <filename>{$entry['filename']}</filename> </entry> "; } $out .= "</playlist>\n"; echo $out;
Re: flash mp3player
Code: Select all
//First we create an array ($playlist), and add some values to it
$playlist = array(
1 => array(
'title' => 'Foo',
'filename' => 'foo.mp3',
),
2 => array(
'title' => 'Bar',
'filename' => 'bar.mp3',
),
);
//Then we define output variable and start adding text to it
$out = "<playlist>\n";
// we add all $playlist array value to that same output variable ( this will loop as many times as there are values in array)
foreach ($playlist as $entry) {
$out .= " <entry>
<title>{$entry['title']}</title>
<filename>{$entry['filename']}</filename>
</entry>
";
}
//And finally we add the ending to that output
$out .= "</playlist>\n";
//And then we echo that whole output variable
echo $out;
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: flash mp3player
Yes, I am assuming that playlists would come from a database or something like that. This code is just to get an admitted beginner started. You might also want to wrap the playlist generator in a function or class to make it more reusable.
(#10850)
Re: flash mp3player
http://php.about.com/od/advancedphp/ss/ ... te_php.htm <- does it helps? 
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: flash mp3player
ok thanks for answeringarborint wrote:If you want to write the playlist to a file then yes.
but could you help me to make this form (sorta "web-based playlist modifier") where can i simply write down song names, URLs etc and then save it to webserver..
<?xml version="1.0" encoding="UTF-8" ?>
<playlist version="0" xmlns="http://xspf.org/ns/0/">
<title>MP3Player</title>
<creator>tom</creator>
<trackList>
<track>
<location>http://hot.ee/antsman333/Nirvana-FreeBird.mp3</location>
<identifier>684088:Track:1639</identifier>
<title>Free bird</title>
<creator>Nirvana</creator>
<image>http://g8.undercoverhd.com/imgsresized/ ... jpg</image>
<extension application="http://docs.ning.com/music/">
</extension>
</track>
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: flash mp3player
Just take what I posted above and try to generate a "trackList". You just need to edit it a little and add a couple fields. See what you get.
(#10850)
Re: flash mp3player
thanks!arborint wrote:Just take what I posted above and try to generate a "trackList". You just need to edit it a little and add a couple fields. See what you get.
ok i will try it on tomorrow
btw sry for disturbing you
Re: flash mp3player
i found a php script which adds your written data into textfile, but it overwrites the exciting data...
but i dont want to owerwrite the data...
is it possible to change this script?
the script is located in this topic: http://www.dynamicdrive.com/forums/arch ... -4539.html
plz help
but i dont want to owerwrite the data...
is it possible to change this script?
the script is located in this topic: http://www.dynamicdrive.com/forums/arch ... -4539.html
plz help
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: flash mp3player
I'd recommend that you look around in this section of the PHP manual:
http://us2.php.net/manual/en/book.filesystem.php
Especially the sections on the functions called in the examples you found, so you know what they do and what the parameters are. There is also a lot of example code in the manual and comments.
http://us2.php.net/manual/en/book.filesystem.php
Especially the sections on the functions called in the examples you found, so you know what they do and what the parameters are. There is also a lot of example code in the manual and comments.
(#10850)
Re: flash mp3player
i found the way how to rewrite the data in text filearborint wrote:I'd recommend that you look around in this section of the PHP manual:
http://us2.php.net/manual/en/book.filesystem.php
Especially the sections on the functions called in the examples you found, so you know what they do and what the parameters are. There is also a lot of example code in the manual and comments.
<?
if($_POST['Submit']){
$open = fopen("textfile.txt","a+");
$text = $_POST['update'];
fwrite($open, $text);
fclose($open);
echo "File updated.<br />";
echo "File:<br />";
$file = file("textfile.txt");
foreach($file as $text) {
echo $text."<br />";
}
}else{
$file = file("textfile.txt");
echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">";
foreach($file as $text) {
echo $text;
}
echo "</textarea>";
echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n
</form>";
}
?>
but it doesnt leave any line spacing..
how to fix this problem?