1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-28 08:58:46 +02:00

Merge branch 'stable'

This commit is contained in:
Gary Katsevman 2016-08-15 18:20:47 -04:00
commit 773b5ab1c1
9 changed files with 70 additions and 11 deletions

View File

@ -17,6 +17,12 @@ CHANGELOG
--------------------
## 5.11.3 (2016-08-15)
* @vdeshpande fixed control text for fullscreen button ([view](https://github.com/videojs/video.js/pull/3485))
* @mister-ben fixed android treating swipe as a tap ([view](https://github.com/videojs/video.js/pull/3514))
* @mboles updated duration() method documentation ([view](https://github.com/videojs/video.js/pull/3515))
* @mister-ben silenced chrome's play() request was interrupted by pause() error ([view](https://github.com/videojs/video.js/pull/3518))
## 5.11.2 (2016-08-09)
_(none)_

View File

@ -1,7 +1,7 @@
{
"name": "video.js",
"description": "An HTML5 and Flash video player with a common API and skin for both.",
"version": "5.11.2",
"version": "5.11.3",
"keywords": [
"videojs",
"html5",

View File

@ -1,7 +1,7 @@
{
"name": "video.js",
"description": "An HTML5 and Flash video player with a common API and skin for both.",
"version": "5.11.2",
"version": "5.11.3",
"copyright": "Copyright Brightcove, Inc. <https://www.brightcove.com/>",
"license": "Apache-2.0",
"keywords": [

View File

@ -10,7 +10,6 @@ import * as Guid from './utils/guid.js';
import * as Events from './utils/events.js';
import log from './utils/log.js';
import toTitleCase from './utils/to-title-case.js';
import assign from 'object.assign';
import mergeOptions from './utils/merge-options.js';
/**
@ -1179,8 +1178,11 @@ class Component {
this.on('touchstart', function(event) {
// If more than one finger, don't consider treating this as a click
if (event.touches.length === 1) {
// Copy the touches object to prevent modifying the original
firstTouch = assign({}, event.touches[0]);
// Copy pageX/pageY from the object
firstTouch = {
pageX: event.touches[0].pageX,
pageY: event.touches[0].pageY
};
// Record start time so we can detect a tap vs. "touch and hold"
touchStart = new Date().getTime();
// Reset couldBeTap tracking

View File

@ -12,6 +12,11 @@ import Component from '../component.js';
*/
class FullscreenToggle extends Button {
constructor(player, options) {
super(player, options);
this.on(player, 'fullscreenchange', this.handleFullscreenChange);
}
/**
* Allow sub components to stack CSS class names
*
@ -21,7 +26,18 @@ class FullscreenToggle extends Button {
buildCSSClass() {
return `vjs-fullscreen-control ${super.buildCSSClass()}`;
}
/**
* Handles Fullscreenchange on the component and change control text accordingly
*
* @method handleFullscreenChange
*/
handleFullscreenChange() {
if (this.player_.isFullscreen()) {
this.controlText('Non-Fullscreen');
} else {
this.controlText('Fullscreen');
}
}
/**
* Handles click for full screen
*
@ -30,10 +46,8 @@ class FullscreenToggle extends Button {
handleClick() {
if (!this.player_.isFullscreen()) {
this.player_.requestFullscreen();
this.controlText('Non-Fullscreen');
} else {
this.player_.exitFullscreen();
this.controlText('Fullscreen');
}
}

View File

@ -1444,7 +1444,8 @@ class Player extends Component {
}
/**
* Get the length in time of the video in seconds
* Normally gets the length in time of the video in seconds;
* in all but the rarest use cases an argument will NOT be passed to the method
* ```js
* var lengthOfVideo = myPlayer.duration();
* ```

View File

@ -437,7 +437,13 @@ class Html5 extends Tech {
* @method play
*/
play() {
this.el_.play();
const playPromise = this.el_.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
playPromise.then(null, (e) => {});
}
}
/**

View File

@ -3,6 +3,7 @@ import VolumeControl from '../../src/js/control-bar/volume-control/volume-contro
import MuteToggle from '../../src/js/control-bar/mute-toggle.js';
import PlaybackRateMenuButton from '../../src/js/control-bar/playback-rate-menu/playback-rate-menu-button.js';
import Slider from '../../src/js/slider/slider.js';
import FullscreenToggle from '../../src/js/control-bar/fullscreen-toggle.js';
import TestHelpers from './test-helpers.js';
import document from 'global/document';
@ -110,3 +111,15 @@ QUnit.test('should hide playback rate control if it\'s not supported', function(
assert.ok(playbackRate.el().className.indexOf('vjs-hidden') >= 0, 'playbackRate is not hidden');
});
QUnit.test('Fullscreen control text should be correct when fullscreenchange is triggered', function() {
const player = TestHelpers.makePlayer();
const fullscreentoggle = new FullscreenToggle(player);
player.isFullscreen(true);
player.trigger('fullscreenchange');
QUnit.equal(fullscreentoggle.controlText(), 'Non-Fullscreen', 'Control Text is correct while switching to fullscreen mode');
player.isFullscreen(false);
player.trigger('fullscreenchange');
QUnit.equal(fullscreentoggle.controlText(), 'Fullscreen', 'Control Text is correct while switching back to normal mode');
});

View File

@ -1,4 +1,4 @@
/* eslint-env qunit */
/* eslint-env qunit, browser */
let player;
let tech;
@ -517,3 +517,20 @@ QUnit.test('Html5#reset calls Html5.resetMediaElement when called', function(ass
Html5.resetMediaElement = oldResetMedia;
});
QUnit.test('Exception in play promise should be caught', function() {
const oldEl = tech.el_;
tech.el_ = {
play: () => {
return new Promise(function(resolve, reject) {
reject(new DOMException());
});
}
};
tech.play();
QUnit.ok(true, 'error was caught');
tech.el_ = oldEl;
});