Open lil0r opened 1 year ago
Thanks for opening, I also noticed this myself recently that this stopped working!
I'm in the same situation.
Change the loadedmetadata
event to the playing
event, and then get around it for now.
But no autoplay.
Time setting is held off until a canplay
event occurs, function currentTime
.
v1.8 - 7.20.2 video.js (L.L.25427-25456)
/**
* Get or set the current time (in seconds)
*
* @param {number|string} [seconds]
* The time to seek to in seconds
*
* @return {number}
* - the current time in seconds when getting
*/
;
_proto.currentTime = function currentTime(seconds) {
if (typeof seconds !== 'undefined') {
if (seconds < 0) {
seconds = 0;
}
this.techCall_('setCurrentTime', seconds);
return;
} // cache last currentTime and return. default to 0 seconds
//
// Caching the currentTime is meant to prevent a massive amount of reads on the tech's
// currentTime when scrubbing, but may not provide much performance benefit afterall.
// Should be tested. Also something has to read the actual current time or the cache will
// never get updated.
this.cache_.currentTime = this.techGet_('currentTime') || 0;
return this.cache_.currentTime;
}
v1.9 - 7.20.2 video.js (L.L.27087-27124)
/**
* Get or set the current time (in seconds)
*
* @param {number|string} [seconds]
* The time to seek to in seconds
*
* @return {number}
* - the current time in seconds when getting
*/
;
_proto.currentTime = function currentTime(seconds) {
if (typeof seconds !== 'undefined') {
if (seconds < 0) {
seconds = 0;
}
if (!this.isReady_ || this.changingSrc_ || !this.tech_ || !this.tech_.isReady_) {
this.cache_.initTime = seconds;
this.off('canplay', this.boundApplyInitTime_);
this.one('canplay', this.boundApplyInitTime_);
return;
}
this.techCall_('setCurrentTime', seconds);
this.cache_.initTime = 0;
return;
} // cache last currentTime and return. default to 0 seconds
//
// Caching the currentTime is meant to prevent a massive amount of reads on the tech's
// currentTime when scrubbing, but may not provide much performance benefit afterall.
// Should be tested. Also something has to read the actual current time or the cache will
// never get updated.
this.cache_.currentTime = this.techGet_('currentTime') || 0;
return this.cache_.currentTime;
}
video.js L.L.24845-24847
_this.boundApplyInitTime_ = function (e) {
return _this.applyInitTime_(e);
};
video.js L.L.27132-27134
_proto.applyInitTime_ = function applyInitTime_() {
this.currentTime(this.cache_.initTime);
}
Change the loadedmetadata
event to the canplaythrough
event that occurs after the canplay
event
player.player.one('canplaythrough', () => {
const urlParams = new URLSearchParams(window.location.search);
const paramT = Number(urlParams.get('t'));
const timestamp = !isNaN(paramT) ? paramT : 0;
player.player.currentTime(timestamp);
});
See #928
Describe the issue Expected to be able to link to specific timestamp in video by adding URL parameter
To Reproduce Steps to reproduce the issue:
Expected behavior video to jump to 60 seconds mark
Environment (please complete the following information):
Additional context Add any other context about the problem here.