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

Forums

/

playerReady not called in 4.4.192

22 replies [Last post]

I've downloaded the latest JW player, 4.4.192 licensed version... and the player is being embedded fine through embedSWFObject, but the playerReady function isn't being called.

This is what its embedding, so I don't think its a script access problem:

<object id="player1" width="720" height="405" type="application/x-shockwave-flash" name="player1" data="/includes/javascript/video/player.swf">
<param name="allowfullscreen" value="true"/>
<param name="allowscriptaccess" value="always"/>
<param name="flashvars" value="autostart=false&controlbar=over&skin=/includes/javascript/video/dangdang.swf/>
</object>

Are you testing this on a Linux client?

v4.4.192 works well for me, embedded with swfobject v2.2. No problems calling the playerReady() function.

I have the same problem. I'm using v 4.4.192 with wfobject v2.1 on suse 11.1. The playerReady() functions isn't being called and i can't access the player with document.getElemtentById('playerID'). Can you plaese help me

I am testing on a linux client, ubuntu specifically, w/ sfwobject 2.1 as well... FF 3.08

@zach,

For Linux, add the flashvar id=player1 to match the name and id in your object code. Jeroen added the id flashvar specifically for Linux.

that did the trick... odd since it worked in older releases without... but thanks!

EDIT: Actually... is this a bug? why doesn't it use the fields in the id/name? I only ask because I will have to go through and change all my videos because I need to utilize this value through javascript...

I founded myself about an hour ago and now everything is working just fine. Anyway @lefTy thanks for the help:)

Hi all,

Ivan, can you explain how do you do, to resolve your problem ?!?

Thank a lot, KissGround

@KissGround you have to add id flash var with the same value as the embeded object id and name. Here's my code. Hope it will help!

function createPlayer() {
var flashvars = {
id: "jwplayer",
controlbar: "over",
autostart:true
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:"jwplayer",
name:"jwplayer"
}

swfobject.embedSWF("/swf/player.swf",
"videoplaceholder", "480", "360", "9.0.115",
false, flashvars, params, attributes);
}

"For Linux, add the flashvar id=player1 to match the name and id in your object code"

This is a horrible bug/workaround! Where is this documented on the Javascript API pages?

@ankle,

I guess you missed it here: http://developer.longtailvideo.com/trac/wiki/FlashVars#API

Next time, read the documantation more carefully before you post and make a fool of yourself.

@kissMe: True, right at the bottom of the page it says
"id (ply): ID of the player within the javascript DOM. Useful for javascript interaction. This is automatically set for Windows / MAC, but under Linux you'll have to set the flashvar. "

But it doesn't mention this on the main API page at <http://developer.longtailvideo.com/trac/wiki/FlashAPI>, nor does it say in big letters anywhere that playerReady just won't fire on Linux unless the id flashvar is set.

I'm not being difficult, just trying to help prevent anyone else spending a long time wondering why the player isn't doing anything at all.

oufff!!!!! yes This is a horrible bug !!!!!!!!!!!!!!!!!!!!!!
thank's IVAN :)

 
   RTFM

I just encountered this *bug* too - and ye, just because it's documented, doesn't mean it isn't a bug.

And I agree with ankle that it is even poorly document - nothing on the API page, nothing in the tutorials. Gah.

The worst part is it would go completely uncaught until production were dev done on windows/mac.

 
    ROFL

"RTFM"

I've RTFM, and nowhere in the FM does it say that playerReady will not be called unless the flashvar id is set.
Also, why is it automatically detected on Windows and Mac, but not GNU/Linux?

@Fibonacci,

Guess you also skipped this part of the manual: http://developer.longtailvideo.com/trac/wiki/FlashVars#API

Next time, read the documantation more carefully before you post and make a fool of yourself.

@kissMe,

I still don't see anywhere that playerReady will not be called unless the flashvar id is set, or why is it not automatically set on GNU/Linux.

Next time, read the documantation more carefully before you post and make a fool of yourself.

Calling playerReady() is not crucial to the use of the JavaScript API.

It's just a convenient way of knowing when the player reference object is available.

You can still do a loop, checking for the player reference object.
Then, when the player reference object is available, start using the JavaScript API.
It yields the same functionality as playerReady().

As for why, go ask Adobe why the automatic ID retrieval through ExternalInterface.objectID doesn't work on Linux.

Still cannot get the call for playerReady - any other ideas? I put id in flashvars. Thanks

function createPlayer() {
var flashvars = {
id:"player1",
file:"/playlists/uriplaylist.xml",
autostart:"true",
bufferlength:"10",
controlbar:"none",
autostart:"true",
displayclick:"none",
icons:"false",
quality:"false",
repeat:"list",
stretching:"exactfit"
}
var params = {
allowfullscreen:"false",
allowscriptaccess:"never"
}
var attributes = {
id:"player1",
name:"player1"
}
swfobject.embedSWF("/flvplayer/player.swf", "placeholder1", "823", "535", "9.0.115", false, flashvars, params, attributes);
alert('Player Created ');
}

function playerReady(thePlayer) {
alert('Player Ready Function');
player = document.getElementById(thePlayer);
addListeners();
}

 
Guaranteed working code.

Demo Page:

    http://willswonders.myip.org:8074/Not%20Having%20Fun.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

  <head>

    <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        id:                    'playerID',
        file:                  'playlist_jwchapters.xml',
        autostart:             'true',
        bufferlength:          '10',
        controlbar:            'none',
        displayclick:          'none',
        icons:                 'false',
        quality:               'false',
        repeat:                'list',
        stretching:            'exactfit'
      };

      var params =
      {
        allowfullscreen:       'false', 
        allowscriptaccess:     'always'
      };

      var attributes =
      {
        id:                    'playerID', 
        name:                  'playerID'
      };

      swfobject.embedSWF('player-4.6.248.swf', 'player', '823', '535', '9.0.124', false, flashvars, params, attributes);
    </script>

    <script type="text/javascript">
      var player    =  null;
      var playlist  =  null;

      function playerReady(obj)
      {
        player = gid(obj.id);
alert('Player ID: ' + player.id);
        addListeners();
      };

      function addListeners()
      {
        playlist = player.getPlaylist();

        if(playlist.length > 0)
        {
          player.addModelListener('STATE', 'stateMonitor');
        }
        else
        {
alert('Try Again!');
          setTimeout("addListeners();", 100);
        }
      };

      function stateMonitor(obj)
      {
alert('State: ' + obj.newstate);
        if(obj.newstate == 'COMPLETED')
        {
          //...drop out of fullscreen
          this.window.focus();

          //...load a new page
          window.location = 'http://yahoo.com';
        }
      };

      function gid(name)
      {
        return document.getElementById(name);
      };
    </script>

  </head>

  <body>

    <div id="playercontainer" class="playercontainer"><a id="player" class="player" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>

  </body>

</html>

my god.

i spent a lot of time to resolve this problem.

!!!