最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

flash - Play mp3 using JavaScript and swf - Stack Overflow

programmeradmin1浏览0评论

Is there a Flash MP3 player that would allow me to do following to pass URL to mp3 file and get it automatically played. To help out with answer - here is detailed code that describes what I would like to do:

<object id="mp3PlayerSwf" type="application/x-shockwave-flash" data="mp3Player.swf">
 <param name="movie" value="mp3Player.swf">
</object>

<input type="button" id="soundPlay1" value="Sound Play 1" />

<script type="text/javascript">
    function eventHandler1(sender) {
        var mp3Player = document.getElementById("mp3PlayerSwf");
        mp3Player.playSound(".mp3");
    }

    var soundPlay1 = document.getElementById('soundPlay1');
    if (soundPlay1.addEventListener) {
        soundPlay1.addEventListener('click', eventHandler1, false);
    }
    // IE
    else if (soundPlay1.attachEvent) {
        soundPlay1.attachEvent('onclick', eventHandler1);
    }
</script>

Constraint is that I can't use libraries that have JavaScript initialization - like for example SoundManager2 - /

Thanks for any help!

Is there a Flash MP3 player that would allow me to do following to pass URL to mp3 file and get it automatically played. To help out with answer - here is detailed code that describes what I would like to do:

<object id="mp3PlayerSwf" type="application/x-shockwave-flash" data="mp3Player.swf">
 <param name="movie" value="mp3Player.swf">
</object>

<input type="button" id="soundPlay1" value="Sound Play 1" />

<script type="text/javascript">
    function eventHandler1(sender) {
        var mp3Player = document.getElementById("mp3PlayerSwf");
        mp3Player.playSound("http://myUrl./my.mp3");
    }

    var soundPlay1 = document.getElementById('soundPlay1');
    if (soundPlay1.addEventListener) {
        soundPlay1.addEventListener('click', eventHandler1, false);
    }
    // IE
    else if (soundPlay1.attachEvent) {
        soundPlay1.attachEvent('onclick', eventHandler1);
    }
</script>

Constraint is that I can't use libraries that have JavaScript initialization - like for example SoundManager2 - http://www.schillmania./content/projects/soundmanager2/

Thanks for any help!

Share Improve this question asked Feb 23, 2010 at 23:09 nikib3ronikib3ro 20.6k25 gold badges124 silver badges185 bronze badges 2
  • can't you create a Flash-movie yourself? Just use ExternalInterface to listen to the JS, and attach the MP3 file to a Sound-object.. – Pbirkoff Commented Feb 23, 2010 at 23:12
  • I can't because I don't have Macromedia tools installed on my puter... – nikib3ro Commented Feb 24, 2010 at 17:07
Add a ment  | 

2 Answers 2

Reset to default 5

Try dewplayer: http://www.alsacreations.fr/dewplayer-en

You can use it like this (sample code taken from the link):


<object type="application/x-shockwave-flash" data="dewplayer.swf" width="200" height="20" id="dewplayer" name="dewplayer">
<param name="movie" value="dewplayer.swf" />
<param name="flashvars" value="mp3=test.mp3" />
<param name="wmode" value="transparent" />
</object>

Another player would be http://musicplayer.sourceforge

发布评论

评论列表(0)

  1. 暂无评论