1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-25 11:13:52 +02:00

@gkatsev improved tech controls listener handling.. closes #2511

This commit is contained in:
Gary Katsevman 2015-08-25 16:17:35 -04:00
parent e10a2f4b03
commit de39cfc5ab
3 changed files with 30 additions and 2 deletions

View File

@ -108,6 +108,7 @@ CHANGELOG
* @forbesjo switched automated testing to BrowserStack ([view](https://github.com/videojs/video.js/pull/2492))
* @gkatsev fixed nativeControlsForTouch handling. Defaults to native controls on iphone and native android browsers. ([view](https://github.com/videojs/video.js/pull/2499))
* @heff fixed cross-platform track tests by switching to a fake tech ([view](https://github.com/videojs/video.js/pull/2496))
* @gkatsev improved tech controls listener handling. ([view](https://github.com/videojs/video.js/pull/2511))
--------------------

View File

@ -609,6 +609,9 @@ class Player extends Component {
* @method addTechControlsListeners
*/
addTechControlsListeners() {
// Make sure to remove all the previous listeners in case we are called multiple times.
this.removeTechControlsListeners();
// Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
// trigger mousedown/up.
// http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
@ -1939,7 +1942,6 @@ class Player extends Component {
if (this.usingNativeControls_ !== bool) {
this.usingNativeControls_ = bool;
if (bool) {
this.removeTechControlsListeners();
this.addClass('vjs-using-native-controls');
/**
@ -1952,7 +1954,6 @@ class Player extends Component {
*/
this.trigger('usingnativecontrols');
} else {
this.addTechControlsListeners();
this.removeClass('vjs-using-native-controls');
/**

View File

@ -415,6 +415,32 @@ test('should allow for tracking when native controls are used', function(){
player.dispose();
});
test('make sure that controls listeners do not get added too many times', function(){
var player = TestHelpers.makePlayer({});
var listeners = 0;
player.addTechControlsListeners = function() {
listeners++;
};
// Make sure native controls is false before starting test
player.usingNativeControls(false);
player.usingNativeControls(true);
player.controls(true);
equal(listeners, 0, 'addTechControlsListeners should not have gotten called yet');
player.usingNativeControls(false);
player.controls(false);
player.controls(true);
equal(listeners, 1, 'addTechControlsListeners should have gotten called once');
player.dispose();
});
// test('should use custom message when encountering an unsupported video type',
// function() {
// videojs.options['notSupportedMessage'] = 'Video no go <a href="">link</a>';