video.js icon indicating copy to clipboard operation
video.js copied to clipboard

Setting currentTime on 'loadedmetadata' event doesn't work properly on flash

Open steplerbox opened this issue 10 years ago • 7 comments

Description

I want to start video from some position. For this purpose I'm using player.currentTime(myTime) on 'loadedmetadata' event. But after that on 'timeupdate' event player.currentTime() === 'myTime' and video plays from the 0. Video should play from my time position and on 'timeupdate' event player.currentTime() should be equal correct time position.

Steps to reproduce

  1. use flash player
  2. add listener to 'loadedmetadata' with player.currentTime(yourTime)
  3. add listener to 'timeupdate' and log player.currentTime() ... PROFIT!!!

versions

videojs

videojs swf 5.1.0 video.js 5.11.0

browsers

chrome

OSes

ubuntu

steplerbox avatar Aug 04 '16 11:08 steplerbox

Does it work better if you use canplay event instead?

gkatsev avatar Aug 15 '16 20:08 gkatsev

Yes, canplay event works. Thank you.

steplerbox avatar Aug 16 '16 13:08 steplerbox

I think, it would be good to document it.

steplerbox avatar Aug 16 '16 14:08 steplerbox

I was having issues with this also. I am using the HTML5 version though. I was using video.js 5.11.0 and I could not get loadedmetadata or canplay working. I was using preload="none", so I had to hit play before the loadedmetadata event fired.

I tried updating to 5.12.1 to see if anything was different and it was not. I was able to get loadmetadata to work by adding a setTimeout. When I hit play, with the code below the loadedmetadata fires, and you cannot notice any play or pauses in the playback when i hit play, just looks like it meant to start playing at the 90 second mark.

I commented on what worked and what did not work in the code below. Thought on how to improve this code. I dont think timeouts is the right way to go.

 player.on('loadedmetadata', function(){
    console.log('inside example_video_1 is loadedmetadata');
          //works
          setTimeout(function() { player.play(); }, 100);
          setTimeout(function() { player.pause(); }, 200);
          setTimeout(function() { player.currentTime(90); }, 300);
          setTimeout(function() { player.play(); }, 400);


          //does not work
          //player.play();
          //player.pause();
          //player.currentTime(90);
          //player.play();         

          //does not work
          //setTimeout(function() { player.pause(); }, 100);
          //setTimeout(function() { player.currentTime(90); }, 200);
          //setTimeout(function() { player.play(); }, 300);

  });

bigt11 avatar Aug 30 '16 20:08 bigt11

Looks like this issue might be similar to #3099 and #3622.

gkatsev avatar Sep 19 '16 22:09 gkatsev

Try this: player.on("ready", function () { this.on('loadedmetadata', function () {
// it all should work here
}); });

rlanhambli avatar May 25 '18 20:05 rlanhambli

Given that Adobe Flash is being end-of-lifed this month we will no longer be working on flash related features.

gkatsev avatar Dec 10 '20 05:12 gkatsev