mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-16 01:26:16 -08:00
bugfix
This commit is contained in:
1 parent
9fd3e580bb
commit
4ce05442c7
36 files changed
+731
-683
No files matched your search
+10
-1
@@ -1 +1,10 @@
|
||||
.artplayer-video-player{position:relative;width:100%;height:100%;overflow:hidden;outline:0;font-family:Roboto,Arial,Helvetica,sans-serif;color:#eee;text-align:left;direction:ltr;font-size:14px;line-height:1.3;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);touch-action:manipulation;-ms-high-contrast-adjust:none}.artplayer-video-player *{box-sizing:border-box}.artplayer-video-player .art-icon{display:inline-block}.artplayer-video-player .art-icon svg{fill:#fff}.artplayer-video-player .artplayer-video{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;width:100%;height:100%;background-color:#000;outline:0}.artplayer-video-player .artplayer-subtitle{position:absolute;z-index:20;bottom:40px;width:100%;padding:0 20px;text-align:center;color:#fff;text-shadow:.5px .5px .5px rgba(0,0,0,.5);font-size:20px}.artplayer-video-player .artplayer-subtitle p{margin:5px 0}.artplayer-video-player .artplayer-layers{position:absolute;z-index:30;left:0;top:0;right:0;bottom:0;width:100%;height:100%}.artplayer-video-player .artplayer-layers .art-layer{position:absolute}.artplayer-video-player .artplayer-mask{display:none;position:absolute;z-index:40;left:0;top:0;right:0;bottom:0;width:100%;height:100%;cursor:pointer}.artplayer-video-player .artplayer-mask .art-icon-playBig{position:absolute;right:30px;bottom:65px;opacity:.6}.artplayer-video-player .artplayer-loading{display:none;position:absolute;z-index:40;left:0;top:0;right:0;bottom:0;width:100%;height:100%;align-items:center;justify-content:center}.artplayer-video-player .artplayer-bottom{position:absolute;z-index:50;left:0;right:0;bottom:0;height:100px;padding:60px 10px 0;opacity:0;visibility:hidden;transition:all .2s ease-in-out;pointer-events:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==) repeat-x bottom}.artplayer-video-player .artplayer-bottom .artplayer-progress{position:relative;pointer-events:all}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress{position:relative;height:5px;padding:1px 0;cursor:pointer}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner{position:relative;height:100%;background:hsla(0,0%,100%,.2)}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-loaded{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;height:100%;width:0;background:hsla(0,0%,100%,.4)}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-played{position:absolute;z-index:20;left:0;top:0;right:0;bottom:0;height:100%;width:0}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-highlight{position:absolute;z-index:30;left:0;top:0;right:0;bottom:0;height:0}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-highlight span{display:inline-block;position:absolute;left:0;top:0;width:7px;height:3px;background:#fff;border-radius:3px}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-indicator{display:none;position:absolute;z-index:40;top:-5px;left:-6.5px;width:13px;height:13px;border-radius:50%}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-indicator.show-indicator{display:block}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-tip{display:none;position:absolute;z-index:50;top:-25px;left:0;height:20px;padding:0 5px;line-height:20px;color:#fff;font-size:12px;text-align:center;background:rgba(0,0,0,.7);border-radius:3px;font-weight:700}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress:hover .art-progress-indicator,.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress:hover .art-progress-tip{display:block}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-thumbnails{display:none;position:absolute;bottom:8px;left:0;pointer-events:none;background-color:rgba(0,0,0,.7)}.artplayer-video-player .artplayer-bottom .artplayer-controls{position:relative;pointer-events:all;display:flex;align-items:center;justify-content:space-between;height:36px}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control{float:left;font-size:12px;height:36px;line-height:36px;cursor:pointer}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control .art-icon{display:flex;align-items:cLine truncated
|
||||
.artplayer-video-player .artplayer-video{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;width:100%;height:100%;background-color:#000;outline:0}
|
||||
.artplayer-video-player{position:relative;width:100%;height:100%;overflow:hidden;outline:0;font-family:Roboto,Arial,Helvetica,sans-serif;color:#eee;text-align:left;direction:ltr;font-size:14px;line-height:1.3;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);touch-action:manipulation;-ms-high-contrast-adjust:none}.artplayer-video-player *{box-sizing:border-box}.artplayer-video-player .art-icon{display:inline-block}.artplayer-video-player .art-icon svg{fill:#fff}.artplayer-video-player.artplayer-error .art-progress-indicator,.artplayer-video-player.artplayer-error .art-progress-tip{display:none!important}
|
||||
.artplayer-video-player .artplayer-subtitle{position:absolute;z-index:20;bottom:40px;width:100%;padding:0 20px;text-align:center;color:#fff;text-shadow:.5px .5px .5px rgba(0,0,0,.5);font-size:20px}.artplayer-video-player .artplayer-subtitle p{margin:5px 0}
|
||||
.artplayer-video-player .artplayer-layers{position:absolute;z-index:30;left:0;top:0;right:0;bottom:0;width:100%;height:100%}.artplayer-video-player .artplayer-layers .art-layer{position:absolute}
|
||||
.artplayer-video-player .artplayer-mask{display:none;position:absolute;z-index:40;left:0;top:0;right:0;bottom:0;width:100%;height:100%;cursor:pointer}.artplayer-video-player .artplayer-mask .art-icon-playBig{position:absolute;right:30px;bottom:65px;opacity:.6}
|
||||
.artplayer-video-player .artplayer-loading{display:none;position:absolute;z-index:40;left:0;top:0;right:0;bottom:0;width:100%;height:100%;align-items:center;justify-content:center}
|
||||
.artplayer-video-player .artplayer-notice{display:none;font-size:14px;position:absolute;z-index:60;left:10px;top:10px;height:30px;line-height:30px;padding:0 10px;border-radius:3px;color:#fff;background:rgba(0,0,0,.6)}
|
||||
.artplayer-video-player .artplayer-bottom{position:absolute;z-index:50;left:0;right:0;bottom:0;height:100px;padding:60px 10px 0;opacity:0;visibility:hidden;transition:all .2s ease-in-out;pointer-events:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==) repeat-x bottom}.artplayer-video-player .artplayer-bottom .artplayer-progress{position:relative;pointer-events:all}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress{position:relative;height:5px;padding:1px 0;cursor:pointer}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner{position:relative;height:100%;background:hsla(0,0%,100%,.2)}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-loaded{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;height:100%;width:0;background:hsla(0,0%,100%,.4)}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-played{position:absolute;z-index:20;left:0;top:0;right:0;bottom:0;height:100%;width:0}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-highlight{position:absolute;z-index:30;left:0;top:0;right:0;bottom:0;height:0}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-highlight span{display:inline-block;position:absolute;left:0;top:0;width:7px;height:3px;background:#fff;border-radius:3px}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-indicator{display:none;position:absolute;z-index:40;top:-5px;left:-6.5px;width:13px;height:13px;border-radius:50%}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-indicator.show-indicator{display:block}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress .art-control-progress-inner .art-progress-tip{display:none;position:absolute;z-index:50;top:-25px;left:0;height:20px;padding:0 5px;line-height:20px;color:#fff;font-size:12px;text-align:center;background:rgba(0,0,0,.7);border-radius:3px;font-weight:700}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress:hover .art-progress-indicator,.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-progress:hover .art-progress-tip{display:block}.artplayer-video-player .artplayer-bottom .artplayer-progress .art-control-thumbnails{display:none;position:absolute;bottom:8px;left:0;pointer-events:none;background-color:rgba(0,0,0,.7)}.artplayer-video-player .artplayer-bottom .artplayer-controls{position:relative;pointer-events:all;display:flex;align-items:center;justify-content:space-between;height:36px}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control{float:left;font-size:12px;height:36px;line-height:36px;cursor:pointer}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control .art-icon{display:flex;align-items:center;justify-content:center;float:left;height:36px;width:36px;padding:7px}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel{position:relative;float:left;width:0;height:100%;transition:margin .2s cubic-bezier(.4,0,1,1),width .2s cubic-bezier(.4,0,1,1);overflow:hidden}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel .art-volume-slider-handle{position:absolute;top:50%;left:0;width:12px;height:12px;border-radius:12px;margin-top:-6px;background:#fff}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:before{left:-54px;background:#fff}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:after{left:6px;background:hsla(0,0%,100%,.2)}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:after,.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel .art-volume-slider-handle:before{content:"";position:absolute;display:block;top:50%;height:3px;margin-top:-2px;width:60px}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-volume .art-volume-panel.art-volume-panel-hover{width:60px}.artplayer-video-player .artplayer-bottom .artplayer-controls .art-control-time{padding:0 10px}.artplayer-video-player.controls-show .artplayer-bottom,.artplayer-video-player:hover .artplayer-bottom{opacity:1;visibilityLine truncated
|
||||
.artplayer-video-player .artplayer-contextmenu{position:absolute;z-index:70;left:0;top:0;width:200px;padding:5px 0;background:rgba(0,0,0,.8)}.artplayer-video-player .artplayer-contextmenu .art-menu{cursor:pointer;font-size:13px;display:block;color:#fff;padding:7px 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 0 2px rgba(0,0,0,.5)}.artplayer-video-player .artplayer-contextmenu .art-menu a{color:#fff;text-decoration:none}.artplayer-video-player .artplayer-contextmenu .art-menu:hover{background-color:hsla(0,0%,100%,.1)}
|
||||
.artplayer-video-player .artplayer-info{display:none;position:absolute;left:10px;top:10px;z-index:80;width:350px;min-height:150px;padding:10px;color:#fff;font-size:12px;font-family:Noto Sans CJK SC DemiLight,Roboto,Segoe UI,Tahoma,Arial,Helvetica,sans-serif;-webkit-font-smoothing:antialiased;background:rgba(0,0,0,.7)}.artplayer-video-player .artplayer-info .art-info-item{display:flex;margin-bottom:5px}.artplayer-video-player .artplayer-info .art-info-item .art-info-title{width:100px;text-align:right}.artplayer-video-player .artplayer-info .art-info-item .art-info-content{flex:1;padding-left:5px}.artplayer-video-player .artplayer-info .artplayer-info-close{position:absolute;top:5px;right:5px;cursor:pointer}
|
||||
File renamed without changes.
+26
-21
@@ -26,7 +26,6 @@
|
||||
<script src="./js/artplayer.js"></script>
|
||||
<script>
|
||||
var player = new Artplayer({
|
||||
loop: true,
|
||||
container: '.artplayer-app',
|
||||
url: './video/one-more-time-one-more-chance.mp4',
|
||||
poster: './img/one-more-time-one-more-chance.jpg',
|
||||
@@ -38,6 +37,7 @@
|
||||
width: 190,
|
||||
height: 107
|
||||
},
|
||||
contextmenu: [],
|
||||
highlight: [
|
||||
{
|
||||
time: 60,
|
||||
@@ -65,7 +65,7 @@
|
||||
player.layers.add({
|
||||
index: 1,
|
||||
name: 'your-name',
|
||||
html: '<img style="width: 100px" src="./img/yourName.png">',
|
||||
html: '<img style="width: 100px" src="./img/your-name.png">',
|
||||
style: {
|
||||
'top': '20px',
|
||||
'right': '20px',
|
||||
@@ -73,7 +73,12 @@
|
||||
}
|
||||
}, dom => {
|
||||
dom.addEventListener('click', () => {
|
||||
dom.remove();
|
||||
player.destroy(true);
|
||||
new Artplayer({
|
||||
autoplay: true,
|
||||
container: '.artplayer-app',
|
||||
url: './video/you-name.mp4',
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,26 +92,26 @@
|
||||
});
|
||||
});
|
||||
|
||||
Artplayer.config.mse.mediaSource.events.forEach(item => {
|
||||
player.on('mediaSource:' + item, event => {
|
||||
console.log('mediaSource', event);
|
||||
});
|
||||
});
|
||||
// Artplayer.config.mse.mediaSource.events.forEach(item => {
|
||||
// player.on('mediaSource:' + item, event => {
|
||||
// console.log('mediaSource', event);
|
||||
// });
|
||||
// });
|
||||
|
||||
Artplayer.config.mse.sourceBufferList.events.forEach(item => {
|
||||
player.on('sourceBuffers:' + item, event => {
|
||||
console.log('sourceBuffers', event);
|
||||
});
|
||||
player.on('activeSourceBuffers:' + item, event => {
|
||||
console.log('activeSourceBuffers', event);
|
||||
});
|
||||
});
|
||||
// Artplayer.config.mse.sourceBufferList.events.forEach(item => {
|
||||
// player.on('sourceBuffers:' + item, event => {
|
||||
// console.log('sourceBuffers', event);
|
||||
// });
|
||||
// player.on('activeSourceBuffers:' + item, event => {
|
||||
// console.log('activeSourceBuffers', event);
|
||||
// });
|
||||
// });
|
||||
|
||||
Artplayer.config.mse.sourceBuffer.events.forEach(item => {
|
||||
player.on('sourceBuffer:' + item, event => {
|
||||
console.log('sourceBuffer', event);
|
||||
});
|
||||
});
|
||||
// Artplayer.config.mse.sourceBuffer.events.forEach(item => {
|
||||
// player.on('sourceBuffer:' + item, event => {
|
||||
// console.log('sourceBuffer', event);
|
||||
// });
|
||||
// });
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
+291
-216
@@ -422,29 +422,25 @@
|
||||
var storage = Object.assign({}, getStorage(), defineProperty({}, key, value));
|
||||
localStorage.setItem('artplayer_settings', JSON.stringify(storage));
|
||||
}
|
||||
function getType(val) {
|
||||
var toString = Object.prototype.toString;
|
||||
var type = toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, '');
|
||||
return type;
|
||||
}
|
||||
|
||||
function validOption(option) {
|
||||
errorHandle(option.container, '\'container\' option is required.');
|
||||
errorHandle(option.url, '\'url\' option is required.');
|
||||
errorHandle(typeof option.container === 'string' || option.container instanceof Element, "'container' option require 'string' or 'Element' type, but got '".concat(_typeof_1(option.container), "'."));
|
||||
errorHandle(typeof option.url === 'string', "'url' option require 'string' type, but got '".concat(_typeof_1(option.url), "'."));
|
||||
errorHandle(typeof option.poster === 'string', "'poster' option require 'string' type, but got '".concat(_typeof_1(option.poster), "'."));
|
||||
errorHandle(Object.prototype.toString.call(option.thumbnails) === '[object Object]', "'thumbnails' option require 'object' type, but got '".concat(_typeof_1(option.thumbnails), "'."));
|
||||
errorHandle(typeof option.volume === 'number', "'volume' option require 'number' type, but got '".concat(_typeof_1(option.volume), "'."));
|
||||
errorHandle(typeof option.autoplay === 'boolean', "'autoplay' option require 'boolean' type, but got '".concat(_typeof_1(option.autoplay), "'."));
|
||||
errorHandle(typeof option.loop === 'boolean', "'loop' option require 'boolean' type, but got '".concat(_typeof_1(option.loop), "'."));
|
||||
errorHandle(['none', 'metadata', 'auto'].indexOf(option.preload) > -1, "'preload' option require one of 'none\u3001metadata\u3001auto', but got '".concat(option.preload, "."));
|
||||
errorHandle(typeof option.lang === 'string', "'lang' option require 'string' type, but got '".concat(_typeof_1(option.lang), "'."));
|
||||
errorHandle(typeof option.type === 'string', "'type' option require 'string' type, but got '".concat(_typeof_1(option.type), "'."));
|
||||
errorHandle(typeof option.mimeCodec === 'string', "'mimeCodec' option require 'string' type, but got '".concat(_typeof_1(option.mimeCodec), "'."));
|
||||
errorHandle(Array.isArray(option.layers), "'layers' option require 'array' type, but got '".concat(_typeof_1(option.layers), "'."));
|
||||
errorHandle(Array.isArray(option.contextmenu), "'contextmenu' option require 'array' type, but got '".concat(_typeof_1(option.contextmenu), "'."));
|
||||
errorHandle(typeof option.loading === 'string' || option.loading instanceof Element, "'loading' option require 'string' type, but got '".concat(_typeof_1(option.loading), "'."));
|
||||
errorHandle(typeof option.theme === 'string', "'theme' option require 'string' type, but got '".concat(_typeof_1(option.theme), "'."));
|
||||
errorHandle(typeof option.hotkey === 'boolean', "'hotkey' option require 'boolean' type, but got '".concat(_typeof_1(option.hotkey), "'."));
|
||||
errorHandle(Object.prototype.toString.call(option.subtitle) === '[object Object]', "'subtitle' option require 'object' type, but got '".concat(_typeof_1(option.subtitle), "'."));
|
||||
errorHandle(Array.isArray(option.controls), "'controls' option require 'array' type, but got '".concat(_typeof_1(option.controls), "'."));
|
||||
errorHandle(Array.isArray(option.highlight), "'highlight' option require 'array' type, but got '".concat(_typeof_1(option.highlight), "'."));
|
||||
function validOption(DEFAULTS, option) {
|
||||
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['option'];
|
||||
Object.keys(DEFAULTS).forEach(function (key) {
|
||||
var defaultValue = DEFAULTS[key];
|
||||
var value = option[key];
|
||||
var defaultType = getType(defaultValue);
|
||||
var type = getType(value);
|
||||
errorHandle(defaultType === type, "'".concat(path.join('.'), ".").concat(key, "' require '").concat(defaultType, "' type, but got '").concat(type, "'"));
|
||||
|
||||
if (type === 'object') {
|
||||
validOption(defaultValue, value, path.concat(key));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var mimeCodec = {
|
||||
@@ -562,7 +558,7 @@
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var refs = this.art.refs;
|
||||
refs.$container.innerHTML = "\n <div class=\"artplayer-video-player\">\n <video class=\"artplayer-video\" webkit-playsinline playsinline></video>\n <div class=\"artplayer-subtitle\"></div>\n <div class=\"artplayer-layers\"></div>\n <div class=\"artplayer-mask\"></div>\n <div class=\"artplayer-bottom\">\n <div class=\"artplayer-progress\"></div>\n <div class=\"artplayer-controls\">\n <div class=\"artplayer-controls-left\"></div>\n <div class=\"artplayer-controls-right\"></div>\n </div>\n </div>\n <div class=\"artplayer-loading\"></div>\n <div class=\"artplayer-notice\"></div>\n <div class=\"artplayer-info\">\n <div class=\"artplayer-info-panel\"></div>\n <div class=\"artplayer-info-close\">[x]</div>\n </div>\n </div>\n ";
|
||||
refs.$container.innerHTML = "\n <div class=\"artplayer-video-player\">\n <video class=\"artplayer-video\"></video>\n <div class=\"artplayer-subtitle\"></div>\n <div class=\"artplayer-layers\"></div>\n <div class=\"artplayer-mask\"></div>\n <div class=\"artplayer-bottom\">\n <div class=\"artplayer-progress\"></div>\n <div class=\"artplayer-controls\">\n <div class=\"artplayer-controls-left\"></div>\n <div class=\"artplayer-controls-right\"></div>\n </div>\n </div>\n <div class=\"artplayer-loading\"></div>\n <div class=\"artplayer-notice\"></div>\n <div class=\"artplayer-info\">\n <div class=\"artplayer-info-panel\"></div>\n <div class=\"artplayer-info-close\">[x]</div>\n </div>\n </div>\n ";
|
||||
refs.$player = refs.$container.querySelector('.artplayer-video-player');
|
||||
refs.$video = refs.$container.querySelector('.artplayer-video');
|
||||
refs.$subtitle = refs.$container.querySelector('.artplayer-subtitle');
|
||||
@@ -654,13 +650,16 @@
|
||||
createClass(Player, [{
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var option = this.art.option;
|
||||
var $video = this.art.refs.$video;
|
||||
$video.controls = false;
|
||||
$video.poster = option.poster;
|
||||
var _this$art = this.art,
|
||||
option = _this$art.option,
|
||||
$video = _this$art.refs.$video;
|
||||
Object.keys(option.moreVideoAttr).forEach(function (key) {
|
||||
var value = option.moreVideoAttr[key];
|
||||
$video[key] = value;
|
||||
});
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
$video.poster = option.poster;
|
||||
$video.autoplay = option.autoplay;
|
||||
$video.preload = option.preload;
|
||||
$video.src = option.url;
|
||||
}
|
||||
}, {
|
||||
@@ -668,13 +667,13 @@
|
||||
value: function eventBind() {
|
||||
var _this = this;
|
||||
|
||||
var _this$art = this.art,
|
||||
proxy = _this$art.events.proxy,
|
||||
_this$art$refs = _this$art.refs,
|
||||
$player = _this$art$refs.$player,
|
||||
$video = _this$art$refs.$video,
|
||||
i18n = _this$art.i18n,
|
||||
notice = _this$art.notice;
|
||||
var _this$art2 = this.art,
|
||||
proxy = _this$art2.events.proxy,
|
||||
_this$art2$refs = _this$art2.refs,
|
||||
$player = _this$art2$refs.$player,
|
||||
$video = _this$art2$refs.$video,
|
||||
i18n = _this$art2.i18n,
|
||||
notice = _this$art2.notice;
|
||||
config.video.events.forEach(function (eventName) {
|
||||
proxy($video, eventName, function (event) {
|
||||
_this.art.emit("video:".concat(event.type), event);
|
||||
@@ -753,10 +752,10 @@
|
||||
}, {
|
||||
key: "play",
|
||||
value: function play() {
|
||||
var _this$art2 = this.art,
|
||||
$video = _this$art2.refs.$video,
|
||||
i18n = _this$art2.i18n,
|
||||
notice = _this$art2.notice;
|
||||
var _this$art3 = this.art,
|
||||
$video = _this$art3.refs.$video,
|
||||
i18n = _this$art3.i18n,
|
||||
notice = _this$art3.notice;
|
||||
var promise = $video.play();
|
||||
notice.show(i18n.get('Start'));
|
||||
this.art.emit('play', $video);
|
||||
@@ -765,10 +764,10 @@
|
||||
}, {
|
||||
key: "pause",
|
||||
value: function pause() {
|
||||
var _this$art3 = this.art,
|
||||
$video = _this$art3.refs.$video,
|
||||
i18n = _this$art3.i18n,
|
||||
notice = _this$art3.notice;
|
||||
var _this$art4 = this.art,
|
||||
$video = _this$art4.refs.$video,
|
||||
i18n = _this$art4.i18n,
|
||||
notice = _this$art4.notice;
|
||||
$video.pause();
|
||||
notice.show(i18n.get('Pause'));
|
||||
this.art.emit('pause', $video);
|
||||
@@ -785,9 +784,9 @@
|
||||
}, {
|
||||
key: "seek",
|
||||
value: function seek(time) {
|
||||
var _this$art4 = this.art,
|
||||
$video = _this$art4.refs.$video,
|
||||
notice = _this$art4.notice;
|
||||
var _this$art5 = this.art,
|
||||
$video = _this$art5.refs.$video,
|
||||
notice = _this$art5.notice;
|
||||
var newTime = Math.max(time, 0);
|
||||
|
||||
if ($video.duration) {
|
||||
@@ -801,10 +800,10 @@
|
||||
}, {
|
||||
key: "volume",
|
||||
value: function volume(percentage) {
|
||||
var _this$art5 = this.art,
|
||||
$video = _this$art5.refs.$video,
|
||||
i18n = _this$art5.i18n,
|
||||
notice = _this$art5.notice;
|
||||
var _this$art6 = this.art,
|
||||
$video = _this$art6.refs.$video,
|
||||
i18n = _this$art6.i18n,
|
||||
notice = _this$art6.notice;
|
||||
|
||||
if (percentage !== undefined) {
|
||||
$video.volume = clamp(percentage, 0, 1);
|
||||
@@ -827,10 +826,10 @@
|
||||
}, {
|
||||
key: "playbackRate",
|
||||
value: function playbackRate(rate) {
|
||||
var _this$art6 = this.art,
|
||||
$video = _this$art6.refs.$video,
|
||||
i18n = _this$art6.i18n,
|
||||
notice = _this$art6.notice;
|
||||
var _this$art7 = this.art,
|
||||
$video = _this$art7.refs.$video,
|
||||
i18n = _this$art7.i18n,
|
||||
notice = _this$art7.notice;
|
||||
var newRate = clamp(rate, 0.1, 10);
|
||||
$video.playbackRate = newRate;
|
||||
notice.show("".concat(i18n.get('Rate'), ": ").concat(newRate, "x"));
|
||||
@@ -841,33 +840,62 @@
|
||||
return Player;
|
||||
}();
|
||||
|
||||
function validControl(option) {
|
||||
errorHandle(typeof option.control === 'function', "'control' option require 'function' type, but got '".concat(_typeof_1(option.control), "'."));
|
||||
errorHandle(typeof option.disable === 'boolean', "'disable' option require 'boolean' type, but got '".concat(_typeof_1(option.disable), "'."));
|
||||
errorHandle(['top', 'left', 'right'].indexOf(option.position) > -1, "'position' option require one of 'top\u3001left\u3001right', but got '".concat(option.position, "'."));
|
||||
errorHandle(typeof option.index === 'number', "'index' option require 'number' type, but got '".concat(_typeof_1(option.index), "'."));
|
||||
}
|
||||
var Danmu =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Danmu(option) {
|
||||
classCallCheck(this, Danmu);
|
||||
|
||||
var Danmu = function Danmu(art, option) {
|
||||
classCallCheck(this, Danmu);
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
};
|
||||
createClass(Danmu, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}]);
|
||||
|
||||
var Fullscreen = function Fullscreen(art, option) {
|
||||
classCallCheck(this, Fullscreen);
|
||||
return Danmu;
|
||||
}();
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
};
|
||||
var Fullscreen =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Fullscreen(option) {
|
||||
classCallCheck(this, Fullscreen);
|
||||
|
||||
var Pip = function Pip(art, option) {
|
||||
classCallCheck(this, Pip);
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
};
|
||||
createClass(Fullscreen, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Fullscreen;
|
||||
}();
|
||||
|
||||
var Pip =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Pip(option) {
|
||||
classCallCheck(this, Pip);
|
||||
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
createClass(Pip, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Pip;
|
||||
}();
|
||||
|
||||
var loading = "<svg class=\"lds-spinner\" width=\"80px\" height=\"80px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"xMidYMid\" style=\"background: none;\"><g transform=\"rotate(0 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.9166666666666666s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(30 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.8333333333333334s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(60 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.75s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(90 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.6666666666666666s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(120 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.5833333333333334s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(150 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.5s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(180 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.4166666666666667s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(210 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.3333333333333333s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(240 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.25s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(270 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.16666666666666666s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(300 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"-0.08333333333333333s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g><g transform=\"rotate(330 50 50)\">\n <rect x=\"47\" y=\"24\" rx=\"9.4\" ry=\"4.8\" width=\"6\" height=\"12\" fill=\"#ffffff\">\n <animate attributeName=\"opacity\" values=\"1;0\" keyTimes=\"0;1\" dur=\"1s\" begin=\"0s\" repeatCount=\"indefinite\"></animate>\n </rect>\n</g></svg>\n";
|
||||
|
||||
@@ -908,15 +936,19 @@
|
||||
var PlayAndPause =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function PlayAndPause(art, option) {
|
||||
function PlayAndPause(option) {
|
||||
classCallCheck(this, PlayAndPause);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
this.init();
|
||||
}
|
||||
|
||||
createClass(PlayAndPause, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
}, {
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this = this;
|
||||
@@ -924,8 +956,8 @@
|
||||
var _this$art = this.art,
|
||||
proxy = _this$art.events.proxy,
|
||||
player = _this$art.player;
|
||||
this.$play = append(this.option.ref, icons$1.play);
|
||||
this.$pause = append(this.option.ref, icons$1.pause);
|
||||
this.$play = append(this.option.$control, icons$1.play);
|
||||
this.$pause = append(this.option.$control, icons$1.pause);
|
||||
this.$pause.style.display = 'none';
|
||||
proxy(this.$play, 'click', function () {
|
||||
player.play();
|
||||
@@ -950,19 +982,23 @@
|
||||
var Progress =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Progress(art, option) {
|
||||
function Progress(option) {
|
||||
classCallCheck(this, Progress);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
this.isDroging = false;
|
||||
this.getLoaded = this.getLoaded.bind(this);
|
||||
this.getPlayed = this.getPlayed.bind(this);
|
||||
this.set = this.set.bind(this);
|
||||
this.init();
|
||||
}
|
||||
|
||||
createClass(Progress, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
this.isDroging = false;
|
||||
this.getLoaded = this.getLoaded.bind(this);
|
||||
this.getPlayed = this.getPlayed.bind(this);
|
||||
this.set = this.set.bind(this);
|
||||
this.init();
|
||||
}
|
||||
}, {
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this = this;
|
||||
@@ -974,16 +1010,18 @@
|
||||
proxy = _this$art.events.proxy,
|
||||
$video = _this$art.refs.$video,
|
||||
player = _this$art.player;
|
||||
append(this.option.ref, "\n <div class=\"art-control-progress-inner\">\n <div class=\"art-progress-loaded\"></div>\n <div class=\"art-progress-played\" style=\"background: ".concat(theme, "\"></div>\n <div class=\"art-progress-highlight\"></div>\n <div class=\"art-progress-indicator\" style=\"background: ").concat(theme, "\"></div>\n <div class=\"art-progress-tip art-tip\"></div>\n </div>\n "));
|
||||
this.$loaded = this.option.ref.querySelector('.art-progress-loaded');
|
||||
this.$played = this.option.ref.querySelector('.art-progress-played');
|
||||
this.$highlight = this.option.ref.querySelector('.art-progress-highlight');
|
||||
this.$indicator = this.option.ref.querySelector('.art-progress-indicator');
|
||||
this.$tip = this.option.ref.querySelector('.art-progress-tip');
|
||||
append(this.option.$control, "\n <div class=\"art-control-progress-inner\">\n <div class=\"art-progress-loaded\"></div>\n <div class=\"art-progress-played\" style=\"background: ".concat(theme, "\"></div>\n <div class=\"art-progress-highlight\"></div>\n <div class=\"art-progress-indicator\" style=\"background: ").concat(theme, "\"></div>\n <div class=\"art-progress-tip art-tip\"></div>\n </div>\n "));
|
||||
this.$loaded = this.option.$control.querySelector('.art-progress-loaded');
|
||||
this.$played = this.option.$control.querySelector('.art-progress-played');
|
||||
this.$highlight = this.option.$control.querySelector('.art-progress-highlight');
|
||||
this.$indicator = this.option.$control.querySelector('.art-progress-indicator');
|
||||
this.$tip = this.option.$control.querySelector('.art-progress-tip');
|
||||
this.art.on('video:canplay', function () {
|
||||
_this.set('loaded', _this.getLoaded());
|
||||
|
||||
highlight.forEach(function (item) {
|
||||
highlight.filter(function (item) {
|
||||
return !item.disable;
|
||||
}).forEach(function (item) {
|
||||
var left = Number(item.time) / $video.duration;
|
||||
append(_this.$highlight, "\n <span data-text=\"".concat(item.text, "\" data-time=\"").concat(item.time, "\" style=\"left: ").concat(left * 100, "%\"></span>\n "));
|
||||
});
|
||||
@@ -997,7 +1035,7 @@
|
||||
this.art.on('video:ended', function () {
|
||||
_this.set('played', 1);
|
||||
});
|
||||
proxy(this.option.ref, 'mousemove', function (event) {
|
||||
proxy(this.option.$control, 'mousemove', function (event) {
|
||||
_this.$tip.style.display = 'block';
|
||||
|
||||
if (event.path.indexOf(_this.$highlight) > -1) {
|
||||
@@ -1006,10 +1044,10 @@
|
||||
_this.showTime(event);
|
||||
}
|
||||
});
|
||||
proxy(this.option.ref, 'mouseout', function () {
|
||||
proxy(this.option.$control, 'mouseout', function () {
|
||||
_this.$tip.style.display = 'none';
|
||||
});
|
||||
proxy(this.option.ref, 'click', function (event) {
|
||||
proxy(this.option.$control, 'click', function (event) {
|
||||
if (event.target !== _this.$indicator) {
|
||||
var _this$getPosFromEvent = _this.getPosFromEvent(event),
|
||||
second = _this$getPosFromEvent.second,
|
||||
@@ -1052,7 +1090,7 @@
|
||||
text = _event$target$dataset.text,
|
||||
time = _event$target$dataset.time;
|
||||
this.$tip.innerHTML = text;
|
||||
var left = Number(time) / $video.duration * this.option.ref.clientWidth + event.target.clientWidth / 2 - this.$tip.clientWidth / 2;
|
||||
var left = Number(time) / $video.duration * this.option.$control.clientWidth + event.target.clientWidth / 2 - this.$tip.clientWidth / 2;
|
||||
this.$tip.style.left = "".concat(left, "px");
|
||||
}
|
||||
}, {
|
||||
@@ -1067,8 +1105,8 @@
|
||||
|
||||
if (width <= tipWidth / 2) {
|
||||
this.$tip.style.left = 0;
|
||||
} else if (width > this.option.ref.clientWidth - tipWidth / 2) {
|
||||
this.$tip.style.left = "".concat(this.option.ref.clientWidth - tipWidth, "px");
|
||||
} else if (width > this.option.$control.clientWidth - tipWidth / 2) {
|
||||
this.$tip.style.left = "".concat(this.option.$control.clientWidth - tipWidth, "px");
|
||||
} else {
|
||||
this.$tip.style.left = "".concat(width - tipWidth / 2, "px");
|
||||
}
|
||||
@@ -1099,38 +1137,54 @@
|
||||
return Progress;
|
||||
}();
|
||||
|
||||
var Subtitle = function Subtitle(art, option) {
|
||||
classCallCheck(this, Subtitle);
|
||||
var Subtitle =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Subtitle(option) {
|
||||
classCallCheck(this, Subtitle);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
};
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
createClass(Subtitle, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Subtitle;
|
||||
}();
|
||||
|
||||
var Time =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Time(art, option) {
|
||||
function Time(option) {
|
||||
classCallCheck(this, Time);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
this.init();
|
||||
}
|
||||
|
||||
createClass(Time, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
}, {
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this = this;
|
||||
|
||||
this.option.ref.innerHTML = '00:00 / 00:00';
|
||||
this.option.$control.innerHTML = '00:00 / 00:00';
|
||||
this.art.on('video:canplay', function () {
|
||||
_this.option.ref.innerHTML = _this.getTime();
|
||||
_this.option.$control.innerHTML = _this.getTime();
|
||||
});
|
||||
this.art.on('video:timeupdate', function () {
|
||||
_this.option.ref.innerHTML = _this.getTime();
|
||||
_this.option.$control.innerHTML = _this.getTime();
|
||||
});
|
||||
this.art.on('video:seeking', function () {
|
||||
_this.option.ref.innerHTML = _this.getTime();
|
||||
_this.option.$control.innerHTML = _this.getTime();
|
||||
});
|
||||
}
|
||||
}, {
|
||||
@@ -1147,16 +1201,20 @@
|
||||
var Volume =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Volume(art, option) {
|
||||
function Volume(option) {
|
||||
classCallCheck(this, Volume);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
this.isDroging = false;
|
||||
this.init();
|
||||
}
|
||||
|
||||
createClass(Volume, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
this.isDroging = false;
|
||||
this.init();
|
||||
}
|
||||
}, {
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this = this;
|
||||
@@ -1164,9 +1222,9 @@
|
||||
var _this$art = this.art,
|
||||
proxy = _this$art.events.proxy,
|
||||
player = _this$art.player;
|
||||
this.$volume = append(this.option.ref, icons$1.volume);
|
||||
this.$volumeClose = append(this.option.ref, icons$1.volumeClose);
|
||||
this.$volumePanel = append(this.option.ref, '<div class="art-volume-panel"></div>');
|
||||
this.$volume = append(this.option.$control, icons$1.volume);
|
||||
this.$volumeClose = append(this.option.$control, icons$1.volumeClose);
|
||||
this.$volumePanel = append(this.option.$control, '<div class="art-volume-panel"></div>');
|
||||
this.$volumeHandle = append(this.$volumePanel, '<div class="art-volume-slider-handle"></div>');
|
||||
this.$volumeClose.style.display = 'none';
|
||||
var volume = getStorage('volume');
|
||||
@@ -1181,8 +1239,9 @@
|
||||
proxy(this.$volumeClose, 'click', function () {
|
||||
_this.$volume.style.display = 'block';
|
||||
_this.$volumeClose.style.display = 'none';
|
||||
player.volume(getStorage('volume'));
|
||||
});
|
||||
proxy(this.option.ref, 'mouseenter', function () {
|
||||
proxy(this.option.$control, 'mouseenter', function () {
|
||||
_this.$volumePanel.classList.add('art-volume-panel-hover'); // TODO
|
||||
|
||||
|
||||
@@ -1190,7 +1249,7 @@
|
||||
_this.setVolumeHandle(player.volume());
|
||||
}, 200);
|
||||
});
|
||||
proxy(this.option.ref, 'mouseleave', function () {
|
||||
proxy(this.option.$control, 'mouseleave', function () {
|
||||
_this.$volumePanel.classList.remove('art-volume-panel-hover');
|
||||
});
|
||||
proxy(this.$volumePanel, 'click', function (event) {
|
||||
@@ -1258,25 +1317,41 @@
|
||||
return Volume;
|
||||
}();
|
||||
|
||||
var Setting = function Setting(art, option) {
|
||||
classCallCheck(this, Setting);
|
||||
var Setting =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Setting(option) {
|
||||
classCallCheck(this, Setting);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
};
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
createClass(Setting, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Setting;
|
||||
}();
|
||||
|
||||
var Thumbnails =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Thumbnails(art, option) {
|
||||
function Thumbnails(option) {
|
||||
classCallCheck(this, Thumbnails);
|
||||
|
||||
this.art = art;
|
||||
this.option = option;
|
||||
this.init();
|
||||
}
|
||||
|
||||
createClass(Thumbnails, [{
|
||||
key: "apply",
|
||||
value: function apply(art) {
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
}, {
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this = this;
|
||||
@@ -1285,12 +1360,12 @@
|
||||
$progress = _this$art.refs.$progress,
|
||||
proxy = _this$art.events.proxy;
|
||||
proxy($progress, 'mousemove', function (event) {
|
||||
_this.option.ref.style.display = 'block';
|
||||
_this.option.$control.style.display = 'block';
|
||||
|
||||
_this.showThumbnails(event);
|
||||
});
|
||||
proxy($progress, 'mouseout', function () {
|
||||
_this.option.ref.style.display = 'none';
|
||||
_this.option.$control.style.display = 'none';
|
||||
});
|
||||
}
|
||||
}, {
|
||||
@@ -1311,17 +1386,17 @@
|
||||
var perIndex = Math.ceil(posWidth / perWidth);
|
||||
var yIndex = Math.ceil(perIndex / column);
|
||||
var xIndex = perIndex % column || column;
|
||||
this.option.ref.style.backgroundImage = "url(".concat(url, ")");
|
||||
this.option.ref.style.height = "".concat(height, "px");
|
||||
this.option.ref.style.width = "".concat(width, "px");
|
||||
this.option.ref.style.backgroundPosition = "-".concat(--xIndex * width, "px -").concat(--yIndex * height, "px");
|
||||
this.option.$control.style.backgroundImage = "url(".concat(url, ")");
|
||||
this.option.$control.style.height = "".concat(height, "px");
|
||||
this.option.$control.style.width = "".concat(width, "px");
|
||||
this.option.$control.style.backgroundPosition = "-".concat(--xIndex * width, "px -").concat(--yIndex * height, "px");
|
||||
|
||||
if (posWidth <= width / 2) {
|
||||
this.option.ref.style.left = 0;
|
||||
this.option.$control.style.left = 0;
|
||||
} else if (posWidth > $progress.clientWidth - width / 2) {
|
||||
this.option.ref.style.left = "".concat($progress.clientWidth - width, "px");
|
||||
this.option.$control.style.left = "".concat($progress.clientWidth - width, "px");
|
||||
} else {
|
||||
this.option.ref.style.left = "".concat(posWidth - width / 2, "px");
|
||||
this.option.$control.style.left = "".concat(posWidth - width / 2, "px");
|
||||
}
|
||||
}
|
||||
}]);
|
||||
@@ -1352,92 +1427,78 @@
|
||||
value: function init() {
|
||||
var _this = this;
|
||||
|
||||
this.add({
|
||||
control: Progress,
|
||||
this.add(new Progress({
|
||||
disable: false,
|
||||
position: 'top',
|
||||
index: 10
|
||||
});
|
||||
this.add({
|
||||
control: Thumbnails,
|
||||
}));
|
||||
this.add(new Thumbnails({
|
||||
disable: !this.art.option.thumbnails.url,
|
||||
position: 'top',
|
||||
index: 20
|
||||
});
|
||||
this.add({
|
||||
control: PlayAndPause,
|
||||
}));
|
||||
this.add(new PlayAndPause({
|
||||
disable: false,
|
||||
position: 'left',
|
||||
index: 10
|
||||
});
|
||||
this.add({
|
||||
control: Volume,
|
||||
}));
|
||||
this.add(new Volume({
|
||||
disable: false,
|
||||
tooltip: 'Volume',
|
||||
position: 'left',
|
||||
index: 20
|
||||
});
|
||||
this.add({
|
||||
control: Time,
|
||||
}));
|
||||
this.add(new Time({
|
||||
disable: false,
|
||||
tooltip: 'Volume',
|
||||
position: 'left',
|
||||
index: 30
|
||||
});
|
||||
this.add({
|
||||
control: Danmu,
|
||||
}));
|
||||
this.add(new Danmu({
|
||||
disable: false,
|
||||
tooltip: 'Danmu',
|
||||
position: 'right',
|
||||
index: 10
|
||||
});
|
||||
this.add({
|
||||
control: Subtitle,
|
||||
}));
|
||||
this.add(new Subtitle({
|
||||
disable: false,
|
||||
tooltip: 'Subtitle',
|
||||
position: 'right',
|
||||
index: 20
|
||||
});
|
||||
this.add({
|
||||
control: Setting,
|
||||
}));
|
||||
this.add(new Setting({
|
||||
disable: false,
|
||||
tooltip: 'Setting',
|
||||
position: 'right',
|
||||
index: 30
|
||||
});
|
||||
this.add({
|
||||
control: Pip,
|
||||
}));
|
||||
this.add(new Pip({
|
||||
disable: false,
|
||||
tooltip: 'Pip',
|
||||
position: 'right',
|
||||
index: 40
|
||||
});
|
||||
this.add({
|
||||
control: Fullscreen,
|
||||
}));
|
||||
this.add(new Fullscreen({
|
||||
disable: false,
|
||||
tooltip: 'Fullscreen',
|
||||
position: 'right',
|
||||
index: 50
|
||||
});
|
||||
this.art.option.controls.forEach(function (item) {
|
||||
}));
|
||||
this.art.option.controls.filter(function (item) {
|
||||
return !item.disable;
|
||||
}).forEach(function (item) {
|
||||
_this.add(item);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "add",
|
||||
value: function add(option) {
|
||||
validControl(option);
|
||||
value: function add(control) {
|
||||
var option = control.option;
|
||||
|
||||
if (!option.disable) {
|
||||
id++;
|
||||
var name = option.control.name.toLowerCase() || "control".concat(id);
|
||||
var name = control.constructor.name.toLowerCase() || "control".concat(id);
|
||||
var $control = document.createElement('div');
|
||||
$control.setAttribute('class', "art-control art-control-".concat(name));
|
||||
$control.setAttribute('data-control-index', String(option.index) || id);
|
||||
option.ref = $control;
|
||||
this.commonMethod(option);
|
||||
this[name] = new option.control(this.art, option);
|
||||
option.$control = $control;
|
||||
this.commonMethod(control);
|
||||
this.$map[option.position].push($control);
|
||||
control.apply(this.art);
|
||||
this[name] = control;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
@@ -1474,24 +1535,24 @@
|
||||
}
|
||||
}, {
|
||||
key: "commonMethod",
|
||||
value: function commonMethod(option) {
|
||||
value: function commonMethod(control) {
|
||||
var _this3 = this;
|
||||
|
||||
Object.defineProperty(option.control.prototype, 'hide', {
|
||||
Object.defineProperty(control, 'hide', {
|
||||
value: function value() {
|
||||
option.ref.style.display = 'none';
|
||||
control.option.$control.style.display = 'none';
|
||||
|
||||
_this3.art.emit('control:hide', option.ref);
|
||||
_this3.art.emit('control:hide', control.option.$control);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(option.control.prototype, 'show', {
|
||||
Object.defineProperty(control, 'show', {
|
||||
value: function value() {
|
||||
option.ref.style.display = option.position === 'top' ? 'block' : 'inline-block';
|
||||
control.option.$control.style.display = 'block';
|
||||
|
||||
_this3.art.emit('control:show', option.ref);
|
||||
_this3.art.emit('control:show', control.option.$control);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(option.control.prototype, 'getPosFromEvent', {
|
||||
Object.defineProperty(control, 'getPosFromEvent', {
|
||||
value: function value(event) {
|
||||
var _this3$art$refs = _this3.art.refs,
|
||||
$video = _this3$art$refs.$video,
|
||||
@@ -1530,6 +1591,8 @@
|
||||
return Controls;
|
||||
}();
|
||||
|
||||
var id$1 = 0;
|
||||
|
||||
var Contextmenu =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
@@ -1551,15 +1614,17 @@
|
||||
refs = _this$art.refs,
|
||||
proxy = _this$art.events.proxy;
|
||||
option.contextmenu.push({
|
||||
text: i18n.get('Video info'),
|
||||
name: 'info',
|
||||
html: i18n.get('Video info'),
|
||||
click: function click() {
|
||||
_this.art.info.show();
|
||||
}
|
||||
}, {
|
||||
text: 'ArtPlayer 1.0.0',
|
||||
link: 'https://github.com/zhw2590582/artplayer'
|
||||
name: 'version',
|
||||
html: '<a href="https://github.com/zhw2590582/artplayer" target="_blank">ArtPlayer 1.0.0</a>'
|
||||
}, {
|
||||
text: i18n.get('Close'),
|
||||
name: 'close',
|
||||
html: i18n.get('Close'),
|
||||
click: function click() {
|
||||
_this.hide();
|
||||
}
|
||||
@@ -1594,20 +1659,21 @@
|
||||
refs.$contextmenu = document.createElement('div');
|
||||
refs.$contextmenu.classList.add('artplayer-contextmenu');
|
||||
option.contextmenu.forEach(function (item) {
|
||||
var $menu = document.createElement('a');
|
||||
$menu.innerHTML = item.text;
|
||||
$menu.classList.add('art-menu');
|
||||
id$1++;
|
||||
var $menu = document.createElement('div');
|
||||
$menu.setAttribute('data-art-menu-id', id$1);
|
||||
$menu.setAttribute('class', "art-menu art-menu-".concat(item.name || id$1));
|
||||
append($menu, item.html);
|
||||
setStyle($menu, item.style || {});
|
||||
|
||||
if (item.link) {
|
||||
$menu.target = '_blank';
|
||||
$menu.href = item.link;
|
||||
} else if (item.click) {
|
||||
$menu.href = '#';
|
||||
if (item.click) {
|
||||
proxy($menu, 'click', function (event) {
|
||||
event.preventDefault();
|
||||
item.click(_this2.art, event);
|
||||
|
||||
_this2.hide();
|
||||
|
||||
_this2.art.emit('contextmenu:click', $menu);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1722,8 +1788,8 @@
|
||||
var infoHtml = [];
|
||||
infoHtml.push("\n <div class=\"art-info-item \">\n <div class=\"art-info-title\">Player version:</div>\n <div class=\"art-info-content\">1.0.0</div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video url:</div>\n <div class=\"art-info-content\" data-video=\"currentSrc\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video type:</div>\n <div class=\"art-info-content\" data-head=\"Content-Type\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video size:</div>\n <div class=\"art-info-content\" data-head=\"Content-length\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video type:</div>\n <div class=\"art-info-content\" data-head=\"Content-Type\">loading...</div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video size:</div>\n <div class=\"art-info-content\" data-head=\"Content-length\">loading...</div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video volume:</div>\n <div class=\"art-info-content\" data-video=\"volume\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video time:</div>\n <div class=\"art-info-content\" data-video=\"currentTime\"></div>\n </div>\n ");
|
||||
infoHtml.push("\n <div class=\"art-info-item\">\n <div class=\"art-info-title\">Video duration:</div>\n <div class=\"art-info-content\" data-video=\"duration\"></div>\n </div>\n ");
|
||||
@@ -1788,8 +1854,12 @@
|
||||
classCallCheck(this, Subtitle);
|
||||
|
||||
this.art = art;
|
||||
this.checkExt(this.art.option.subtitle.url);
|
||||
this.init();
|
||||
var url = this.art.option.subtitle.url;
|
||||
|
||||
if (url) {
|
||||
this.checkExt(url);
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
createClass(Subtitle, [{
|
||||
@@ -2013,7 +2083,7 @@
|
||||
return Hotkey;
|
||||
}();
|
||||
|
||||
var id$1 = 0;
|
||||
var id$2 = 0;
|
||||
|
||||
var Layers =
|
||||
/*#__PURE__*/
|
||||
@@ -2044,11 +2114,11 @@
|
||||
key: "add",
|
||||
value: function add(option, callback) {
|
||||
var refs = this.art.refs;
|
||||
id$1++;
|
||||
id$2++;
|
||||
var $layer = document.createElement('div');
|
||||
$layer.setAttribute('data-art-layer-id', id$1);
|
||||
$layer.setAttribute('class', "art-layer art-layer-".concat(option.name || id$1));
|
||||
$layer.style.zIndex = option.index || id$1;
|
||||
$layer.setAttribute('data-art-layer-id', id$2);
|
||||
$layer.setAttribute('class', "art-layer art-layer-".concat(option.name || id$2));
|
||||
$layer.style.zIndex = option.index || id$2;
|
||||
append($layer, option.html);
|
||||
setStyle($layer, option.style || {});
|
||||
refs.$layers.appendChild($layer);
|
||||
@@ -2198,7 +2268,7 @@
|
||||
return Mask;
|
||||
}();
|
||||
|
||||
var id$2 = 0;
|
||||
var id$3 = 0;
|
||||
var instances = [];
|
||||
|
||||
var Artplayer =
|
||||
@@ -2216,7 +2286,7 @@
|
||||
_this.emit('init:start');
|
||||
|
||||
_this.option = deepMerge({}, Artplayer.DEFAULTS, option);
|
||||
validOption(_this.option);
|
||||
validOption(Artplayer.DEFAULTS, _this.option);
|
||||
|
||||
_this.init();
|
||||
|
||||
@@ -2253,7 +2323,7 @@
|
||||
this.loading = new Loading(this);
|
||||
this.hotkey = new Hotkey(this);
|
||||
this.mask = new Mask(this);
|
||||
this.id = id$2++;
|
||||
this.id = id$3++;
|
||||
instances.push(this);
|
||||
return this;
|
||||
}
|
||||
@@ -2302,6 +2372,7 @@
|
||||
container: '.artplayer',
|
||||
url: '',
|
||||
poster: '',
|
||||
volume: 0.7,
|
||||
thumbnails: {
|
||||
url: '',
|
||||
number: 60,
|
||||
@@ -2309,10 +2380,8 @@
|
||||
height: 90,
|
||||
column: 10
|
||||
},
|
||||
volume: 0.7,
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
preload: 'auto',
|
||||
type: '',
|
||||
mimeCodec: '',
|
||||
layers: [],
|
||||
@@ -2326,6 +2395,12 @@
|
||||
},
|
||||
controls: [],
|
||||
highlight: [],
|
||||
moreVideoAttr: {
|
||||
'controls': false,
|
||||
'preload': 'auto',
|
||||
'webkit-playsinline': true,
|
||||
'playsinline': true
|
||||
},
|
||||
lang: navigator.language.toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/@babel/runtime/helpers/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/construct.js","../../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArray.js","../../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../../node_modules/@babel/runtime/helpers/toConsumableArray.js","../../node_modules/@babel/runtime/helpers/classCallCheck.js","../../node_modules/@babel/runtime/helpers/createClass.js","../../node_modules/@babel/runtime/helpers/typeof.js","../../node_modules/@babel/runtime/helpers/assertThisInitialized.js","../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/defineProperty.js","../../node_modules/@babel/runtime/helpers/objectSpread.js","../../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../../node_modules/@babel/runtime/helpers/nonIterableRest.js","../../node_modules/@babel/runtime/helpers/slicedToArray.js","../../node_modules/@babel/runtime/helpers/isNativeFunction.js","../../node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/index.js","../../src/verification/player.js","../../src/config/mimeCodec.js","../../src/config/mse.js","../../src/config/video.js","../../src/config/index.js","../../node_modules/tiny-emitter/index.js","../../src/template.js","../../src/i18n.js","../../src/player.js","../../src/verification/control.js","../../src/controls/danmu.js","../../src/controls/fullscreen.js","../../src/controls/pip.js","../../src/icons/index.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/thumbnails.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/index.js"],"sourcesContent":["function _setPrototypeOf(o, p) {\n module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nmodule.exports = _setPrototypeOf;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _construct(Parent, args, Class) {\n if (isNativeReflectConstruct()) {\n module.exports = _construct = Reflect.construct;\n } else {\n module.exports = _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\n\nmodule.exports = _construct;","function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}\n\nmodule.exports = _arrayWithoutHoles;","function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}\n\nmodule.exports = _nonIterableSpread;","var arrayWithoutHoles = require(\"./arrayWithoutHoles\");\n\nvar iterableToArray = require(\"./iterableToArray\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defLine truncated
|
||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/@babel/runtime/helpers/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/construct.js","../../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArray.js","../../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../../node_modules/@babel/runtime/helpers/toConsumableArray.js","../../node_modules/@babel/runtime/helpers/classCallCheck.js","../../node_modules/@babel/runtime/helpers/createClass.js","../../node_modules/@babel/runtime/helpers/typeof.js","../../node_modules/@babel/runtime/helpers/assertThisInitialized.js","../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/defineProperty.js","../../node_modules/@babel/runtime/helpers/objectSpread.js","../../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../../node_modules/@babel/runtime/helpers/nonIterableRest.js","../../node_modules/@babel/runtime/helpers/slicedToArray.js","../../node_modules/@babel/runtime/helpers/isNativeFunction.js","../../node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/index.js","../../src/verification/player.js","../../src/config/mimeCodec.js","../../src/config/mse.js","../../src/config/video.js","../../src/config/index.js","../../node_modules/tiny-emitter/index.js","../../src/template.js","../../src/i18n.js","../../src/player.js","../../src/controls/danmu.js","../../src/controls/fullscreen.js","../../src/controls/pip.js","../../src/icons/index.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/thumbnails.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/index.js"],"sourcesContent":["function _setPrototypeOf(o, p) {\n module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nmodule.exports = _setPrototypeOf;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _construct(Parent, args, Class) {\n if (isNativeReflectConstruct()) {\n module.exports = _construct = Reflect.construct;\n } else {\n module.exports = _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\n\nmodule.exports = _construct;","function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}\n\nmodule.exports = _arrayWithoutHoles;","function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}\n\nmodule.exports = _nonIterableSpread;","var arrayWithoutHoles = require(\"./arrayWithoutHoles\");\n\nvar iterableToArray = require(\"./iterableToArray\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, Line truncated
|
||||
+16
-13
@@ -1,5 +1,6 @@
|
||||
import { append } from './utils';
|
||||
import { append, setStyle } from './utils';
|
||||
|
||||
let id = 0;
|
||||
export default class Contextmenu {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
@@ -16,17 +17,19 @@ export default class Contextmenu {
|
||||
|
||||
option.contextmenu.push(
|
||||
{
|
||||
text: i18n.get('Video info'),
|
||||
name: 'info',
|
||||
html: i18n.get('Video info'),
|
||||
click: () => {
|
||||
this.art.info.show();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'ArtPlayer __VERSION__',
|
||||
link: 'https://github.com/zhw2590582/artplayer'
|
||||
name: 'version',
|
||||
html: '<a href="https://github.com/zhw2590582/artplayer" target="_blank">ArtPlayer __VERSION__</a>'
|
||||
},
|
||||
{
|
||||
text: i18n.get('Close'),
|
||||
name: 'close',
|
||||
html: i18n.get('Close'),
|
||||
click: () => {
|
||||
this.hide();
|
||||
}
|
||||
@@ -59,18 +62,18 @@ export default class Contextmenu {
|
||||
refs.$contextmenu = document.createElement('div');
|
||||
refs.$contextmenu.classList.add('artplayer-contextmenu');
|
||||
option.contextmenu.forEach(item => {
|
||||
const $menu = document.createElement('a');
|
||||
$menu.innerHTML = item.text;
|
||||
$menu.classList.add('art-menu');
|
||||
if (item.link) {
|
||||
$menu.target = '_blank';
|
||||
$menu.href = item.link;
|
||||
} else if (item.click) {
|
||||
$menu.href = '#';
|
||||
id++;
|
||||
const $menu = document.createElement('div');
|
||||
$menu.setAttribute('data-art-menu-id', id);
|
||||
$menu.setAttribute('class', `art-menu art-menu-${item.name || id}`);
|
||||
append($menu, item.html);
|
||||
setStyle($menu, item.style || {});
|
||||
if (item.click) {
|
||||
proxy($menu, 'click', event => {
|
||||
event.preventDefault();
|
||||
item.click(this.art, event);
|
||||
this.hide();
|
||||
this.art.emit('contextmenu:click', $menu);
|
||||
});
|
||||
}
|
||||
append(refs.$contextmenu, $menu);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
export default class Danmu {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
export default class Fullscreen {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}
|
||||
+36
-54
@@ -1,5 +1,4 @@
|
||||
import { secondToTime, clamp } from '../utils';
|
||||
import validControl from '../verification/control';
|
||||
import Danmu from './danmu';
|
||||
import Fullscreen from './fullscreen';
|
||||
import Pip from './pip';
|
||||
@@ -25,100 +24,84 @@ export default class Controls {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.add({
|
||||
control: Progress,
|
||||
this.add(new Progress({
|
||||
disable: false,
|
||||
position: 'top',
|
||||
index: 10
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Thumbnails,
|
||||
this.add(new Thumbnails({
|
||||
disable: !this.art.option.thumbnails.url,
|
||||
position: 'top',
|
||||
index: 20
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: PlayAndPause,
|
||||
this.add(new PlayAndPause({
|
||||
disable: false,
|
||||
position: 'left',
|
||||
index: 10
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Volume,
|
||||
this.add(new Volume({
|
||||
disable: false,
|
||||
tooltip: 'Volume',
|
||||
position: 'left',
|
||||
index: 20
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Time,
|
||||
this.add(new Time({
|
||||
disable: false,
|
||||
tooltip: 'Volume',
|
||||
position: 'left',
|
||||
index: 30
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Danmu,
|
||||
this.add(new Danmu({
|
||||
disable: false,
|
||||
tooltip: 'Danmu',
|
||||
position: 'right',
|
||||
index: 10
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Subtitle,
|
||||
this.add(new Subtitle({
|
||||
disable: false,
|
||||
tooltip: 'Subtitle',
|
||||
position: 'right',
|
||||
index: 20
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Setting,
|
||||
this.add(new Setting({
|
||||
disable: false,
|
||||
tooltip: 'Setting',
|
||||
position: 'right',
|
||||
index: 30
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Pip,
|
||||
this.add(new Pip({
|
||||
disable: false,
|
||||
tooltip: 'Pip',
|
||||
position: 'right',
|
||||
index: 40
|
||||
});
|
||||
}));
|
||||
|
||||
this.add({
|
||||
control: Fullscreen,
|
||||
this.add(new Fullscreen({
|
||||
disable: false,
|
||||
tooltip: 'Fullscreen',
|
||||
position: 'right',
|
||||
index: 50
|
||||
});
|
||||
}));
|
||||
|
||||
this.art.option.controls.forEach(item => {
|
||||
this.art.option.controls.filter(item => !item.disable).forEach(item => {
|
||||
this.add(item);
|
||||
});
|
||||
}
|
||||
|
||||
add(option) {
|
||||
validControl(option);
|
||||
add(control) {
|
||||
const { option } = control;
|
||||
if (!option.disable) {
|
||||
id++;
|
||||
const name = option.control.name.toLowerCase() || `control${id}`;
|
||||
const name = control.constructor.name.toLowerCase() || `control${id}`;
|
||||
const $control = document.createElement('div');
|
||||
$control.setAttribute('class', `art-control art-control-${name}`);
|
||||
$control.setAttribute('data-control-index', String(option.index) || id);
|
||||
option.ref = $control;
|
||||
this.commonMethod(option);
|
||||
this[name] = new option.control(this.art, option);
|
||||
option.$control = $control;
|
||||
this.commonMethod(control);
|
||||
this.$map[option.position].push($control);
|
||||
control.apply(this.art);
|
||||
this[name] = control;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,23 +131,22 @@ export default class Controls {
|
||||
});
|
||||
}
|
||||
|
||||
commonMethod(option) {
|
||||
Object.defineProperty(option.control.prototype, 'hide', {
|
||||
commonMethod(control) {
|
||||
Object.defineProperty(control, 'hide', {
|
||||
value: () => {
|
||||
option.ref.style.display = 'none';
|
||||
this.art.emit('control:hide', option.ref);
|
||||
control.option.$control.style.display = 'none';
|
||||
this.art.emit('control:hide', control.option.$control);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(option.control.prototype, 'show', {
|
||||
Object.defineProperty(control, 'show', {
|
||||
value: () => {
|
||||
option.ref.style.display =
|
||||
option.position === 'top' ? 'block' : 'inline-block';
|
||||
this.art.emit('control:show', option.ref);
|
||||
control.option.$control.style.display = 'block';
|
||||
this.art.emit('control:show', control.option.$control);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(option.control.prototype, 'getPosFromEvent', {
|
||||
Object.defineProperty(control, 'getPosFromEvent', {
|
||||
value: event => {
|
||||
const { $video, $progress } = this.art.refs;
|
||||
const { left } = $progress.getBoundingClientRect();
|
||||
|
||||
+5
-2
@@ -1,6 +1,9 @@
|
||||
export default class Pip {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,20 @@ import { append } from '../utils';
|
||||
import icons from '../icons';
|
||||
|
||||
export default class PlayAndPause {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const { events: { proxy }, player } = this.art;
|
||||
|
||||
this.$play = append(this.option.ref, icons.play);
|
||||
this.$pause = append(this.option.ref, icons.pause);
|
||||
this.$play = append(this.option.$control, icons.play);
|
||||
this.$pause = append(this.option.$control, icons.pause);
|
||||
this.$pause.style.display = 'none';
|
||||
|
||||
proxy(this.$play, 'click', () => {
|
||||
|
||||
+18
-15
@@ -1,9 +1,12 @@
|
||||
import { append } from '../utils';
|
||||
|
||||
export default class Progress {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
this.isDroging = false;
|
||||
this.getLoaded = this.getLoaded.bind(this);
|
||||
this.getPlayed = this.getPlayed.bind(this);
|
||||
@@ -20,7 +23,7 @@ export default class Progress {
|
||||
} = this.art;
|
||||
|
||||
append(
|
||||
this.option.ref,
|
||||
this.option.$control,
|
||||
`
|
||||
<div class="art-control-progress-inner">
|
||||
<div class="art-progress-loaded"></div>
|
||||
@@ -32,15 +35,15 @@ export default class Progress {
|
||||
`
|
||||
);
|
||||
|
||||
this.$loaded = this.option.ref.querySelector('.art-progress-loaded');
|
||||
this.$played = this.option.ref.querySelector('.art-progress-played');
|
||||
this.$highlight = this.option.ref.querySelector('.art-progress-highlight');
|
||||
this.$indicator = this.option.ref.querySelector('.art-progress-indicator');
|
||||
this.$tip = this.option.ref.querySelector('.art-progress-tip');
|
||||
this.$loaded = this.option.$control.querySelector('.art-progress-loaded');
|
||||
this.$played = this.option.$control.querySelector('.art-progress-played');
|
||||
this.$highlight = this.option.$control.querySelector('.art-progress-highlight');
|
||||
this.$indicator = this.option.$control.querySelector('.art-progress-indicator');
|
||||
this.$tip = this.option.$control.querySelector('.art-progress-tip');
|
||||
|
||||
this.art.on('video:canplay', () => {
|
||||
this.set('loaded', this.getLoaded());
|
||||
highlight.forEach(item => {
|
||||
highlight.filter(item => !item.disable).forEach(item => {
|
||||
const left = Number(item.time) / $video.duration;
|
||||
append(this.$highlight, `
|
||||
<span data-text="${item.text}" data-time="${item.time}" style="left: ${left * 100}%"></span>
|
||||
@@ -61,7 +64,7 @@ export default class Progress {
|
||||
this.set('played', 1);
|
||||
});
|
||||
|
||||
proxy(this.option.ref, 'mousemove', event => {
|
||||
proxy(this.option.$control, 'mousemove', event => {
|
||||
this.$tip.style.display = 'block';
|
||||
if (event.path.indexOf(this.$highlight) > -1) {
|
||||
this.showHighlight(event);
|
||||
@@ -70,11 +73,11 @@ export default class Progress {
|
||||
}
|
||||
});
|
||||
|
||||
proxy(this.option.ref, 'mouseout', () => {
|
||||
proxy(this.option.$control, 'mouseout', () => {
|
||||
this.$tip.style.display = 'none';
|
||||
});
|
||||
|
||||
proxy(this.option.ref, 'click', event => {
|
||||
proxy(this.option.$control, 'click', event => {
|
||||
if (event.target !== this.$indicator) {
|
||||
const { second, percentage } = this.getPosFromEvent(event);
|
||||
this.set('played', percentage);
|
||||
@@ -108,7 +111,7 @@ export default class Progress {
|
||||
const { text, time } = event.target.dataset;
|
||||
this.$tip.innerHTML = text;
|
||||
const left =
|
||||
Number(time) / $video.duration * this.option.ref.clientWidth +
|
||||
Number(time) / $video.duration * this.option.$control.clientWidth +
|
||||
event.target.clientWidth / 2 -
|
||||
this.$tip.clientWidth / 2;
|
||||
this.$tip.style.left = `${left}px`;
|
||||
@@ -120,8 +123,8 @@ export default class Progress {
|
||||
this.$tip.innerHTML = time;
|
||||
if (width <= tipWidth / 2) {
|
||||
this.$tip.style.left = 0;
|
||||
} else if (width > this.option.ref.clientWidth - tipWidth / 2) {
|
||||
this.$tip.style.left = `${this.option.ref.clientWidth - tipWidth}px`;
|
||||
} else if (width > this.option.$control.clientWidth - tipWidth / 2) {
|
||||
this.$tip.style.left = `${this.option.$control.clientWidth - tipWidth}px`;
|
||||
} else {
|
||||
this.$tip.style.left = `${width - tipWidth / 2}px`;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
export default class Setting {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
export default class Subtitle {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
}
|
||||
}
|
||||
+14
-11
@@ -1,7 +1,10 @@
|
||||
export default class Thumbnails {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
|
||||
@@ -12,12 +15,12 @@ export default class Thumbnails {
|
||||
} = this.art;
|
||||
|
||||
proxy($progress, 'mousemove', event => {
|
||||
this.option.ref.style.display = 'block';
|
||||
this.option.$control.style.display = 'block';
|
||||
this.showThumbnails(event);
|
||||
});
|
||||
|
||||
proxy($progress, 'mouseout', () => {
|
||||
this.option.ref.style.display = 'none';
|
||||
this.option.$control.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,17 +33,17 @@ export default class Thumbnails {
|
||||
let yIndex = Math.ceil(perIndex / column);
|
||||
let xIndex = perIndex % column || column;
|
||||
|
||||
this.option.ref.style.backgroundImage = `url(${url})`;
|
||||
this.option.ref.style.height = `${height}px`;
|
||||
this.option.ref.style.width = `${width}px`;
|
||||
this.option.ref.style.backgroundPosition = `-${--xIndex * width}px -${--yIndex * height}px`;
|
||||
this.option.$control.style.backgroundImage = `url(${url})`;
|
||||
this.option.$control.style.height = `${height}px`;
|
||||
this.option.$control.style.width = `${width}px`;
|
||||
this.option.$control.style.backgroundPosition = `-${--xIndex * width}px -${--yIndex * height}px`;
|
||||
|
||||
if (posWidth <= width / 2) {
|
||||
this.option.ref.style.left = 0;
|
||||
this.option.$control.style.left = 0;
|
||||
} else if (posWidth > $progress.clientWidth - width / 2) {
|
||||
this.option.ref.style.left = `${$progress.clientWidth - width}px`;
|
||||
this.option.$control.style.left = `${$progress.clientWidth - width}px`;
|
||||
} else {
|
||||
this.option.ref.style.left = `${posWidth - width / 2}px`;
|
||||
this.option.$control.style.left = `${posWidth - width / 2}px`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,28 @@
|
||||
import { secondToTime } from '../utils';
|
||||
|
||||
export default class Time {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
this.option.ref.innerHTML = '00:00 / 00:00';
|
||||
this.option.$control.innerHTML = '00:00 / 00:00';
|
||||
|
||||
this.art.on('video:canplay', () => {
|
||||
this.option.ref.innerHTML = this.getTime();
|
||||
this.option.$control.innerHTML = this.getTime();
|
||||
});
|
||||
|
||||
this.art.on('video:timeupdate', () => {
|
||||
this.option.ref.innerHTML = this.getTime();
|
||||
this.option.$control.innerHTML = this.getTime();
|
||||
});
|
||||
|
||||
this.art.on('video:seeking', () => {
|
||||
this.option.ref.innerHTML = this.getTime();
|
||||
this.option.$control.innerHTML = this.getTime();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -2,18 +2,21 @@ import { append, setStorage, getStorage, clamp } from '../utils';
|
||||
import icons from '../icons';
|
||||
|
||||
export default class Volume {
|
||||
constructor(art, option) {
|
||||
this.art = art;
|
||||
constructor(option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
apply(art) {
|
||||
this.art = art;
|
||||
this.isDroging = false;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const { events: { proxy }, player } = this.art;
|
||||
this.$volume = append(this.option.ref, icons.volume);
|
||||
this.$volumeClose = append(this.option.ref, icons.volumeClose);
|
||||
this.$volumePanel = append(this.option.ref, '<div class="art-volume-panel"></div>');
|
||||
this.$volume = append(this.option.$control, icons.volume);
|
||||
this.$volumeClose = append(this.option.$control, icons.volumeClose);
|
||||
this.$volumePanel = append(this.option.$control, '<div class="art-volume-panel"></div>');
|
||||
this.$volumeHandle = append(this.$volumePanel, '<div class="art-volume-slider-handle"></div>');
|
||||
this.$volumeClose.style.display = 'none';
|
||||
|
||||
@@ -31,9 +34,10 @@ export default class Volume {
|
||||
proxy(this.$volumeClose, 'click', () => {
|
||||
this.$volume.style.display = 'block';
|
||||
this.$volumeClose.style.display = 'none';
|
||||
player.volume(getStorage('volume'));
|
||||
});
|
||||
|
||||
proxy(this.option.ref, 'mouseenter', () => {
|
||||
proxy(this.option.$control, 'mouseenter', () => {
|
||||
this.$volumePanel.classList.add('art-volume-panel-hover');
|
||||
|
||||
// TODO
|
||||
@@ -42,7 +46,7 @@ export default class Volume {
|
||||
}, 200);
|
||||
});
|
||||
|
||||
proxy(this.option.ref, 'mouseleave', () => {
|
||||
proxy(this.option.$control, 'mouseleave', () => {
|
||||
this.$volumePanel.classList.remove('art-volume-panel-hover');
|
||||
});
|
||||
|
||||
|
||||
+9
-4
@@ -1,4 +1,4 @@
|
||||
import './style/index.scss';
|
||||
import './style';
|
||||
import { deepMerge } from './utils';
|
||||
import validOption from './verification/player';
|
||||
import config from './config';
|
||||
@@ -26,7 +26,7 @@ class Artplayer extends Emitter {
|
||||
super();
|
||||
this.emit('init:start');
|
||||
this.option = deepMerge({}, Artplayer.DEFAULTS, option);
|
||||
validOption(this.option);
|
||||
validOption(Artplayer.DEFAULTS, this.option);
|
||||
this.init();
|
||||
this.emit('init:end');
|
||||
}
|
||||
@@ -44,6 +44,7 @@ class Artplayer extends Emitter {
|
||||
container: '.artplayer',
|
||||
url: '',
|
||||
poster: '',
|
||||
volume: 0.7,
|
||||
thumbnails: {
|
||||
url: '',
|
||||
number: 60,
|
||||
@@ -51,10 +52,8 @@ class Artplayer extends Emitter {
|
||||
height: 90,
|
||||
column: 10
|
||||
},
|
||||
volume: 0.7,
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
preload: 'auto',
|
||||
type: '',
|
||||
mimeCodec: '',
|
||||
layers: [],
|
||||
@@ -68,6 +67,12 @@ class Artplayer extends Emitter {
|
||||
},
|
||||
controls: [],
|
||||
highlight: [],
|
||||
moreVideoAttr: {
|
||||
'controls': false,
|
||||
'preload': 'auto',
|
||||
'webkit-playsinline': true,
|
||||
'playsinline': true
|
||||
},
|
||||
lang: navigator.language.toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,14 +45,14 @@ export default class Info {
|
||||
infoHtml.push(`
|
||||
<div class="art-info-item">
|
||||
<div class="art-info-title">Video type:</div>
|
||||
<div class="art-info-content" data-head="Content-Type"></div>
|
||||
<div class="art-info-content" data-head="Content-Type">loading...</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
infoHtml.push(`
|
||||
<div class="art-info-item">
|
||||
<div class="art-info-title">Video size:</div>
|
||||
<div class="art-info-content" data-head="Content-length"></div>
|
||||
<div class="art-info-content" data-head="Content-length">loading...</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
|
||||
+6
-5
@@ -9,13 +9,14 @@ export default class Player {
|
||||
}
|
||||
|
||||
init() {
|
||||
const { option } = this.art;
|
||||
const { $video } = this.art.refs;
|
||||
$video.controls = false;
|
||||
$video.poster = option.poster;
|
||||
const { option, refs: { $video } } = this.art;
|
||||
Object.keys(option.moreVideoAttr).forEach(key => {
|
||||
const value = option.moreVideoAttr[key];
|
||||
$video[key] = value;
|
||||
});
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
$video.poster = option.poster;
|
||||
$video.autoplay = option.autoplay;
|
||||
$video.preload = option.preload;
|
||||
$video.src = option.url;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
.artplayer-video-player {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
outline: 0;
|
||||
font-family: Roboto,Arial,Helvetica,sans-serif;
|
||||
color: #eee;
|
||||
text-align: left;
|
||||
direction: ltr;
|
||||
font-size: 14px;
|
||||
line-height: 1.3;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
touch-action: manipulation;
|
||||
-ms-high-contrast-adjust: none;
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.art-icon {
|
||||
display: inline-block;
|
||||
svg {
|
||||
fill: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
&.artplayer-error {
|
||||
.art-progress-indicator, .art-progress-tip {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +1,4 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
.artplayer-video-player {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
outline: 0;
|
||||
font-family: Roboto,Arial,Helvetica,sans-serif;
|
||||
color: #eee;
|
||||
text-align: left;
|
||||
direction: ltr;
|
||||
font-size: 14px;
|
||||
line-height: 1.3;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
touch-action: manipulation;
|
||||
-ms-high-contrast-adjust: none;
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.art-icon {
|
||||
display: inline-block;
|
||||
svg {
|
||||
fill: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-video {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #000;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.artplayer-subtitle {
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
bottom: 40px;
|
||||
width: 100%;
|
||||
padding: 0 20px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
text-shadow: 0.5px 0.5px 0.5px rgba(0, 0, 0, 0.5);
|
||||
font-size: 20px;
|
||||
|
||||
p {
|
||||
margin: 5px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-layers {
|
||||
position: absolute;
|
||||
z-index: 30;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.art-layer {
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-mask {
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 40;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
|
||||
.art-icon-playBig {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
bottom: 65px;
|
||||
opacity: .6;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-loading {
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 40;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.artplayer-bottom {
|
||||
position: absolute;
|
||||
z-index: 50;
|
||||
@@ -226,7 +119,7 @@
|
||||
background-color: rgba(0,0,0,.7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.artplayer-controls {
|
||||
position: relative;
|
||||
pointer-events: all;
|
||||
@@ -234,7 +127,7 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 36px;
|
||||
|
||||
|
||||
.art-control {
|
||||
float: left;
|
||||
font-size: 12px;
|
||||
@@ -251,7 +144,7 @@
|
||||
padding: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.art-control-volume {
|
||||
.art-volume-panel {
|
||||
position: relative;
|
||||
@@ -260,7 +153,7 @@
|
||||
height: 100%;
|
||||
transition: margin .2s cubic-bezier(0.4,0.0,1,1),width .2s cubic-bezier(0.4,0.0,1,1);
|
||||
overflow: hidden;
|
||||
|
||||
|
||||
.art-volume-slider-handle {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@@ -270,17 +163,17 @@
|
||||
border-radius: 12px;
|
||||
margin-top: -6px;
|
||||
background: #fff;
|
||||
|
||||
|
||||
&::before {
|
||||
left: -54px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
|
||||
&::after {
|
||||
left: 6px;
|
||||
background: rgba(255,255,255,.2);
|
||||
}
|
||||
|
||||
|
||||
&::before, &::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
@@ -291,13 +184,13 @@
|
||||
width: 60px
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&.art-volume-panel-hover {
|
||||
width: 60px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.art-control-time {
|
||||
padding: 0 10px;
|
||||
}
|
||||
@@ -310,87 +203,4 @@
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-notice {
|
||||
display: none;
|
||||
font-size: 14px;
|
||||
position: absolute;
|
||||
z-index: 60;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
border-radius: 3px;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.artplayer-contextmenu {
|
||||
position: absolute;
|
||||
z-index: 70;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 200px;
|
||||
padding: 5px 0;
|
||||
background:rgba(0, 0, 0, 0.8);
|
||||
a {
|
||||
font-size: 13px;
|
||||
display: block;
|
||||
color: #fff;
|
||||
padding: 7px 10px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(255,255,255,.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-info {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
z-index: 80;
|
||||
width: 350px;
|
||||
min-height: 150px;
|
||||
padding: 10px;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-family: Noto Sans CJK SC DemiLight,Roboto,Segoe UI,Tahoma,Arial,Helvetica,sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
background: rgba(0,0,0,.7);
|
||||
|
||||
.art-info-item {
|
||||
display: flex;
|
||||
margin-bottom: 5px;
|
||||
.art-info-title {
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.art-info-content {
|
||||
flex: 1;
|
||||
padding-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-info-close {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&.artplayer-error {
|
||||
.art-progress-indicator, .art-progress-tip {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-contextmenu {
|
||||
position: absolute;
|
||||
z-index: 70;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 200px;
|
||||
padding: 5px 0;
|
||||
background:rgba(0, 0, 0, 0.8);
|
||||
.art-menu {
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
display: block;
|
||||
color: #fff;
|
||||
padding: 7px 10px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
|
||||
|
||||
a {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(255,255,255,.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import './artplayer.scss';
|
||||
import './video.scss';
|
||||
import './subtitle.scss';
|
||||
import './layers.scss';
|
||||
import './mask.scss';
|
||||
import './loading.scss';
|
||||
import './bottom.scss';
|
||||
import './notice.scss';
|
||||
import './contextmenu.scss';
|
||||
import './info.scss';
|
||||
@@ -0,0 +1,38 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-info {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
z-index: 80;
|
||||
width: 350px;
|
||||
min-height: 150px;
|
||||
padding: 10px;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-family: Noto Sans CJK SC DemiLight,Roboto,Segoe UI,Tahoma,Arial,Helvetica,sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
background: rgba(0,0,0,.7);
|
||||
|
||||
.art-info-item {
|
||||
display: flex;
|
||||
margin-bottom: 5px;
|
||||
.art-info-title {
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.art-info-content {
|
||||
flex: 1;
|
||||
padding-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.artplayer-info-close {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-layers {
|
||||
position: absolute;
|
||||
z-index: 30;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.art-layer {
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-loading {
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 40;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-mask {
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 40;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
|
||||
.art-icon-playBig {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
bottom: 65px;
|
||||
opacity: .6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-notice {
|
||||
display: none;
|
||||
font-size: 14px;
|
||||
position: absolute;
|
||||
z-index: 60;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
border-radius: 3px;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-subtitle {
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
bottom: 40px;
|
||||
width: 100%;
|
||||
padding: 0 20px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
text-shadow: 0.5px 0.5px 0.5px rgba(0, 0, 0, 0.5);
|
||||
font-size: 20px;
|
||||
|
||||
p {
|
||||
margin: 5px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
.artplayer-video-player {
|
||||
.artplayer-video {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #000;
|
||||
outline: 0;
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -3,8 +3,12 @@ import { errorHandle, getExt, setStyle } from './utils';
|
||||
export default class Subtitle {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.checkExt(this.art.option.subtitle.url);
|
||||
this.init();
|
||||
|
||||
const { url } = this.art.option.subtitle;
|
||||
if (url) {
|
||||
this.checkExt(url);
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ export default class Template {
|
||||
const { refs } = this.art;
|
||||
refs.$container.innerHTML = `
|
||||
<div class="artplayer-video-player">
|
||||
<video class="artplayer-video" webkit-playsinline playsinline></video>
|
||||
<video class="artplayer-video"></video>
|
||||
<div class="artplayer-subtitle"></div>
|
||||
<div class="artplayer-layers"></div>
|
||||
<div class="artplayer-mask"></div>
|
||||
|
||||
@@ -91,3 +91,9 @@ export function setStorage(key, value) {
|
||||
});
|
||||
localStorage.setItem('artplayer_settings', JSON.stringify(storage));
|
||||
}
|
||||
|
||||
export function getType(val) {
|
||||
const { toString } = Object.prototype;
|
||||
const type = toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, '');
|
||||
return type;
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
import { errorHandle } from '../utils';
|
||||
|
||||
export default function validControl(option) {
|
||||
errorHandle(
|
||||
typeof option.control === 'function',
|
||||
`'control' option require 'function' type, but got '${typeof option.control}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.disable === 'boolean',
|
||||
`'disable' option require 'boolean' type, but got '${typeof option.disable}'.`
|
||||
|
||||
+12
-105
@@ -1,108 +1,15 @@
|
||||
import { errorHandle } from '../utils';
|
||||
import { errorHandle, getType } from '../utils';
|
||||
|
||||
export default function validOption(option) {
|
||||
errorHandle(
|
||||
option.container,
|
||||
'\'container\' option is required.'
|
||||
);
|
||||
export default function validOption(DEFAULTS, option, path = ['option']) {
|
||||
Object.keys(DEFAULTS).forEach(key => {
|
||||
const defaultValue = DEFAULTS[key];
|
||||
const value = option[key];
|
||||
const defaultType = getType(defaultValue);
|
||||
const type = getType(value);
|
||||
errorHandle(defaultType === type, `'${path.join('.')}.${key}' require '${defaultType}' type, but got '${type}'`);
|
||||
|
||||
errorHandle(
|
||||
option.url,
|
||||
'\'url\' option is required.'
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.container === 'string' || option.container instanceof Element,
|
||||
`'container' option require 'string' or 'Element' type, but got '${typeof option.container}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.url === 'string',
|
||||
`'url' option require 'string' type, but got '${typeof option.url}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.poster === 'string',
|
||||
`'poster' option require 'string' type, but got '${typeof option.poster}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
Object.prototype.toString.call(option.thumbnails) === '[object Object]',
|
||||
`'thumbnails' option require 'object' type, but got '${typeof option.thumbnails}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.volume === 'number',
|
||||
`'volume' option require 'number' type, but got '${typeof option.volume}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.autoplay === 'boolean',
|
||||
`'autoplay' option require 'boolean' type, but got '${typeof option.autoplay}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.loop === 'boolean',
|
||||
`'loop' option require 'boolean' type, but got '${typeof option.loop}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
['none', 'metadata', 'auto'].indexOf(option.preload) > -1,
|
||||
`'preload' option require one of 'none、metadata、auto', but got '${option.preload}.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.lang === 'string',
|
||||
`'lang' option require 'string' type, but got '${typeof option.lang}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.type === 'string',
|
||||
`'type' option require 'string' type, but got '${typeof option.type}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.mimeCodec === 'string',
|
||||
`'mimeCodec' option require 'string' type, but got '${typeof option.mimeCodec}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
Array.isArray(option.layers),
|
||||
`'layers' option require 'array' type, but got '${typeof option.layers}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
Array.isArray(option.contextmenu),
|
||||
`'contextmenu' option require 'array' type, but got '${typeof option.contextmenu}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.loading === 'string' || option.loading instanceof Element,
|
||||
`'loading' option require 'string' type, but got '${typeof option.loading}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.theme === 'string',
|
||||
`'theme' option require 'string' type, but got '${typeof option.theme}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.hotkey === 'boolean',
|
||||
`'hotkey' option require 'boolean' type, but got '${typeof option.hotkey}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
Object.prototype.toString.call(option.subtitle) === '[object Object]',
|
||||
`'subtitle' option require 'object' type, but got '${typeof option.subtitle}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
Array.isArray(option.controls),
|
||||
`'controls' option require 'array' type, but got '${typeof option.controls}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
Array.isArray(option.highlight),
|
||||
`'highlight' option require 'array' type, but got '${typeof option.highlight}'.`
|
||||
);
|
||||
if (type === 'object') {
|
||||
validOption(defaultValue, value, path.concat(key));
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user