使用JavaScript同时运行两个视频

时间:2016-05-11 09:11:50

标签: jquery html5-video

点击使用JavaScript创建的播放按钮后,我想同时播放两个视频:https://jsfiddle.net/Lrt7nqyn/

目前,只有一个视频在运行。

pieces

1 个答案:

答案 0 :(得分:2)

试试这个:

JSfiddle:https://jsfiddle.net/1co0x58v/

$('input.play', player).bind('click',function () {
      $('video, audio', player)[0].play();
      $('video, audio', player)[1].play(); // add this line to play second video
});
$('input.pause', player).bind('click',function (){
      $('video, audio', player)[0].pause();
      $('video, audio', player)[1].pause(); // add this line to pause second video
});