I using PhoneGap for android application, HTML5 video tag for play video in application. the video is playing from phone SD card
HTML:
<video id="homevideo" width="100%" controls>
<source type="video/m4v" src="file:///mnt/ext_card/app/test1.m4v" >
</video>
Script:
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();
}
also i used addEventListener
for looping
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);
Only one video played, but it not looped... how can i loop the video one by one after previous video complate?
Got working this with jQuery...
i just tried with jQuery
instant of Javascript
its working now...
added JQuery library in head
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
and script
used
$("#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();
});
Its working!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.