Автоматическое воспроизведение видео в JW Player - PullRequest
1 голос
/ 17 марта 2011

Я пытаюсь воспроизвести видео .flv при загрузке страницы с помощью JW Player (V 4.2.88). Я просто не могу заставить мой код автоматически воспроизводиться при загрузке страницы, даже если мой код выглядит нормально.

Я также получаю игрок является нулевым или нет объекта в IE.Если я добавлю кнопку и вызову Play () по ее щелчку, видео начнет воспроизводиться.

Я использую JQuery, .NET 4.0 & C #

Вот мой код:

<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>

1 Ответ

0 голосов
/ 20 апреля 2012

потратив пару часов, я нашел решение нулевой проблемы ...

Вы можете предотвратить нулевую ошибку, добавив "& nbsp;" между тегами div в контейнере:

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

это смешно, но решил мои проблемы ...

...