开发者

Auto play video in JW Player

I am trying to play a .flv video on page load using JW Player (V 4.2.88) I just can't make my code auto play on page load even though my code looks OK.

I am also getting player is null or not an object in IE. If I add a button and call the Play() on it's click, the video starts playing.

I am using JQuery, .NET 4.0 & C#

Here is my code:

<script type="text/javascript">
      var player;
      function playerReady(thePlayer) {
         //this gets fired in IE, FF
         player = window.document[thePlayer.id];         
      }
      function createPlayer() {
         var flashvars = { autostart: "true", 开发者_运维技巧skin: "http://localhost/app/Binn/flv/modieus.swf", lightcolor: "33cc00", frontcolor: "cccccc", quality: "true" }
         var params = { allowfullscreen: "true", allowscriptaccess: "always", wmode: "opaque" }
         var attributes = { id: "player1", name: "player1" }
         swfobject.embedSWF("/app/Binn/flv/player.swf", "VPlayer", "717", "420", "10.0.1", false, flashvars, params, attributes);
      }      

      function Play() {
         //this line gives error in IE saying player is null or not an object
         player.sendEvent('LOAD', 'http://localhost/kvs/u/bob/soccer.flv');
      }
      $(function () {
         alert('Creating the player on page load');
         createPlayer();
      });
      $(window).load(function () {
         alert('window loaded, so auto playing video');
         Play();
      });
   </script>

<div id="VPlayer"></div>


after spending a couple of hours i've found the solution of the null problem...

you can prevent null error by adding a "&nbsp ;" between the div tags in the container:

<div id="container">&nbsp;</div>

it is funny, but solved my problems...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜