Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

playerReady not triggered

6 replies [Last post]

Hello,

I use the latest swfobject and the latest jw player.

$(document).ready(function() {
        var flashvars = {
            file: "http://localhost:55721/Content/Kalimba.mp3",
            backcolor: "111111",
            frontcolor: "66cc00",
            lightcolor: "66cc00",
            playlistsize: "200",
            skin: "http://localhost:55721/Content/bluemetal.swf",
            playlist: "bottom"
        };
       
        var params =
        {
        'allowfullscreen': 'true',
        'allowscriptaccess': 'always',
        'bgcolor': '#000000'
        };
       
        var attributes = {};

        swfobject.embedSWF("http://localhost:55721/Content/player-viral.swf", "player", "470", "470", "9.0.0",
            "", flashvars, params, attributes);
       

    });

with the above code the player is loaded and my mp3 can be played. In my html head I have:

<script type="text/javascript">
        var player = null;
       
        function playerReady(obj) {
            player = document.getElementById(obj.id);
          
            alert('ok');
        };
    </script>

This is never triggered. Why is this? I searched the forum but couldn't find an answer

thanks

There could be a number of reasons for this. Do you have any other javascript on the page?

Try this:

try {
var myReady = playerReady;
} catch (err){
}

playerReady = function(obj) {

player = document.getElementById(obj.id);
alert('ok');

try {
myReady(obj);
} catch (err){
}
}

You forgot to name the poor thing — now he's running around screaming, "Who am I?"

$(document).ready(function() {
var flashvars = {
file: "http://localhost:55721/Content/Kalimba.mp3",
backcolor: "111111",
frontcolor: "66cc00",
lightcolor: "66cc00",
playlistsize: "200",
skin: "http://localhost:55721/Content/bluemetal.swf",
<strong>id:"playerID",</strong>
playlist: "bottom"
};

var params =
{
'allowfullscreen': 'true',
'allowscriptaccess': 'always',
'bgcolor': '#000000'
};

var attributes =
{
<strong>id:'playerID',
name:'playerID'</strong>
};

swfobject.embedSWF("http://localhost:55721/Content/player-viral.swf", "player", "470", "470", "9.0.0",
"", flashvars, params, attributes);

});

Of course, choose any valid attribute string that you want for the player id.

Adobe advises:

From: http://livedocs.adobe.com/flex/201/langref/flash/external/ExternalInterface.html

Note: When embedding SWF files within an HTML page,
     make sure that the id and name attributes
      of the <object> and <embed> tags
      do not include characters such as: . (period), -, +, *, /, and \.

No other JS are there except jquery. I just making a test page.

With your approach I get a Reference error player ready not defined.

@hobbs: thanks it works!

@hobbs: thanks indeed

 
@gong & Nathan,

You're welcome.

            [i]Good Luck![/i]