Search code examples
phpjavascriptflashswfobject

multiple loading of same swf with swfObject 2.2


I have a php-script (it fetches mp3-files from MySQL database) and flash-player for listening. Working with player has been implemented with swfObject 2.2. If I'm loading one mp3-file, it works fine. But if I want to load some mp3, I get only the last mp3 in player(in html-source I see all, what needed, but not on the frontpage)

swfobject and mp3-player includes correctly, because working with one file is ok.

any clues?

    <div class="myFlashPlayers">
    <script type="text/javascript">
    var flashvars = {url:'1.mp3',artist:'artist1', track:'track1', duration:'4:32'};
    var params = {};
    var attributes = {};
    swfobject.embedSWF("player.swf", "myAlternativeContent", "320", "40", "9.0.0", false, flashvars, params, attributes);


    var flashvars = {url:'2.mp3',artist:'artist2', track:'track2', duration:'1:03'};
    var params = {};
    var attributes = {};
    swfobject.embedSWF("player.swf", "myAlternativeContent", "320", "40", "9.0.0", false, flashvars, params, attributes);
    </script></div>

Solution

  • The name parameter becomes the <object>'s DOM id parameter (among other things), which has to be unique. You'll have to assign a different name in each swfobject invocation. Even just appending 1, 2, etc... will be enough.