This commit is contained in:
Harvey Zack committed 2018-10-17 20:52:13 +08:00
1 parent 5f6febce42
commit b2159e7d4d
9 files changed
+64 -61

No files matched your search

+26 -28
View File
@@ -238,6 +238,21 @@
return url.trim().toLowerCase().split('.').pop();
}
function append(parent, child) {
if (child instanceof Element) {
parent.appendChild(child);
} else {
parent.innerHTML = child;
}
return parent;
}
function setStyle(element, styles) {
Object.keys(styles).forEach(function (key) {
element.style[key] = styles[key];
});
return element;
}
function verification(option) {
errorHandle(option.container, '\'container\' option is required.');
@@ -794,9 +809,9 @@
});
}
refs.$contextmenu.appendChild($menu);
append(refs.$contextmenu, $menu);
});
refs.$wrap.appendChild(refs.$contextmenu);
append(refs.$wrap, refs.$contextmenu);
}
}, {
key: "setPos",
@@ -947,9 +962,7 @@
_this$art$refs = _this$art.refs,
$video = _this$art$refs.$video,
$subtitle = _this$art$refs.$subtitle;
Object.keys(subtitleStyle).forEach(function (key) {
$subtitle.style[key] = subtitleStyle[key];
});
setStyle($subtitle, subtitleStyle);
var $track = document.createElement('track');
$track.default = true;
$track.kind = 'metadata';
@@ -1145,19 +1158,8 @@
$layer.setAttribute('data-art-layer-id', id);
$layer.setAttribute('class', "art-layer art-layer-".concat(option.name || id));
$layer.style.zIndex = option.index || id;
if (option.html instanceof Element) {
$layer.appendChild(option.html);
} else {
$layer.innerHTML = option.html;
}
if (option.style) {
Object.keys(option.style).forEach(function (key) {
$layer.style[key] = option.style[key];
});
}
append($layer, option.html);
setStyle($layer, option.style || {});
refs.$layers.appendChild($layer);
callback && callback($layer);
}
@@ -1180,7 +1182,7 @@
var play = "<svg id=\"plyr-play\" width=\"16px\" height=\"18px\">\n <path d=\"M15.562 8.1L3.87.225C3.052-.337 2 .225 2 1.125v15.75c0 .9 1.052 1.462 1.87.9L15.563 9.9c.584-.45.584-1.35 0-1.8z\"></path>\n</svg>\n";
var Icons = {
var icons = {
loading: loading,
play: play
};
@@ -1198,7 +1200,7 @@
return result;
}
var Icons$1 = creatDomFromSvg(Icons);
var icons$1 = creatDomFromSvg(icons);
var Loading =
/*#__PURE__*/
@@ -1218,13 +1220,9 @@
$loading = _this$art.refs.$loading;
if (option.loading) {
if (option.loading instanceof Element) {
$loading.appendChild(option.loading);
} else {
$loading.innerHTML = option.loading;
}
append($loading, option.loading);
} else {
$loading.appendChild(Icons$1.loading);
append($loading, icons$1.loading);
}
}
}, {
@@ -1299,8 +1297,8 @@
option = _this$art.option,
refs = _this$art.refs,
proxy = _this$art.events.proxy;
Icons$1.play.style.backgroundColor = option.theme;
refs.$mask.appendChild(Icons$1.play);
icons$1.play.style.backgroundColor = option.theme;
append(refs.$mask, icons$1.play);
proxy(refs.$mask, 'click', function () {
player.play();
+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/utils/verification.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/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(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}\n\nmodule.exports = _inherits;","function _isNativeFunction(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/utils/verification.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/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(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}\n\nmodule.exports = _inherits;","function _isNativeFunction(Line truncated
+4 -2
View File
@@ -1,3 +1,5 @@
import { append } from './utils';
export default class Contextmenu {
constructor(art) {
this.art = art;
@@ -75,9 +77,9 @@ export default class Contextmenu {
this.hide();
});
}
refs.$contextmenu.appendChild($menu);
append(refs.$contextmenu, $menu);
});
refs.$wrap.appendChild(refs.$contextmenu);
append(refs.$wrap, refs.$contextmenu);
}
setPos(event) {
+2 -2
View File
@@ -1,7 +1,7 @@
import loading from './loading.svg';
import play from './play.svg';
const Icons = {
const icons = {
loading,
play
};
@@ -16,4 +16,4 @@ function creatDomFromSvg(map) {
return result;
}
export default creatDomFromSvg(Icons);
export default creatDomFromSvg(icons);
+4 -13
View File
@@ -1,3 +1,5 @@
import { append, setStyle } from './utils';
let id = 0;
export default class Layers {
constructor(art) {
@@ -24,19 +26,8 @@ export default class Layers {
$layer.setAttribute('data-art-layer-id', id);
$layer.setAttribute('class', `art-layer art-layer-${option.name || id}`);
$layer.style.zIndex = option.index || id;
if (option.html instanceof Element) {
$layer.appendChild(option.html);
} else {
$layer.innerHTML = option.html;
}
if (option.style) {
Object.keys(option.style).forEach(key => {
$layer.style[key] = option.style[key];
});
}
append($layer, option.html);
setStyle($layer, option.style || {});
refs.$layers.appendChild($layer);
callback && callback($layer);
}
+4 -7
View File
@@ -1,4 +1,5 @@
import Icons from './icons';
import icons from './icons';
import { append } from './utils';
export default class Loading {
constructor(art) {
@@ -9,13 +10,9 @@ export default class Loading {
init() {
const { option, refs: { $loading } } = this.art;
if (option.loading) {
if (option.loading instanceof Element) {
$loading.appendChild(option.loading);
} else {
$loading.innerHTML = option.loading;
}
append($loading, option.loading);
} else {
$loading.appendChild(Icons.loading);
append($loading, icons.loading);
}
}
+4 -3
View File
@@ -1,4 +1,5 @@
import Icons from './icons';
import icons from './icons';
import { append } from './utils';
export default class Mask {
constructor(art) {
@@ -14,8 +15,8 @@ export default class Mask {
events: { proxy }
} = this.art;
Icons.play.style.backgroundColor = option.theme;
refs.$mask.appendChild(Icons.play);
icons.play.style.backgroundColor = option.theme;
append(refs.$mask, icons.play);
proxy(refs.$mask, 'click', () => {
player.play();
+2 -5
View File
@@ -1,4 +1,4 @@
import { errorHandle, getExt } from './utils';
import { errorHandle, getExt, setStyle } from './utils';
export default class Subtitle {
constructor(art) {
@@ -19,10 +19,7 @@ export default class Subtitle {
refs: { $video, $subtitle }
} = this.art;
Object.keys(subtitleStyle).forEach(key => {
$subtitle.style[key] = subtitleStyle[key];
});
setStyle($subtitle, subtitleStyle);
const $track = document.createElement('track');
$track.default = true;
$track.kind = 'metadata';
+17
View File
@@ -29,3 +29,20 @@ export function getExt(url) {
.split('.')
.pop();
}
export function append(parent, child) {
if (child instanceof Element) {
parent.appendChild(child);
} else {
parent.innerHTML = child;
}
return parent;
}
export function setStyle(element, styles) {
Object.keys(styles).forEach(key => {
element.style[key] = styles[key];
});
return element;
}