1

我将 PhoneGap 用于 android 应用程序,HTML5 视频标签用于在应用程序中播放视频。视频正在从手机 SD 卡播放

HTML:

<video id="homevideo" width="100%" controls>
        <source  type="video/m4v" src="file:///mnt/ext_card/app/test1.m4v" >
</video>

脚本:

var videoPlayer;
var video_count = 1;

document.addEventListener("deviceready", videoplay, false);
function videoplay(){ 
    videoPlayer = document.getElementById("homevideo");
     videoPlayer.play();

}
videoPlayer.onended = function(e) {
      video_count++;
      if (video_count == 4) video_count = 1;
      var nextVideo = "file:///mnt/ext_card/app/test"+video_count+".m4v";
      videoPlayer.src = nextVideo;
      videoPlayer.play();
}

我也用于addEventListener循环

videoPlayer.addEventListener("ended", function (){
       video_count++;
       if (video_count == 4) video_count = 1;
       var nextVideo = "file:///mnt/ext_card/app/advertisements/test"+video_count+".m4v";
       videoPlayer.src = nextVideo;
       videoPlayer.play();
}, false); 

只播放了一个视频,但没有循环播放...如何在上一个视频完成后一个接一个地循环播放视频?

4

1 回答 1

0

用 jQuery 处理这个...

我刚刚尝试了它的jQuery即时Javascript工作......

在中添加了 JQuery 库head

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

script使用

$("#homevideo").bind('ended', function(){ 
  video_count++;
       if (video_count == 4) video_count = 1;
       var nextVideo = "file:///mnt/ext_card/app/advertisements/test"+video_count+".m4v";
       videoPlayer.src = nextVideo;
       videoPlayer.play();
});

它的工作!

于 2013-06-27T13:44:44.603 回答