0

I want to put songs on a web page and have a little play button, like you can see on Last.fm or Pandora. There can be multiple songs listed on the site, and if you start playing a different song with one already playing, it will pause the first track and begin playing the one you just clicked on. I think they use Flash for this, and I could probably implement it in a few hours, but is there already code I could use for this? Maybe just a flash swf file that you stick hidden on a web page with a basic Javascript API that I can use to stream mp3 files?

Also, what about WMA or AAC files? Is there a universal solution that will play these 3 file types?


http://musicplayer.sourceforge.net/

4

4 回答 4

1

There are many flash mp3 players that you can use that do this. Usually, you just have to edit a text file to point at the mp3s you want to have available.

Here is the first one that showed up on a google search for flash mp3 player: http://www.flashmp3player.org/demo.html

于 2008-09-07T07:53:09.147 回答
0

如果您想嵌入 WMP,这相当简单,您可以通过 JavaScript 使用所有控件。上面有一个很棒的 MSDN 部分,但我现在似乎找不到它。

编辑:我在 MSDN 上发现包含嵌入式 WMP 将接受的属性,然后您所要做的就是通过 javascript 调用方法。

<OBJECT id="VIDEO" width="320" height="240" 
    style="position:absolute; left:0;top:0;"
    CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
    type="application/x-oleobject">

    <PARAM NAME="URL" VALUE="your file or url">
    <PARAM NAME="SendPlayStateChangeEvents" VALUE="True">
    <PARAM NAME="AutoStart" VALUE="True">
    <PARAM name="uiMode" value="none">
    <PARAM name="PlayCount" value="9999">
</OBJECT>

然后对于 javascript

<script type="javascript">
obj = document.getElementById("VIDEO"); //Where video is the id of the object above.
obj.URL="filename"; //You can use this to both start and change the current file.
obj.controls.stop(); //Will stop
obj.controls.Pause(); //Pause
</script>

在这里的某个地方,我有代码甚至可以控制音量。
不久前,我纯粹用 HTML 和 JavaScript 为客户端构建了一个自定义(外观)播放器。

于 2008-09-07T12:08:26.663 回答
0

我很久以前收藏的东西,但到目前为止从未测试过:http ://www.schillmania.com/projects/soundmanager2/

于 2008-09-07T12:47:43.653 回答
0

I second superjoe30's suggestion: I had great success with musicplayer. The only (slight) negative is that it's a little older project and not as well skinnable as some of the alternatives (although you have the full source code, so - given some time - you can make it look exactly as you need it to).

于 2008-09-07T17:34:12.620 回答