mirror of
https://github.com/videojs/video.js.git
synced 2024-12-25 02:42:10 +02:00
@forbesjo added the `scrubbing` property. closes #2080
This commit is contained in:
parent
f19d13b9bb
commit
69738a86dc
@ -14,7 +14,8 @@ CHANGELOG
|
||||
* @dconnolly replaced JSON.parse with a safe non-eval JSON parse ([view](https://github.com/videojs/video.js/pull/2077))
|
||||
* @mmcc added a new default skin, switched to SASS, modified the html ([view](https://github.com/videojs/video.js/pull/1999))
|
||||
* @gkatsev removed event.isDefaultPrevented in favor of event.defaultPrevented ([view](https://github.com/videojs/video.js/pull/2081))
|
||||
* @heff added and `extends` function for external subclassing ([view](https://github.com/videojs/video.js/pull/2078))
|
||||
* @heff added and `extends` function for external subclassing ([view](https://github.com/videojs/video.js/pull/2078))
|
||||
* @forbesjo added the `scrubbing` property ([view](https://github.com/videojs/video.js/pull/2080))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -28,7 +28,7 @@ class SeekBar extends Slider {
|
||||
|
||||
updateARIAAttributes() {
|
||||
// Allows for smooth scrubbing, when player can't keep up.
|
||||
let time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
|
||||
let time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
|
||||
this.el_.setAttribute('aria-valuenow', Lib.round(this.getPercent()*100, 2)); // machine readable value of progress bar (percentage complete)
|
||||
this.el_.setAttribute('aria-valuetext', Lib.formatTime(time, this.player_.duration())); // human readable value of progress bar (time complete)
|
||||
}
|
||||
@ -40,8 +40,7 @@ class SeekBar extends Slider {
|
||||
onMouseDown(event) {
|
||||
super.onMouseDown(event);
|
||||
|
||||
this.player_.scrubbing = true;
|
||||
this.player_.addClass('vjs-scrubbing');
|
||||
this.player_.scrubbing(true);
|
||||
|
||||
this.videoWasPlaying = !this.player_.paused();
|
||||
this.player_.pause();
|
||||
@ -60,8 +59,7 @@ class SeekBar extends Slider {
|
||||
onMouseUp(event) {
|
||||
super.onMouseUp(event);
|
||||
|
||||
this.player_.scrubbing = false;
|
||||
this.player_.removeClass('vjs-scrubbing');
|
||||
this.player_.scrubbing(false);
|
||||
if (this.videoWasPlaying) {
|
||||
this.player_.play();
|
||||
}
|
||||
|
@ -100,6 +100,13 @@ class Player extends Component {
|
||||
// May be turned back on by HTML5 tech if nativeControlsForTouch is true
|
||||
tag.controls = false;
|
||||
|
||||
/**
|
||||
* Store the internal state of scrubbing
|
||||
* @private
|
||||
* @return {Boolean} True if the user is scrubbing
|
||||
*/
|
||||
this.scrubbing_ = false;
|
||||
|
||||
this.el_ = this.createEl();
|
||||
this.initChildren();
|
||||
|
||||
@ -559,6 +566,29 @@ class Player extends Component {
|
||||
return (this.techGet('paused') === false) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the user is "scrubbing". Scrubbing is when the user
|
||||
* has clicked the progress bar handle and is dragging it along the progress bar.
|
||||
* @param {Boolean} isScrubbing True/false the user is scrubbing
|
||||
* @return {Boolean} The scrubbing status when getting
|
||||
* @return {Object} The player when setting
|
||||
*/
|
||||
scrubbing(isScrubbing) {
|
||||
if (isScrubbing !== undefined) {
|
||||
this.scrubbing_ = !!isScrubbing;
|
||||
|
||||
if (isScrubbing) {
|
||||
this.addClass('vjs-scrubbing');
|
||||
} else {
|
||||
this.removeClass('vjs-scrubbing');
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return this.scrubbing_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the current time (in seconds)
|
||||
*
|
||||
|
@ -702,3 +702,18 @@ test('should add an audio class if an audio el is used', function() {
|
||||
|
||||
ok(player.el().className.indexOf(audioClass) !== -1, 'added '+ audioClass +' css class');
|
||||
});
|
||||
|
||||
test('should not be scrubbing while not seeking', function(){
|
||||
var player = TestHelpers.makePlayer();
|
||||
equal(player.scrubbing(), false, 'player is not scrubbing');
|
||||
ok(player.el().className.indexOf('scrubbing') === -1, 'scrubbing class is not present');
|
||||
player.scrubbing(false);
|
||||
equal(player.scrubbing(), false, 'player is not scrubbing');
|
||||
});
|
||||
|
||||
test('should be scrubbing while seeking', function(){
|
||||
var player = TestHelpers.makePlayer();
|
||||
player.scrubbing(true);
|
||||
equal(player.scrubbing(), true, 'player is scrubbing');
|
||||
ok(player.el().className.indexOf('scrubbing') !== -1, 'scrubbing class is present');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user