user2319698
user2319698

Reputation: 11

HTML5 currentTime not working in PhoneGap

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

Answers (1)

Davor Mlinaric
Davor Mlinaric

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

Related Questions