Reputation: 11
I'm using PhoneGap and making an app for Samsung Galaxy Tab 2. I'm trying to play a mp4 video starting at a specific time. Using this code the video only starts from the beginning, and not 20 seconds in. What could be wrong?
function onDeviceReady() {
var playerDiv = document.getElementById('player');
playerDiv.innerHTML="<video id='video' src='"+window.localStorage.getItem("selectedVideo")+"' loop='loop' width='1285' height='752'></video>";
document.getElementById("video").addEventListener("loadedmetadata", function() {
this.currentTime = 20;
}, false);
}
function playVideo() {
document.getElementById('video').play();
}
I have also tried this, but it still starts from the beginning:
document.getElementById('video').addEventListener('loadedmetadata', function() {
this.currentTime = 20;
this.play();
}, false);
And using canplay insted of loadedmetedata does not work.
Upvotes: 1
Views: 435
Reputation: 2027
here is similar question
Trouble with audio tag, jQuery, and currentTime
var audio = $('audio');
audio.bind('canplay', function() {
this.currentTime = 20;
});
audio.get(0).play();
Upvotes: 2