0

我需要将一种方法 - play() - 应用于 flowplayer 对象,但它不起作用,我不明白为什么,我该怎么办?在setupContemporaryEvents()函数中有错误的代码,建议,提前谢谢。

这是html:

<div id="area1" class="player aree" data-engine="flash">
  <video id="vid1" preload="none">
    <source src="myvideo1.flv" type="video/flv">
  </video>
</div>
<div id="area2" class="player aree" data-engine="flash">
  <video id="vid2" preload="none">
    <source src="myvideo2.flv" type="video/flv">
  </video>
</div>

这是javascript:

$(function() {
  var video1, video2;
  var bVideo1 = false;
  var bVideo2 = false;
  video1 = $("#area1").flowplayer({swf: "flowplayer-5.3.1/flowplayer.swf"});
  video2 = $("#area2").flowplayer({swf: "flowplayer-5.3.1/flowplayer.swf"});

  $("#area1").bind("ready", function(e, api) {
    bVideo1 = true;
    setupContemporaryEvents();
  });
  $("#area2").bind("ready", function(e, api) {
    bVideo2 = true;
    setupContemporaryEvents();
  });

  var setupContemporaryEvents = function(){
    if(bVideo1 && bVideo2){
      $("#area1").bind("resume", function(e, api) {
        // not working
        $("#vid2").play();
        // not working
        $("#area2").play();
        // not working
        video2.play();
      });
    }
  };
});
4

1 回答 1

1

我找到了解决方案,这是对 javascript 的更正:

$(function() {
  var video1, video2;
  var bVideo1 = false;
  var bVideo2 = false;
  $("#area1").flowplayer({swf: "flowplayer-5.3.1/flowplayer.swf"});
  $("#area2").flowplayer({swf: "flowplayer-5.3.1/flowplayer.swf"});

  $("#area1").bind("ready", function(e, api) {
    bVideo1 = true;
    video1 = api;
    setupContemporaryEvents();
  });
  $("#area2").bind("ready", function(e, api) {
    bVideo2 = true;
    video2 = api;
    setupContemporaryEvents();
  });

  var setupContemporaryEvents = function(){
    if(bVideo1 && bVideo2){
      $("#area1").bind("resume", function(e, api) {
        video2.play();
      });
    }
  };
});
于 2013-01-29T20:13:52.227 回答