mirror of
https://github.com/videojs/video.js.git
synced 2024-12-25 02:42:10 +02:00
@dmlap fire seeking in the flash tech, not the SWF. closes #2372
This commit is contained in:
parent
4056c5f75c
commit
4ad45ef9a8
@ -71,6 +71,7 @@ CHANGELOG
|
||||
* @dmlap export videojs.createTimeRange ([view](https://github.com/videojs/video.js/pull/2361))
|
||||
* @dmlap export a basic played() on techs ([view](https://github.com/videojs/video.js/pull/2384))
|
||||
* @dmlap use seekable on source handlers when defined ([view](https://github.com/videojs/video.js/pull/2376))
|
||||
* @dmlap fire seeking in the flash tech, not the SWF ([view](https://github.com/videojs/video.js/pull/2372))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
"safe-json-parse": "^4.0.0",
|
||||
"videojs-font": "1.3.0",
|
||||
"videojs-ie8": "1.1.0",
|
||||
"videojs-swf": "4.7.1",
|
||||
"videojs-swf": "5.0.0-rc0",
|
||||
"vtt.js": "git+https://github.com/gkatsev/vtt.js.git#vjs-v0.12.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -54,6 +54,10 @@ class Flash extends Tech {
|
||||
window.videojs.Flash.onReady = Flash.onReady;
|
||||
window.videojs.Flash.onEvent = Flash.onEvent;
|
||||
window.videojs.Flash.onError = Flash.onError;
|
||||
|
||||
this.on('seeked', function() {
|
||||
this.lastSeekTarget_ = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,6 +161,14 @@ class Flash extends Tech {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the tech is currently seeking.
|
||||
* @return {boolean} true if seeking
|
||||
*/
|
||||
seeking() {
|
||||
return this.lastSeekTarget_ !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current time
|
||||
*
|
||||
@ -171,6 +183,7 @@ class Flash extends Tech {
|
||||
time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
|
||||
|
||||
this.lastSeekTarget_ = time;
|
||||
this.trigger('seeking');
|
||||
this.el_.vjs_setProperty('currentTime', time);
|
||||
super.setCurrentTime();
|
||||
}
|
||||
@ -284,7 +297,7 @@ class Flash extends Tech {
|
||||
// Create setters and getters for attributes
|
||||
const _api = Flash.prototype;
|
||||
const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
|
||||
const _readOnly = 'error,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
|
||||
const _readOnly = 'error,networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
|
||||
|
||||
function _createSetter(attr){
|
||||
var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
|
||||
|
@ -23,6 +23,7 @@ test('Flash.canPlaySource', function() {
|
||||
test('currentTime', function() {
|
||||
let getCurrentTime = Flash.prototype.currentTime;
|
||||
let setCurrentTime = Flash.prototype.setCurrentTime;
|
||||
let seekingCount = 0;
|
||||
let seeking = false;
|
||||
let setPropVal;
|
||||
let getPropVal;
|
||||
@ -41,6 +42,11 @@ test('currentTime', function() {
|
||||
seekable(){
|
||||
return createTimeRange(5, 1000);
|
||||
},
|
||||
trigger(event){
|
||||
if (event === 'seeking') {
|
||||
seekingCount++;
|
||||
}
|
||||
},
|
||||
seeking(){
|
||||
return seeking;
|
||||
}
|
||||
@ -54,6 +60,7 @@ test('currentTime', function() {
|
||||
// Test the currentTime setter
|
||||
setCurrentTime.call(mockFlash, 10);
|
||||
equal(setPropVal, 10, 'currentTime is set on the swf element');
|
||||
equal(seekingCount, 1, 'triggered seeking');
|
||||
|
||||
// Test current time while seeking
|
||||
setCurrentTime.call(mockFlash, 20);
|
||||
@ -61,15 +68,18 @@ test('currentTime', function() {
|
||||
result = getCurrentTime.call(mockFlash);
|
||||
equal(result, 20, 'currentTime is retrieved from the lastSeekTarget while seeking');
|
||||
notEqual(result, getPropVal, 'currentTime is not retrieved from the element while seeking');
|
||||
equal(seekingCount, 2, 'triggered seeking');
|
||||
|
||||
// clamp seeks to seekable
|
||||
setCurrentTime.call(mockFlash, 1001);
|
||||
result = getCurrentTime.call(mockFlash);
|
||||
equal(result, mockFlash.seekable().end(0), 'clamped to the seekable end');
|
||||
equal(seekingCount, 3, 'triggered seeking');
|
||||
|
||||
setCurrentTime.call(mockFlash, 1);
|
||||
result = getCurrentTime.call(mockFlash);
|
||||
equal(result, mockFlash.seekable().start(0), 'clamped to the seekable start');
|
||||
equal(seekingCount, 4, 'triggered seeking');
|
||||
});
|
||||
|
||||
test('dispose removes the object element even before ready fires', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user