0

I'm developing a Cordova app for Android and I need to put a video with some cue points controlled by buttons.

In the HTML, I have the code to load the mp4 file and the buttons. With JS I'm trying to add the cue points on a click event, but any number I put in the currentTime property, always starts from the beginning of the video. Instead of start from the point I have put.

The code I have is:

document.getElementById("video").load();
document.getElementById("video").addEventListener('loadedmetadata', function() {
    document.getElementById("video").play();
    document.getElementById("video").currentTime = seconds;
}, false);

I tried to change the order of the lines, because I read something over there but no results.


EDIT:

Still no results, now I'm with this:

document.getElementById("video").currentTime = seconds;
document.getElementById("video").play();

But does the same as the others.

Anyone can help?


Thanks.

user409543
  • 116
  • 2
  • At first, why do you play the video and then set `currentTime`? Try to set the time before you are playing the video. - Also, on every change you do on your video try to add `.load()` afterwards for the video to update. – Felix Haeberle Apr 20 '17 at 11:07
  • Thank you for your answer, but I tried and doesn't work. – user409543 Apr 20 '17 at 11:12
  • I assume you have set 'seconds' to a value? also, is your video optimized for streaming (with the MOOV atom at the front - https://stackoverflow.com/questions/32937114/set-up-buffering-for-video-object/32959717#32959717 - otherwise it won't be able to seek correctly until it has read to the end of the file) – Offbeatmammal Apr 20 '17 at 14:40

1 Answers1

0

It was because of the frame rate.

The video I was trying initially had 30 and I tried with one of 24 and it worked.

user409543
  • 116
  • 2