简体   繁体   中英

Play mp3 using JavaScript and swf

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.com/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.com/content/projects/soundmanager2/

Thanks for any help!

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=" />
<param name="wmode" value="transparent" />
</object>

另一个玩家将是http://musicplayer.sourceforge.net

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM