mirror of
https://github.com/videojs/video.js.git
synced 2025-03-19 21:28:23 +02:00
Merge branch 'bugfix/lastseek-cleanup' of git://github.com/dmlap/video-js into dmlap-bugfix/lastseek-cleanup
This commit is contained in:
commit
7ade43d91d
@ -68,25 +68,7 @@ vjs.SeekBar.prototype.updateARIAAttributes = function(){
|
||||
};
|
||||
|
||||
vjs.SeekBar.prototype.getPercent = function(){
|
||||
var currentTime;
|
||||
// Flash RTMP provider will not report the correct time
|
||||
// immediately after a seek. This isn't noticeable if you're
|
||||
// seeking while the video is playing, but it is if you seek
|
||||
// while the video is paused.
|
||||
if (this.player_.techName === 'Flash' && this.player_.seeking()) {
|
||||
var cache = this.player_.getCache();
|
||||
if (cache.lastSetCurrentTime) {
|
||||
currentTime = cache.lastSetCurrentTime;
|
||||
}
|
||||
else {
|
||||
currentTime = this.player_.currentTime();
|
||||
}
|
||||
}
|
||||
else {
|
||||
currentTime = this.player_.currentTime();
|
||||
}
|
||||
|
||||
return currentTime / this.player_.duration();
|
||||
return this.player_.currentTime() / this.player_.duration();
|
||||
};
|
||||
|
||||
vjs.SeekBar.prototype.onMouseDown = function(event){
|
||||
|
@ -60,7 +60,9 @@ vjs.Flash = vjs.MediaTechController.extend({
|
||||
'id': objId,
|
||||
'name': objId, // Both ID and Name needed or swf to identifty itself
|
||||
'class': 'vjs-tech'
|
||||
}, options['attributes'])
|
||||
}, options['attributes']),
|
||||
|
||||
lastSeekTarget
|
||||
;
|
||||
|
||||
// If source was supplied pass as a flash var.
|
||||
@ -75,6 +77,17 @@ vjs.Flash = vjs.MediaTechController.extend({
|
||||
}
|
||||
}
|
||||
|
||||
this['setCurrentTime'] = function(time){
|
||||
lastSeekTarget = time;
|
||||
this.el_.vjs_setProperty('currentTime', time);
|
||||
};
|
||||
this['currentTime'] = function(time){
|
||||
if (this.seeking()) {
|
||||
return lastSeekTarget;
|
||||
}
|
||||
return this.el_.vjs_getProperty('currentTime');
|
||||
};
|
||||
|
||||
// Add placeholder to player div
|
||||
vjs.insertFirst(placeHolder, parentEl);
|
||||
|
||||
@ -302,9 +315,9 @@ vjs.Flash.prototype.enterFullScreen = function(){
|
||||
|
||||
// Create setters and getters for attributes
|
||||
var api = vjs.Flash.prototype,
|
||||
readWrite = 'rtmpConnection,rtmpStream,preload,currentTime,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(','),
|
||||
readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(','),
|
||||
readOnly = 'error,currentSrc,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks'.split(',');
|
||||
// Overridden: buffered
|
||||
// Overridden: buffered, currentTime
|
||||
|
||||
/**
|
||||
* @this {*}
|
||||
|
@ -650,9 +650,6 @@ vjs.Player.prototype.paused = function(){
|
||||
vjs.Player.prototype.currentTime = function(seconds){
|
||||
if (seconds !== undefined) {
|
||||
|
||||
// cache the last set value for smoother scrubbing
|
||||
this.cache_.lastSetCurrentTime = seconds;
|
||||
|
||||
this.techCall('setCurrentTime', seconds);
|
||||
|
||||
// improve the accuracy of manual timeupdates
|
||||
|
@ -62,3 +62,37 @@ test('test canPlaySource', function() {
|
||||
ok(!canPlaySource({ type: 'video/webm; codecs="vp8, vorbis"' }));
|
||||
ok(!canPlaySource({ type: 'video/webm' }));
|
||||
});
|
||||
|
||||
test('currentTime is the seek target during seeking', function() {
|
||||
var noop = function() {},
|
||||
seeking = false,
|
||||
parentEl = document.createElement('div'),
|
||||
tech = new vjs.Flash({
|
||||
id: noop,
|
||||
on: noop,
|
||||
options_: {}
|
||||
}, {
|
||||
'parentEl': parentEl
|
||||
}),
|
||||
currentTime;
|
||||
|
||||
tech.el().vjs_setProperty = function(property, value) {
|
||||
if (property === 'currentTime') {
|
||||
currentTime = value;
|
||||
}
|
||||
};
|
||||
tech.el().vjs_getProperty = function(name) {
|
||||
if (name === 'currentTime') {
|
||||
return currentTime;
|
||||
} else if (name === 'seeking') {
|
||||
return seeking;
|
||||
}
|
||||
};
|
||||
|
||||
currentTime = 3;
|
||||
strictEqual(3, tech.currentTime(), 'currentTime is retreived from the SWF');
|
||||
|
||||
tech['setCurrentTime'](7);
|
||||
seeking = true;
|
||||
strictEqual(7, tech.currentTime(), 'during seeks the target time is returned');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user