mirror of
https://github.com/videojs/video.js.git
synced 2025-07-15 01:34:23 +02:00
@dmlap export a basic played() on techs. closes #2384
This commit is contained in:
@ -69,6 +69,7 @@ CHANGELOG
|
|||||||
* Fixed vertical option for volumeMenuButton ([view](https://github.com/videojs/video.js/pull/2352))
|
* Fixed vertical option for volumeMenuButton ([view](https://github.com/videojs/video.js/pull/2352))
|
||||||
* @dmlap switched events to not bubble by default ([view](https://github.com/videojs/video.js/pull/2351))
|
* @dmlap switched events to not bubble by default ([view](https://github.com/videojs/video.js/pull/2351))
|
||||||
* @dmlap export videojs.createTimeRange ([view](https://github.com/videojs/video.js/pull/2361))
|
* @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))
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ class Flash extends Tech {
|
|||||||
// Create setters and getters for attributes
|
// Create setters and getters for attributes
|
||||||
const _api = Flash.prototype;
|
const _api = Flash.prototype;
|
||||||
const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
|
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,played,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
|
const _readOnly = 'error,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
|
||||||
|
|
||||||
function _createSetter(attr){
|
function _createSetter(attr){
|
||||||
var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
|
var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
|
||||||
|
@ -525,6 +525,15 @@ class Html5 extends Tech {
|
|||||||
*/
|
*/
|
||||||
playbackRate() { return this.el_.playbackRate; }
|
playbackRate() { return this.el_.playbackRate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a TimeRanges object that represents the ranges of the
|
||||||
|
* media resource that the user agent has played.
|
||||||
|
* @return {TimeRangeObject} the range of points on the media
|
||||||
|
* timeline that has been reached through normal playback
|
||||||
|
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
|
||||||
|
*/
|
||||||
|
played() { return this.el_.played; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set desired speed at which the media resource is to play
|
* Set desired speed at which the media resource is to play
|
||||||
*
|
*
|
||||||
|
@ -30,6 +30,16 @@ class Tech extends Component {
|
|||||||
options.reportTouchActivity = false;
|
options.reportTouchActivity = false;
|
||||||
super(null, options, ready);
|
super(null, options, ready);
|
||||||
|
|
||||||
|
// keep track of whether the current source has played at all to
|
||||||
|
// implement a very limited played()
|
||||||
|
this.hasStarted_ = false;
|
||||||
|
this.on('playing', function() {
|
||||||
|
this.hasStarted_ = true;
|
||||||
|
});
|
||||||
|
this.on('loadstart', function() {
|
||||||
|
this.hasStarted_ = false;
|
||||||
|
});
|
||||||
|
|
||||||
this.textTracks_ = options.textTracks;
|
this.textTracks_ = options.textTracks;
|
||||||
|
|
||||||
// Manually track progress in cases where the browser/flash player doesn't report it.
|
// Manually track progress in cases where the browser/flash player doesn't report it.
|
||||||
@ -246,6 +256,22 @@ class Tech extends Component {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the time ranges that have been played through for the
|
||||||
|
* current source. This implementation is incomplete. It does not
|
||||||
|
* track the played time ranges, only whether the source has played
|
||||||
|
* at all or not.
|
||||||
|
* @return {TimeRangeObject} a single time range if this video has
|
||||||
|
* played or an empty set of ranges if not.
|
||||||
|
* @method played
|
||||||
|
*/
|
||||||
|
played() {
|
||||||
|
if (this.hasStarted_) {
|
||||||
|
return createTimeRange(0, 0);
|
||||||
|
}
|
||||||
|
return createTimeRange();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set current time
|
* Set current time
|
||||||
*
|
*
|
||||||
|
@ -69,6 +69,11 @@ test('test playbackRate', function() {
|
|||||||
strictEqual(tech.playbackRate(), 0.75);
|
strictEqual(tech.playbackRate(), 0.75);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should export played', function() {
|
||||||
|
tech.createEl();
|
||||||
|
deepEqual(tech.played(), tech.el().played, 'returns the played attribute');
|
||||||
|
});
|
||||||
|
|
||||||
test('should remove the controls attribute when recreating the element', function() {
|
test('should remove the controls attribute when recreating the element', function() {
|
||||||
var el;
|
var el;
|
||||||
player.tagAttributes = {
|
player.tagAttributes = {
|
||||||
|
@ -192,3 +192,12 @@ test('should handle unsupported sources with the source hanlder API', function()
|
|||||||
tech.setSource('');
|
tech.setSource('');
|
||||||
ok(usedNative, 'native source handler was used when an unsupported source was set');
|
ok(usedNative, 'native source handler was used when an unsupported source was set');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should track whether a video has played', function() {
|
||||||
|
let tech = new Tech();
|
||||||
|
|
||||||
|
equal(tech.played().length, 0, 'starts with zero length');
|
||||||
|
|
||||||
|
tech.trigger('playing');
|
||||||
|
equal(tech.played().length, 1, 'has length after playing');
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user