Comparar commits
12 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| d482e278d8 | |||
| 803777227b | |||
| 30fa4813c6 | |||
| c82b615f01 | |||
| 0bc2a4d4d5 | |||
| d59769821d | |||
| 2d01479fb5 | |||
| d8ea23e0c9 | |||
| 9d249bb23b | |||
| 7929677f6f | |||
| 6cd785ab7f | |||
| edde614822 |
@@ -26,6 +26,7 @@
|
||||
* [languages](#languages)
|
||||
* [nativeControlsForTouch](#nativecontrolsfortouch)
|
||||
* [notSupportedMessage](#notsupportedmessage)
|
||||
* [playbackRates](#playbackrates)
|
||||
* [plugins](#plugins)
|
||||
* [sourceOrder](#sourceorder)
|
||||
* [sources](#sources)
|
||||
@@ -180,6 +181,24 @@ Explicitly set a default value for [the associated tech option](#nativecontrolsf
|
||||
|
||||
Allows overriding the default message that is displayed when Video.js cannot play back a media source.
|
||||
|
||||
### `playbackRates`
|
||||
|
||||
> Type: `Array`
|
||||
|
||||
An array of numbers strictly greater than 0, where 1 means regular speed
|
||||
(100%), 0.5 means half-speed (50%), 2 means double-speed (200%), etc.
|
||||
If specified, Video.js displays a control (of class `vjs-playback-rate`)
|
||||
allowing the user to choose playback speed from among the array of choices.
|
||||
The choices are presented in the specified order from bottom to top.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
videojs('my-player', {
|
||||
playbackRates: [0.5, 1, 1.5, 2]
|
||||
});
|
||||
```
|
||||
|
||||
### `plugins`
|
||||
|
||||
> Type: `Object`
|
||||
|
||||
@@ -251,7 +251,7 @@ class Advanced extends Plugin {
|
||||
}
|
||||
|
||||
updateState() {
|
||||
this.setState({playing: !player.paused()});
|
||||
this.setState({playing: !this.player.paused()});
|
||||
}
|
||||
|
||||
logState(changed) {
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@
|
||||
"rollup": "babel-node build/rollup.js",
|
||||
"rollup-minify": "babel-node build/rollup.js --minify",
|
||||
"rollup-dev": "babel-node build/rollup.js --watch",
|
||||
"watch": "npm run rollup-dev",
|
||||
"assets": "node build/assets.js",
|
||||
"change": "grunt chg-add",
|
||||
"clean": "grunt clean",
|
||||
@@ -83,7 +84,7 @@
|
||||
"grunt-accessibility": "^5.0.0",
|
||||
"grunt-babel": "^7.0.0",
|
||||
"grunt-banner": "^0.6.0",
|
||||
"grunt-browserify": "5.1.0",
|
||||
"grunt-browserify": "5.2.0",
|
||||
"grunt-cli": "~1.2.0",
|
||||
"grunt-concurrent": "^2.3.1",
|
||||
"grunt-contrib-clean": "^1.0.0",
|
||||
@@ -133,7 +134,7 @@
|
||||
"remark-parse": "^4.0.0",
|
||||
"remark-stringify": "^4.0.0",
|
||||
"remark-toc": "^4.0.0",
|
||||
"remark-validate-links": "^6.0.0",
|
||||
"remark-validate-links": "^7.0.0",
|
||||
"replace": "^0.3.0",
|
||||
"rollup": "^0.47.5",
|
||||
"rollup-plugin-babel": "^2.7.1",
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Video.js Sandbox</title>
|
||||
<script src='../node_modules/es5-shim/es5-shim.js'></script>
|
||||
<script src='../node_modules/es6-shim/es6-shim.js'></script>
|
||||
|
||||
<link href="../build/temp/video-js.css" rel="stylesheet" type="text/css">
|
||||
<script src="../dist/video.js"></script>
|
||||
|
||||
<script src='../node_modules/videojs-flash/dist/videojs-flash.js'></script>
|
||||
<script src="https://unpkg.com/videojs-contrib-hls@latest/dist/videojs-contrib-hls.js"></script>
|
||||
|
||||
<script src="../build/temp/lang/es.js"></script>
|
||||
|
||||
<!-- Set the location of the flash SWF -->
|
||||
<script>
|
||||
// videojs.options.flash.swf = 'http://vjs.zencdn.net/swf/5.3/video-js.swf';
|
||||
videojs.options.flash.swf = 'http://localhost:8000/video-js-swf/dist/video-js.swf';
|
||||
</script>
|
||||
<style>
|
||||
.source-el { background: #FF6961; }
|
||||
.source-js { background: #77DD77; }
|
||||
.options-src { background: #AEC6CF; }
|
||||
.source-el.data-setup { background: red; }
|
||||
.source-js.data-setup { background: green; }
|
||||
.options-src.data-setup { background: blue; }
|
||||
|
||||
.video-js {
|
||||
height: 150px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
display: grid;
|
||||
margin: 0 auto;
|
||||
grid-gap: 10px;
|
||||
grid-template-columns: 300px 300px 300px;
|
||||
}
|
||||
.panel > p:first-child {
|
||||
border-bottom: black 1px solid;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>All the various ways to embed and source video elements.</p>
|
||||
<p>Pastel color background represent programmatic setup.</p>
|
||||
<p>Vibrant color background represent data-setup.</p>
|
||||
<div class="wrapper">
|
||||
<div class="panel source-el">
|
||||
<p>js setup with source element</p>
|
||||
<p>Div embed, source element</p>
|
||||
<div id="vid01" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png">
|
||||
<source src="./oceans.mp4" type='video/mp4'>
|
||||
</div>
|
||||
<p>Video embed, source element</p>
|
||||
<video id="vid11" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png">
|
||||
<source src="./oceans.mp4" type='video/mp4'>
|
||||
</video>
|
||||
<p>injested div el, source element</p>
|
||||
<div data-vjs-player>
|
||||
<video id="vid21" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png">
|
||||
<source src="./oceans.mp4" type='video/mp4'>
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel options-src">
|
||||
<p>js setup with sources options</p>
|
||||
<p>Div embed, js source</p>
|
||||
<div id="vid05" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png">
|
||||
</div>
|
||||
<p>Video embed, js source</p>
|
||||
<video id="vid15" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png">
|
||||
</video>
|
||||
<p>injested div el, js source</p>
|
||||
<div data-vjs-player>
|
||||
<video id="vid25" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png">
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel source-js">
|
||||
<p>js setup with js method sources</p>
|
||||
<p>Div embed, js source</p>
|
||||
<div id="vid02" class="video-js" controls>
|
||||
</div>
|
||||
<p>Video embed, js source</p>
|
||||
<video id="vid12" class="video-js" controls>
|
||||
</video>
|
||||
<p>injested div el, js source</p>
|
||||
<div data-vjs-player>
|
||||
<video id="vid22" class="video-js" controls>
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel source-el data-setup">
|
||||
<p>data-setup with sourrce elements</p>
|
||||
<p>Div embed, source element</p>
|
||||
<div id="vid03" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup="{}">
|
||||
<source src="./oceans.mp4" type='video/mp4'>
|
||||
</div>
|
||||
<p>Video embed, source element</p>
|
||||
<video id="vid13" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup="{}">
|
||||
<source src="./oceans.mp4" type='video/mp4'>
|
||||
</video>
|
||||
<p>injested div el, source element</p>
|
||||
<div data-vjs-player>
|
||||
<video id="vid23" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup="{}">
|
||||
<source src="./oceans.mp4" type='video/mp4'>
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel options-src data-setup">
|
||||
<p>data-setup embeds with sources options</p>
|
||||
<p>Div embed, source element</p>
|
||||
<div id="vid04" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup='{"sources": [{"src":"./oceans.mp4", "type":"video/mp4"}]}'>
|
||||
</div>
|
||||
<p>Video embed, source element</p>
|
||||
<video id="vid14" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup='{"sources": [{"src":"./oceans.mp4", "type":"video/mp4"}]}'>
|
||||
</video>
|
||||
<p>injested div el, source element</p>
|
||||
<div data-vjs-player>
|
||||
<video id="vid24" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup='{"sources": [{"src":"./oceans.mp4", "type":"video/mp4"}]}'>
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel source-js data-setup">
|
||||
<p>js setup with js method sources</p>
|
||||
<p>Div embed, js source</p>
|
||||
<div id="vid06" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup="{}">
|
||||
</div>
|
||||
<p>Video embed, js source</p>
|
||||
<video id="vid16" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup="{}">
|
||||
</video>
|
||||
<p>injested div el, js source</p>
|
||||
<div data-vjs-player>
|
||||
<video id="vid26" class="video-js" controls poster="//vjs.zencdn.net/v/oceans.png" data-setup="{}">
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var player01 = videojs('vid01');
|
||||
var player11 = videojs('vid11');
|
||||
var player21 = videojs('vid21');
|
||||
var player01 = videojs('vid02');
|
||||
var player11 = videojs('vid12');
|
||||
var player21 = videojs('vid22');
|
||||
var player05 = videojs('vid05', {sources: [{src:'./oceans.mp4',type:'video/mp4'}]});
|
||||
var player15 = videojs('vid15', {sources: [{src:'./oceans.mp4',type:'video/mp4'}]});
|
||||
var player25 = videojs('vid25', {sources: [{src:'./oceans.mp4',type:'video/mp4'}]});
|
||||
player01.src({src:'./oceans.mp4', type:'video/mp4'});
|
||||
player11.src({src:'./oceans.mp4', type:'video/mp4'});
|
||||
player21.src({src:'./oceans.mp4', type:'video/mp4'});
|
||||
player01.poster('//vjs.zencdn.net/v/oceans.png');
|
||||
player11.poster('//vjs.zencdn.net/v/oceans.png');
|
||||
player21.poster('//vjs.zencdn.net/v/oceans.png');
|
||||
setTimeout(function() {
|
||||
videojs.players.vid06 && videojs.players.vid06.src({src:'./oceans.mp4', type:'video/mp4'});
|
||||
videojs.players.vid16 && videojs.players.vid16.src({src:'./oceans.mp4', type:'video/mp4'});
|
||||
videojs.players.vid26 && videojs.players.vid26.src({src:'./oceans.mp4', type:'video/mp4'});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+30
-7
@@ -363,6 +363,7 @@ class Player extends Component {
|
||||
// now remove immediately so native controls don't flash.
|
||||
// May be turned back on by HTML5 tech if nativeControlsForTouch is true
|
||||
tag.controls = false;
|
||||
tag.removeAttribute('controls');
|
||||
|
||||
/*
|
||||
* Store the internal state of scrubbing
|
||||
@@ -508,16 +509,34 @@ class Player extends Component {
|
||||
* The DOM element that gets created.
|
||||
*/
|
||||
createEl() {
|
||||
const tag = this.tag;
|
||||
let tag = this.tag;
|
||||
let el;
|
||||
const playerElIngest = this.playerElIngest_ = tag.parentNode && tag.parentNode.hasAttribute && tag.parentNode.hasAttribute('data-vjs-player');
|
||||
let playerElIngest = this.playerElIngest_ = tag.parentNode && tag.parentNode.hasAttribute && tag.parentNode.hasAttribute('data-vjs-player');
|
||||
const divEmbed = this.tag.tagName.toLowerCase() === 'div';
|
||||
|
||||
if (playerElIngest) {
|
||||
el = this.el_ = tag.parentNode;
|
||||
} else {
|
||||
} else if (!divEmbed) {
|
||||
el = this.el_ = super.createEl('div');
|
||||
}
|
||||
|
||||
// Copy over all the attributes from the tag, including ID and class
|
||||
// ID will now reference player box, not the video tag
|
||||
const attrs = Dom.getAttributes(tag);
|
||||
|
||||
if (divEmbed) {
|
||||
el = this.el_ = tag;
|
||||
tag = this.tag = document.createElement('video');
|
||||
while (el.children.length) {
|
||||
tag.appendChild(el.firstChild);
|
||||
el.removeChild(el.firstChild);
|
||||
}
|
||||
|
||||
el.appendChild(tag);
|
||||
|
||||
playerElIngest = this.playerElIngest_ = el;
|
||||
}
|
||||
|
||||
// set tabindex to -1 so we could focus on the player element
|
||||
tag.setAttribute('tabindex', '-1');
|
||||
|
||||
@@ -525,17 +544,21 @@ class Player extends Component {
|
||||
tag.removeAttribute('width');
|
||||
tag.removeAttribute('height');
|
||||
|
||||
// Copy over all the attributes from the tag, including ID and class
|
||||
// ID will now reference player box, not the video tag
|
||||
const attrs = Dom.getAttributes(tag);
|
||||
|
||||
Object.getOwnPropertyNames(attrs).forEach(function(attr) {
|
||||
// workaround so we don't totally break IE7
|
||||
// http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
|
||||
if (attr === 'class') {
|
||||
el.className += ' ' + attrs[attr];
|
||||
|
||||
if (divEmbed) {
|
||||
tag.className += ' ' + attrs[attr];
|
||||
}
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
|
||||
if (divEmbed) {
|
||||
tag.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ const autoSetup = function() {
|
||||
// through each list of elements to build up a new, combined list of elements.
|
||||
const vids = document.getElementsByTagName('video');
|
||||
const audios = document.getElementsByTagName('audio');
|
||||
const divs = document.getElementsByTagName('div');
|
||||
const mediaEls = [];
|
||||
|
||||
if (vids && vids.length > 0) {
|
||||
@@ -45,6 +46,12 @@ const autoSetup = function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (divs && divs.length > 0) {
|
||||
for (let i = 0, e = divs.length; i < e; i++) {
|
||||
mediaEls.push(divs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any media elements exist
|
||||
if (mediaEls && mediaEls.length > 0) {
|
||||
|
||||
|
||||
+136
-1
@@ -17,7 +17,7 @@ QUnit.module('video.js', {
|
||||
QUnit.test('should create a video tag and have access children in old IE', function(assert) {
|
||||
const fixture = document.getElementById('qunit-fixture');
|
||||
|
||||
fixture.innerHTML += '<video id="test_vid_id"><source type="video/mp4"></video>';
|
||||
fixture.innerHTML += '<video id="test_vid_id"><source type="video/mp4"></source></video>';
|
||||
|
||||
const vid = document.getElementById('test_vid_id');
|
||||
|
||||
@@ -331,3 +331,138 @@ QUnit.test('should create a new tag for movingMediaElementInDOM', function(asser
|
||||
Html5.isSupported = oldIS;
|
||||
Html5.nativeSourceHandler.canPlayType = oldCPT;
|
||||
});
|
||||
|
||||
/* **************************************************** *
|
||||
* div embed tests copied from video emebed tests above *
|
||||
* **************************************************** */
|
||||
|
||||
QUnit.module('video.js div embed', {
|
||||
beforeEach() {
|
||||
this.clock = sinon.useFakeTimers();
|
||||
},
|
||||
afterEach() {
|
||||
this.clock.restore();
|
||||
}
|
||||
});
|
||||
QUnit.test('should return a video player instance', function(assert) {
|
||||
const fixture = document.getElementById('qunit-fixture');
|
||||
|
||||
fixture.innerHTML += '<div id="test_vid_id"></div>' +
|
||||
'<div id="test_vid_id2"></div>';
|
||||
|
||||
const player = videojs('test_vid_id', { techOrder: ['techFaker'] });
|
||||
|
||||
assert.ok(player, 'created player from tag');
|
||||
assert.ok(player.id() === 'test_vid_id');
|
||||
assert.ok(videojs.getPlayers().test_vid_id === player,
|
||||
'added player to global reference');
|
||||
|
||||
const playerAgain = videojs('test_vid_id');
|
||||
|
||||
assert.ok(player === playerAgain, 'did not create a second player from same tag');
|
||||
|
||||
assert.equal(player, playerAgain, 'we did not make a new player');
|
||||
|
||||
const tag2 = document.getElementById('test_vid_id2');
|
||||
const player2 = videojs(tag2, { techOrder: ['techFaker'] });
|
||||
|
||||
assert.ok(player2.id() === 'test_vid_id2', 'created player from element');
|
||||
|
||||
player.dispose();
|
||||
player2.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('should log about already initalized players if options already passed',
|
||||
function(assert) {
|
||||
const origWarnLog = log.warn;
|
||||
const fixture = document.getElementById('qunit-fixture');
|
||||
const warnLogs = [];
|
||||
|
||||
log.warn = (args) => {
|
||||
warnLogs.push(args);
|
||||
};
|
||||
|
||||
fixture.innerHTML += '<div id="test_vid_id"></div>';
|
||||
|
||||
const player = videojs('test_vid_id', { techOrder: ['techFaker'] });
|
||||
|
||||
assert.ok(player, 'created player from tag');
|
||||
assert.equal(player.id(), 'test_vid_id', 'player has the right ID');
|
||||
assert.equal(warnLogs.length, 0, 'no warn logs');
|
||||
|
||||
const playerAgain = videojs('test_vid_id');
|
||||
|
||||
assert.equal(player, playerAgain, 'did not create a second player from same tag');
|
||||
assert.equal(warnLogs.length, 0, 'no warn logs');
|
||||
|
||||
const playerAgainWithOptions = videojs('test_vid_id', { techOrder: ['techFaker'] });
|
||||
|
||||
assert.equal(player,
|
||||
playerAgainWithOptions,
|
||||
'did not create a second player from same tag');
|
||||
assert.equal(warnLogs.length, 1, 'logged a warning');
|
||||
assert.equal(warnLogs[0],
|
||||
'Player "test_vid_id" is already initialised. Options will not be applied.',
|
||||
'logged the right message');
|
||||
|
||||
log.warn = origWarnLog;
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('should return a video player instance from el html5 tech', function(assert) {
|
||||
const fixture = document.getElementById('qunit-fixture');
|
||||
|
||||
fixture.innerHTML += '<div id="test_vid_id"></div>' +
|
||||
'<div id="test_vid_id2"></div>';
|
||||
|
||||
const vid = document.querySelector('#test_vid_id');
|
||||
|
||||
const player = videojs(vid);
|
||||
|
||||
assert.ok(player, 'created player from tag');
|
||||
assert.ok(player.id() === 'test_vid_id');
|
||||
assert.ok(videojs.getPlayers().test_vid_id === player,
|
||||
'added player to global reference');
|
||||
|
||||
const playerAgain = videojs(vid);
|
||||
|
||||
assert.ok(player === playerAgain, 'did not create a second player from same tag');
|
||||
assert.equal(player, playerAgain, 'we did not make a new player');
|
||||
|
||||
const tag2 = document.getElementById('test_vid_id2');
|
||||
const player2 = videojs(tag2, { techOrder: ['techFaker'] });
|
||||
|
||||
assert.ok(player2.id() === 'test_vid_id2', 'created player from element');
|
||||
|
||||
player.dispose();
|
||||
player2.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('should return a video player instance from el techfaker', function(assert) {
|
||||
const fixture = document.getElementById('qunit-fixture');
|
||||
|
||||
fixture.innerHTML += '<div id="test_vid_id"></div>' +
|
||||
'<div id="test_vid_id2"></div>';
|
||||
|
||||
const vid = document.querySelector('#test_vid_id');
|
||||
const player = videojs(vid, {techOrder: ['techFaker']});
|
||||
|
||||
assert.ok(player, 'created player from tag');
|
||||
assert.ok(player.id() === 'test_vid_id');
|
||||
assert.ok(videojs.getPlayers().test_vid_id === player,
|
||||
'added player to global reference');
|
||||
|
||||
const playerAgain = videojs(vid);
|
||||
|
||||
assert.ok(player === playerAgain, 'did not create a second player from same tag');
|
||||
assert.equal(player, playerAgain, 'we did not make a new player');
|
||||
|
||||
const tag2 = document.getElementById('test_vid_id2');
|
||||
const player2 = videojs(tag2, { techOrder: ['techFaker'] });
|
||||
|
||||
assert.ok(player2.id() === 'test_vid_id2', 'created player from element');
|
||||
|
||||
player.dispose();
|
||||
player2.dispose();
|
||||
});
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário