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

Forums

/

In 5.7.1794 JavaScript API Breaks when attributes in SWFObject.embedSWF are set to null

1 reply [Last post]
Reply

It appears that if the attributes argument for the SWFObject.embedSWF is set to null (e.g., you don't have any attributes you need set), then the JWPlayer JavaScript API won't work.

You'll be able to select the player reference using its container, and the jwplayer functional will return the API object when it is called, but the actual API functions (e.g., jwplayer().play(), etc. ) will not work.

Passing an attributes object with dummy data fixes this problem.

Since the attributes object argument in swfobject.embedSWF is optional (per their API spec: http://code.google.com/p/swfobject/wiki/api), there's no reason passing null should break JWPlayer's JS API.

For example, this code does not work:

swfobject.embedSWF(
        '/swf/player.swf',
        video_id,
        this.$c.width(),
        this.$c.height(),
        '9.0.115',
        '/swf/expressInstall.swf',
        { displayheight: this.$c.height(),
          file: 'file',
          image: 'image',
          backcolor: '000000',
          screencolor: '000000',
          controlbar: 'over',
          'controlbar.idlehide': 'true',
          autostart: autostart,
          skin: '/swf/skin.swf' },
        { allowscriptaccess: 'always',
          allowfullscreen: 'true',
          wmode: 'opaque',
          menu: 'false' },
          null,
        function (e) {
          if (!e.success) {
            growl({'error': "You don't have Adobe Flash installed. Go to get.adobe.com/flashplayer to download."});
        }
      );

But this code does:

swfobject.embedSWF(
        '/swf/player.swf',
        video_id,
        this.$c.width(),
        this.$c.height(),
        '9.0.115',
        '/swf/expressInstall.swf',
        { displayheight: this.$c.height(),
          file: 'file',
          image: 'image',
          backcolor: '000000',
          screencolor: '000000',
          controlbar: 'over',
          'controlbar.idlehide': 'true',
          autostart: autostart,
          skin: '/swf/skin.swf' },
        { allowscriptaccess: 'always',
          allowfullscreen: 'true',
          wmode: 'opaque',
          menu: 'false' },
        {
          id:"player",
          name:"player"
        },
        function (e) {
          if (!e.success) {
            growl({'error': "You don't have Adobe Flash installed. Go to get.adobe.com/flashplayer to download."});
        }
      );

Hoping this bug report saves someone the time I spent figuring this out.

Reply

@Fred -

The reason your first example breaks the JW Player's API is that the API relies on the player's ID being set properly. In your example, the Flash object is being set up without a DOM ID, so there's no way for the API to communicate with the player.

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • You may post code using <code>...</code> .
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options