This commit is contained in:
Harvey Zack committed 2018-10-19 18:01:39 +08:00
1 parent e988f00cf8
commit 30456c9873
12 files changed
+121 -125

No files matched your search

+1 -1
View File
@@ -1,2 +1,2 @@
.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-font-smoothing:antialiased;-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 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;box-sizing:border-box}.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-mask{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;cursor:pointer}.artplayer-video-player .artplayer-mask .art-icon-play{opacity:.8;display:flex;align-items:center;justify-content:center;width:50px;height:50px;border-radius:50px}.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:50px 10px 0;opacity:0;visibility:hidden;transition:all .2s ease-in-out;box-sizing:border-box;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==) repeat-x bottom}.artplayer-video-player .artplayer-bottom .art-control-progress{position:relative;height:5px;padding:1px 0;cursor:pointer;box-sizing:border-box}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner{position:relative;height:100%;background:hsla(0,0%,100%,.2)}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner .art-progress-loaded{position:absolute;z-index:1;left:0;top:0;right:0;bottom:0;height:100%;width:0;background:hsla(0,0%,100%,.4);-webkit-transform-origin:0 0;transform-origin:0 0}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner .art-progress-played{position:absolute;z-index:2;left:0;top:0;right:0;bottom:0;height:100%;width:0;-webkit-transform-origin:0 0;transform-origin:0 0}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner .art-progress-indicator{display:none;position:absolute;z-index:3;top:-5px;left:-6.5px;width:13px;height:13px;border-radius:50%}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner .art-progress-indicator.show-indicator{display:block}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner .art-progress-timer{display:none;position:absolute;z-index:4;top:-25px;left:0;width:40px;height:20px;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 .art-control-progress:hover .art-progress-indicator,.artplayer-video-player .artplayer-bottom .art-control-progress:hover .art-progress-timer{display:block}.artplayer-video-player.controls-show .artplayer-bottom,.artplayer-video-player:hover .artplayer-bottom{opacity:1;visibility:visible}.artplayer-video-player .artplayer-notice{display:none;font-size:13px;position:absolute;z-index:60;left:10px;top:10px;height:30px;line-height:30px;padding:0 10px;color:#fff;background:rgba(0,0,0,.6)}.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 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,.5)}.artplayer-video-player .artplayer-contextmenu a:hover{background-color:hsla(0,0%,100%,.1)}
.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-font-smoothing:antialiased;-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 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;box-sizing:border-box}.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-mask{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;cursor:pointer}.artplayer-video-player .artplayer-mask .art-icon-play{opacity:.8;display:flex;align-items:center;justify-content:center;width:50px;height:50px;border-radius:50px}.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:50px 10px 0;opacity:0;visibility:hidden;transition:all .2s ease-in-out;box-sizing:border-box;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==) repeat-x bottom}.artplayer-video-player .artplayer-bottom .art-control-progress{position:relative;height:5px;padding:1px 0;cursor:pointer}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner{position:relative;height:100%;background:hsla(0,0%,100%,.2)}.artplayer-video-player .artplayer-bottom .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 .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 .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 .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 .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 .art-control-progress .art-control-progress-inner .art-progress-indicator.show-indicator{display:block}.artplayer-video-player .artplayer-bottom .art-control-progress .art-control-progress-inner .art-progress-timer{display:none;position:absolute;z-index:50;top:-25px;left:0;width:40px;height:20px;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 .art-control-progress:hover .art-progress-indicator,.artplayer-video-player .artplayer-bottom .art-control-progress:hover .art-progress-timer{display:block}.artplayer-video-player.controls-show .artplayer-bottom,.artplayer-video-player:hover .artplayer-bottom{opacity:1;visibility:visible}.artplayer-video-player .artplayer-notice{display:none;font-size:13px;position:absolute;z-index:60;left:10px;top:10px;height:30px;line-height:30px;padding:0 10px;color:#fff;background:rgba(0,0,0,.6)}.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 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,.5)}.artplayer-video-player .artplayer-contextmenu a:hover{background-color:hsla(0,0%,100%,.1)}
button[data-balloon]{overflow:visible}[data-balloon]{position:relative;cursor:pointer}[data-balloon]:after{font-family:sans-serif!important;font-weight:400!important;font-style:normal!important;text-shadow:none!important;font-size:12px!important;background:rgba(17,17,17,.9);border-radius:4px;color:#fff;content:attr(data-balloon);padding:.5em 1em;white-space:nowrap}[data-balloon]:after,[data-balloon]:before{filter:alpha(opactiy=0);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";-moz-opacity:0;-khtml-opacity:0;opacity:0;pointer-events:none;transition:all .18s ease-out .18s;position:absolute;z-index:10}[data-balloon]:before{background:no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='12'%3E%3Cpath fill='rgba(17,17,17,0.9)' d='M2.658 0h32.004c-6 0-11.627 12.002-16.002 12.002C14.285 12.002 8.594 0 2.658 0z'/%3E%3C/svg%3E");background-size:100% auto;width:18px;height:6px;content:""}[data-balloon]:hover:after,[data-balloon]:hover:before,[data-balloon][data-balloon-visible]:after,[data-balloon][data-balloon-visible]:before{filter:alpha(opactiy=100);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-moz-opacity:1;-khtml-opacity:1;opacity:1;pointer-events:auto}[data-balloon].font-awesome:after{font-family:FontAwesome}[data-balloon][data-balloon-break]:after{white-space:pre}[data-balloon][data-balloon-blunt]:after,[data-balloon][data-balloon-blunt]:before{transition:none}[data-balloon][data-balloon-pos=up]:after{margin-bottom:11px}[data-balloon][data-balloon-pos=up]:after,[data-balloon][data-balloon-pos=up]:before{bottom:100%;left:50%;-webkit-transform:translate(-50%,10px);transform:translate(-50%,10px);-webkit-transform-origin:top;transform-origin:top}[data-balloon][data-balloon-pos=up]:before{margin-bottom:5px}[data-balloon][data-balloon-pos=up]:hover:after,[data-balloon][data-balloon-pos=up]:hover:before,[data-balloon][data-balloon-pos=up][data-balloon-visible]:after,[data-balloon][data-balloon-pos=up][data-balloon-visible]:before{-webkit-transform:translate(-50%);transform:translate(-50%)}[data-balloon][data-balloon-pos=up-left]:after{left:0;margin-bottom:11px}[data-balloon][data-balloon-pos=up-left]:after,[data-balloon][data-balloon-pos=up-left]:before{bottom:100%;-webkit-transform:translateY(10px);transform:translateY(10px);-webkit-transform-origin:top;transform-origin:top}[data-balloon][data-balloon-pos=up-left]:before{left:5px;margin-bottom:5px}[data-balloon][data-balloon-pos=up-left]:hover:after,[data-balloon][data-balloon-pos=up-left]:hover:before,[data-balloon][data-balloon-pos=up-left][data-balloon-visible]:after,[data-balloon][data-balloon-pos=up-left][data-balloon-visible]:before{-webkit-transform:translate(0);transform:translate(0)}[data-balloon][data-balloon-pos=up-right]:after{right:0;margin-bottom:11px}[data-balloon][data-balloon-pos=up-right]:after,[data-balloon][data-balloon-pos=up-right]:before{bottom:100%;-webkit-transform:translateY(10px);transform:translateY(10px);-webkit-transform-origin:top;transform-origin:top}[data-balloon][data-balloon-pos=up-right]:before{right:5px;margin-bottom:5px}[data-balloon][data-balloon-pos=up-right]:hover:after,[data-balloon][data-balloon-pos=up-right]:hover:before,[data-balloon][data-balloon-pos=up-right][data-balloon-visible]:after,[data-balloon][data-balloon-pos=up-right][data-balloon-visible]:before{-webkit-transform:translate(0);transform:translate(0)}[data-balloon][data-balloon-pos=down]:after{margin-top:11px}[data-balloon][data-balloon-pos=down]:after,[data-balloon][data-balloon-pos=down]:before{left:50%;top:100%;-webkit-transform:translate(-50%,-10px);transform:translate(-50%,-10px)}[data-balloon][data-balloon-pos=down]:before{background:no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='12'%3E%3Cpath fill='rgba(17,17,17,0.9)' d='M33.342 12H1.338c6 0 11.627-12.002 16.002-12.002C21.715-.002 27.406 12 33.342 12z'/%3E%3C/svg%3E");background-size:100% auto;width:18px;height:6px;margin-top:5px}[data-balloon][data-balloon-pos=down]:hover:after,[data-balloon][data-balloon-pos=down]:hover:before,[data-balloon][data-balloon-pos=down][data-balloon-visible]:after,[data-balloon][data-balloon-pos=down][data-balloon-visible]:before{-webkit-transform:translate(-50%);transform:translate(-50%)}[data-balloon][data-balloon-pos=down-left]:after{left:0;margin-top:11px;top:100%;-webkit-transform:translateY(-10px);transform:translateY(-10px)}[data-balloon][data-balloon-pos=down-left]:before{background:no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='12'%3E%3Cpath fill='rgba(17,17,17,0.9)' d='M33.342 12H1.338c6 0 11.627-12.002 16.002-12.002C21.715-.002 27.406 12 33.342 12z'/%3E%3C/svg%3E");background-size:100% auto;width:18px;height:6px;left:5px;margin-top:5px;top:100%;-webkit-transform:translateY(-10px);transform:translateY(-10px)}[data-balloon][data-balloon-pos=down-left]Line truncated
+46 -36
View File
@@ -31,50 +31,60 @@
poster: './img/poster.png',
subtitle: {
url: './subtitle/dw_trailer_low.vtt'
}
},
highlight: [
{
time: 20,
text: '这是第 20 秒'
},
{
time: 120,
text: '这是 2 分钟'
}
]
});
// player.layers.add({
// html: '23333',
// index: 999,
// name: 'test',
// style: {
// 'color': 'red'
// }
// }, dom => {
// console.log(dom)
// });
player.layers.add({
html: '23333',
index: 999,
name: 'test',
style: {
'color': 'red'
}
}, dom => {
console.log(dom)
});
// console.dir(Artplayer);
console.dir(Artplayer);
// console.log(player);
console.log(player);
// Artplayer.config.video.events.forEach(item => {
// player.on('video:' + item, event => {
// console.log('video', event);
// });
// });
Artplayer.config.video.events.forEach(item => {
player.on('video:' + item, event => {
console.log('video', event);
});
});
// 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>
+18 -39
View File
@@ -280,6 +280,7 @@
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), "'."));
}
var mimeCodec = {
@@ -584,11 +585,6 @@
$video.currentTime = newTime;
this.art.emit('seek', newTime);
}
}, {
key: "currentTime",
value: function currentTime() {
return this.art.refs.$video.currentTime;
}
}, {
key: "volume",
value: function volume(percentage) {
@@ -761,7 +757,6 @@
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(typeof option.html === 'string' || option.html instanceof Element, "'html' option require 'string' or 'Element' type, but got '".concat(_typeof_1(option.html), "'."));
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), "'."));
}
@@ -780,13 +775,6 @@
this.option = option;
};
var Highlight = function Highlight(art, option) {
classCallCheck(this, Highlight);
this.art = art;
this.option = option;
};
var Pip = function Pip(art, option) {
classCallCheck(this, Pip);
@@ -809,6 +797,7 @@
this.art = art;
this.option = option;
this.isDroging = false;
this.getLoaded = this.getLoaded.bind(this);
this.getPlayed = this.getPlayed.bind(this);
this.getPos = this.getPos.bind(this);
@@ -822,16 +811,25 @@
var _this = this;
var _this$art = this.art,
theme = _this$art.option.theme,
_this$art$option = _this$art.option,
highlight = _this$art$option.highlight,
theme = _this$art$option.theme,
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-indicator\" style=\"background: ").concat(theme, "\"></div>\n <div class=\"art-progress-timer\">00:00</div>\n </div>\n "));
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-timer\">00:00</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.$timer = this.option.ref.querySelector('.art-progress-timer');
this.art.on('video:canplay', function () {
_this.set('loaded', _this.getLoaded());
highlight.forEach(function (item) {
var left = Number(item.time) / $video.duration;
append(_this.$highlight, "<span data-text=\"".concat(item.text, "\" data-time=\"").concat(item.time, "\" style=\"left: ").concat(left * 100, "%\"></span>"));
});
});
this.art.on('video:progress', function () {
_this.set('loaded', _this.getLoaded());
@@ -868,7 +866,6 @@
player.seek(second);
}
});
this.isDroging = false;
proxy(this.$indicator, 'mousedown', function () {
_this.isDroging = true;
});
@@ -999,36 +996,24 @@
this.add({
control: Progress,
disable: false,
html: '',
position: 'top',
index: 10
});
this.add({
control: Highlight,
control: Screenshot,
disable: false,
html: '<div class="art-progress-highlight"></div>',
position: 'top',
index: 20
});
this.add({
control: Screenshot,
disable: false,
html: '<div class="art-progress-screenshot"></div>',
position: 'top',
index: 30
});
this.add({
control: PlayAndPause,
disable: false,
html: 'PlayAndPause',
tooltip: 'PlayAndPause',
position: 'left',
index: 10
});
this.add({
control: Volume,
disable: false,
html: 'Volume',
tooltip: 'Volume',
position: 'left',
index: 20
@@ -1036,7 +1021,6 @@
this.add({
control: Time,
disable: false,
html: 'Time',
tooltip: 'Volume',
position: 'left',
index: 30
@@ -1044,7 +1028,6 @@
this.add({
control: Danmu,
disable: false,
html: 'Danmu',
tooltip: 'Danmu',
position: 'right',
index: 10
@@ -1052,7 +1035,6 @@
this.add({
control: Subtitle,
disable: false,
html: 'Subtitle',
tooltip: 'Subtitle',
position: 'right',
index: 20
@@ -1060,7 +1042,6 @@
this.add({
control: Setting,
disable: false,
html: 'Setting',
tooltip: 'Setting',
position: 'right',
index: 30
@@ -1068,7 +1049,6 @@
this.add({
control: Pip,
disable: false,
html: 'Pip',
tooltip: 'Pip',
position: 'right',
index: 40
@@ -1076,7 +1056,6 @@
this.add({
control: Fullscreen,
disable: false,
html: 'Fullscreen',
tooltip: 'Fullscreen',
position: 'right',
index: 50
@@ -1096,8 +1075,6 @@
var $control = document.createElement('div');
$control.setAttribute('class', "art-control art-control-".concat(name));
$control.setAttribute('data-control-index', String(option.index) || id);
setStyle($control, option.style || {});
append($control, option.html);
option.ref = $control;
this.commonMethod(option);
this[name] = new option.control(this.art, option);
@@ -1787,8 +1764,9 @@
option = _this$art.option,
refs = _this$art.refs,
proxy = _this$art.events.proxy;
icons$1.play.style.backgroundColor = option.theme;
append(refs.$mask, icons$1.play);
var playClone = icons$1.play.cloneNode(true);
playClone.style.backgroundColor = option.theme;
append(refs.$mask, playClone);
proxy(refs.$mask, 'click', function () {
player.play();
@@ -1934,6 +1912,7 @@
style: {}
},
controls: [],
highlight: [],
lang: navigator.language.toLowerCase()
};
}
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"artplayer.js","sources":["../../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/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/isNativeFunction.js","../../node_modules/@babel/runtime/helpers/construct.js","../../node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/ArtPlayerError.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/mse.js","../../src/verification/control.js","../../src/controls/danmu.js","../../src/controls/fullscreen.js","../../src/controls/highlight.js","../../src/controls/pip.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/screenshot.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.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","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/icons/index.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/index.js"],"sourcesContent":["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, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nmodule.exports = _createClass;","function _typeof2(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof2(obj); }\n\nfunction _typeof(obj) {\n if (typeof Symbol === \"function\" && _typeof2(Symbol.iterator) === \"symbol\") {\n module.exports = _typeof = function _typeof(obj) {\n return _typeof2(obj);\n };\n } else {\n module.exports = _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : _typeof2(obj);\n };\n }\n\n return _typeof(obj);\n}\n\nmodule.exports = _typeof;","function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}\n\nmodule.exports = _assertThisInitialized;","var _typeof = require(\"../helpers/typeof\");\n\nvar assertThisInitialized = require(\"./assertThisInitialized\");\n\nfunction _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n }\n\n return assertThisInitialized(self);\n}\n\nmodule.exports = _possibleConstructorReturn;","function _getPrototypeOf(o) {\n module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nmodule.exports = _getPrototypeOf;","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 _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) Line truncated
{"version":3,"file":"artplayer.js","sources":["../../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/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/isNativeFunction.js","../../node_modules/@babel/runtime/helpers/construct.js","../../node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/ArtPlayerError.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/mse.js","../../src/verification/control.js","../../src/controls/danmu.js","../../src/controls/fullscreen.js","../../src/controls/pip.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/screenshot.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.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","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/icons/index.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/index.js"],"sourcesContent":["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, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nmodule.exports = _createClass;","function _typeof2(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof2(obj); }\n\nfunction _typeof(obj) {\n if (typeof Symbol === \"function\" && _typeof2(Symbol.iterator) === \"symbol\") {\n module.exports = _typeof = function _typeof(obj) {\n return _typeof2(obj);\n };\n } else {\n module.exports = _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : _typeof2(obj);\n };\n }\n\n return _typeof(obj);\n}\n\nmodule.exports = _typeof;","function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}\n\nmodule.exports = _assertThisInitialized;","var _typeof = require(\"../helpers/typeof\");\n\nvar assertThisInitialized = require(\"./assertThisInitialized\");\n\nfunction _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n }\n\n return assertThisInitialized(self);\n}\n\nmodule.exports = _possibleConstructorReturn;","function _getPrototypeOf(o) {\n module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nmodule.exports = _getPrototypeOf;","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 _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"SuperLine truncated
+1 -24
View File
@@ -1,8 +1,6 @@
import { append, setStyle } from '../utils';
import validControl from '../verification/control';
import Danmu from './danmu';
import Fullscreen from './fullscreen';
import Highlight from './highlight';
import Pip from './pip';
import PlayAndPause from './playAndPause';
import Progress from './progress';
@@ -29,32 +27,20 @@ export default class Controls {
this.add({
control: Progress,
disable: false,
html: '',
position: 'top',
index: 10
});
this.add({
control: Highlight,
control: Screenshot,
disable: false,
html: '<div class="art-progress-highlight"></div>',
position: 'top',
index: 20
});
this.add({
control: Screenshot,
disable: false,
html: '<div class="art-progress-screenshot"></div>',
position: 'top',
index: 30
});
this.add({
control: PlayAndPause,
disable: false,
html: 'PlayAndPause',
tooltip: 'PlayAndPause',
position: 'left',
index: 10
});
@@ -62,7 +48,6 @@ export default class Controls {
this.add({
control: Volume,
disable: false,
html: 'Volume',
tooltip: 'Volume',
position: 'left',
index: 20
@@ -71,7 +56,6 @@ export default class Controls {
this.add({
control: Time,
disable: false,
html: 'Time',
tooltip: 'Volume',
position: 'left',
index: 30
@@ -80,7 +64,6 @@ export default class Controls {
this.add({
control: Danmu,
disable: false,
html: 'Danmu',
tooltip: 'Danmu',
position: 'right',
index: 10
@@ -89,7 +72,6 @@ export default class Controls {
this.add({
control: Subtitle,
disable: false,
html: 'Subtitle',
tooltip: 'Subtitle',
position: 'right',
index: 20
@@ -98,7 +80,6 @@ export default class Controls {
this.add({
control: Setting,
disable: false,
html: 'Setting',
tooltip: 'Setting',
position: 'right',
index: 30
@@ -107,7 +88,6 @@ export default class Controls {
this.add({
control: Pip,
disable: false,
html: 'Pip',
tooltip: 'Pip',
position: 'right',
index: 40
@@ -116,7 +96,6 @@ export default class Controls {
this.add({
control: Fullscreen,
disable: false,
html: 'Fullscreen',
tooltip: 'Fullscreen',
position: 'right',
index: 50
@@ -135,8 +114,6 @@ export default class Controls {
const $control = document.createElement('div');
$control.setAttribute('class', `art-control art-control-${name}`);
$control.setAttribute('data-control-index', String(option.index) || id);
setStyle($control, option.style || {});
append($control, option.html);
option.ref = $control;
this.commonMethod(option);
this[name] = new option.control(this.art, option);
+21 -6
View File
@@ -4,6 +4,7 @@ export default class Progress {
constructor(art, option) {
this.art = art;
this.option = option;
this.isDroging = false;
this.getLoaded = this.getLoaded.bind(this);
this.getPlayed = this.getPlayed.bind(this);
this.getPos = this.getPos.bind(this);
@@ -12,24 +13,38 @@ export default class Progress {
}
init() {
const { option: { theme }, events: { proxy }, player } = this.art;
const {
option: { highlight, theme },
events: { proxy },
refs: { $video },
player
} = this.art;
append(this.option.ref, `
append(
this.option.ref,
`
<div class="art-control-progress-inner">
<div class="art-progress-loaded"></div>
<div class="art-progress-played" style="background: ${theme}"></div>
<div class="art-progress-highlight"></div>
<div class="art-progress-indicator" style="background: ${theme}"></div>
<div class="art-progress-timer">00:00</div>
</div>
`);
`
);
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.$timer = this.option.ref.querySelector('.art-progress-timer');
this.art.on('video:canplay', () => {
this.set('loaded', this.getLoaded());
highlight.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>`);
});
});
this.art.on('video:progress', () => {
@@ -64,7 +79,6 @@ export default class Progress {
}
});
this.isDroging = false;
proxy(this.$indicator, 'mousedown', () => {
this.isDroging = true;
});
@@ -103,7 +117,9 @@ export default class Progress {
getLoaded() {
const { $video } = this.art.refs;
return $video.buffered.length ? $video.buffered.end($video.buffered.length - 1) / $video.duration : 0;
return $video.buffered.length
? $video.buffered.end($video.buffered.length - 1) / $video.duration
: 0;
}
set(type, percentage) {
@@ -113,4 +129,3 @@ export default class Progress {
}
}
}
+1
View File
@@ -60,6 +60,7 @@ class Artplayer extends Emitter {
style: {}
},
controls: [],
highlight: [],
lang: navigator.language.toLowerCase()
};
}
+3 -2
View File
@@ -15,8 +15,9 @@ export default class Mask {
events: { proxy }
} = this.art;
icons.play.style.backgroundColor = option.theme;
append(refs.$mask, icons.play);
const playClone = icons.play.cloneNode(true);
playClone.style.backgroundColor = option.theme;
append(refs.$mask, playClone);
proxy(refs.$mask, 'click', () => {
player.play();
-4
View File
@@ -109,10 +109,6 @@ export default class Player {
this.art.emit('seek', newTime);
}
currentTime() {
return this.art.refs.$video.currentTime;
}
volume(percentage) {
const { $video } = this.art.refs;
if (percentage) {
+24 -7
View File
@@ -123,7 +123,6 @@
height: 5px;
padding: 1px 0;
cursor: pointer;
box-sizing: border-box;
.art-control-progress-inner {
position: relative;
@@ -131,7 +130,7 @@
background: rgba(255,255,255,.2);
.art-progress-loaded {
position: absolute;
z-index: 1;
z-index: 10;
left: 0;
top: 0;
right: 0;
@@ -139,25 +138,43 @@
height: 100%;
width: 0;
background: rgba(255,255,255,.4);
transform-origin: 0 0;
}
.art-progress-played {
position: absolute;
z-index: 2;
z-index: 20;
left: 0;
top: 0;
right: 0;
bottom: 0;
height: 100%;
width: 0;
transform-origin: 0 0;
}
.art-progress-highlight {
position: absolute;
z-index: 30;
left: 0;
top: 0;
right: 0;
bottom: 0;
height: 0;
span {
display: inline-block;
position: absolute;
left: 0;
top: 0;
width: 7px;
height: 3px;
background: #fff;
border-radius: 3px;
}
}
.art-progress-indicator {
display: none;
position: absolute;
z-index: 3;
z-index: 40;
top: -5px;
left: -6.5px;
width: 13px;
@@ -172,7 +189,7 @@
.art-progress-timer {
display: none;
position: absolute;
z-index: 4;
z-index: 50;
top: -25px;
left: 0;
width: 40px;
-5
View File
@@ -11,11 +11,6 @@ export default function validControl(option) {
`'disable' option require 'boolean' type, but got '${typeof option.disable}'.`
);
errorHandle(
typeof option.html === 'string' || option.html instanceof Element,
`'html' option require 'string' or 'Element' type, but got '${typeof option.html}'.`
);
errorHandle(
['top', 'left', 'right'].indexOf(option.position) > -1,
`'position' option require one of 'top、left、right', but got '${option.position}'.`
+5
View File
@@ -90,4 +90,9 @@ export default function validOption(option) {
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}'.`
);
}