今天从《[URL=http://paranimage.com/10-flash-and-javascript-music-players/]10款Flash和Javascript网页音乐播放器[/URL]》看到一个不错的可以支持自动记忆播放进度的网页播放器[URL=http://www.flashmp3player.org/]Flash MP3 Player[/URL],但是经过简单了解之后发现这个Flash版的播放器还需要PHP的支持,于是打算换其它的,但是找遍了搜索引擎也没找到第二款支持AutoResume功能的网页播放器,于是抱着试试看的态度研究了一下PHP代码。不看不要紧,一看才知道原来PHP代码就是根据指定的目录循环列出此目录下面的所有mp3歌曲,然后输出成xml形式。这下子一切都明朗了,于是先把官网的php文件([URL=http://www.flashmp3player.org/flashmp3player.php?file_dir=mp3]http://www.flashmp3player.org/flashmp3player.php?file_dir=mp3[/URL])输出的xml做成静态文件flashmp3player.xml如下,注意编码方式是UTF-8 Without BOM。
<br/><?xml version="1.0" encoding="utf-8"?><br/><playlist><br/> <song id="mp3demosong01" title="Behind Blue Eyes" artist="Limp Bizkit" src="http://www.flashmp3player.org/mp3/demosong01.mp3" /><br/> <song id="mp3demosong02" title="Signed Sealed Delivered" artist="Blue feat. Stevie Wonder" src="http://www.flashmp3player.org/mp3/demosong02.mp3" /><br/> <song id="mp3demosong03" title="On top of the world" artist="Edsilia Rombley" src="http://www.flashmp3player.org/mp3/demosong03.mp3" /><br/> <song id="mp3demosong04" title="Puro Amore" artist="Zucchero Sugar Fornaciari" src="http://www.flashmp3player.org/mp3/demosong04.mp3" /><br/> <song id="mp3demosong05" title="After Dark (Remix)" artist="Krafty Kuts" src="http://www.flashmp3player.org/mp3/demosong05.mp3" /><br/> <song id="mp3demosong06" title="Erase/Rewind" artist="Cardigans" src="http://www.flashmp3player.org/mp3/demosong06.mp3" /><br/> <song id="mp3demosong07" title="Let It Go" artist="Mandyleigh Storm" src="http://www.flashmp3player.org/mp3/demosong07.mp3" /><br/> <song id="mp3demosong08" title="O_ Es-tu" artist="Clemence" src="http://www.flashmp3player.org/mp3/demosong08.mp3" /><br/> <song id="mp3demosong09" title="Wood" artist="Second Person" src="http://www.flashmp3player.org/mp3/demosong09.mp3" /><br/> <song id="mp3demosong10" title="What're you Wanna Do" artist="Lily Vasquez" src="http://www.flashmp3player.org/mp3/demosong10.mp3" /><br/> <song id="mp3demosong11" title="Mockingbird" artist="Eminem" src="http://www.flashmp3player.org/mp3/demosong11.mp3" /><br/> <song id="mp3demosong12" title="New Rise" artist="LA 5" src="http://www.flashmp3player.org/mp3/demosong12.mp3" /><br/> <song id="mp3demosong13" title="Up to My Neck in the Blues" artist="the Sonny Moorman Group" src="http://www.flashmp3player.org/mp3/demosong13.mp3" /><br/> <song id="mp3demosong14" title="Boogie-Woogie Sampler" artist="Ryan Ahern" src="http://www.flashmp3player.org/mp3/demosong14.mp3" /><br/> <song id="mp3demosong15" title="Beta-Karotin" artist="BoomBox" src="http://www.flashmp3player.org/mp3/demosong15.mp3" /><br/> <song id="mp3demosong16" title="Comcast Blues" artist="PenMachine" src="http://www.flashmp3player.org/mp3/demosong16.mp3" /><br/></playlist><br/>
然后把下图位置的flashmp3player.php直接改为flashmp3player.xml
如果你用其它语言打算实现flashmp3player.php文件的相同功能,只要通过参数file_dir即可获得配置的文件路径。
最后把我做出来的例子给大家看看,我新增加了几首歌曲:[URL=http://www.cuiwenyuan.com/flashmp3player/flashmp3player.html]演示[/URL]