update common code

This commit is contained in:
Harvey Zack committed 2018-10-12 17:16:49 +08:00
1 parent 495782f5c6
commit 11bc295663
14 files changed
+59 -44

No files matched your search

+1
View File
@@ -0,0 +1 @@
.artplayer-wrap{position:relative;width:100%;height:100%;text-align:left}.artplayer-wrap .artplayer-controls,.artplayer-wrap .artplayer-layers,.artplayer-wrap .artplayer-loading,.artplayer-wrap .artplayer-notice,.artplayer-wrap .artplayer-poster,.artplayer-wrap .artplayer-video{position:absolute;left:0;top:0;right:0;bottom:0;width:100%;height:100%}
+1
View File
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.artplayer={})}(this,function(e){"use strict";var o=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e};function t(e,t){return e(t={exports:{}},t.exports),t.exports}var a=t(function(t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=r=function(e){return n(e)}:t.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},r(e)}t.exports=r});var s=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var u=function(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?s(e):t},c=t(function(t){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}t.exports=n}),f=t(function(n){function r(e,t){return n.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(e,t)}n.exports=r});var n=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)};var p=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},l=t(function(r){function o(e,t,n){return!function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?r.exports=o=function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&f(o,n.prototype),o}:r.exports=o=Reflect.construct,o.apply(null,arguments)}r.exports=o}),h=function(e){function r(e,t){var n;return o(this,r),n=u(this,c(r).call(this,e)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(s(n)),t||n.constructor),n.name="ArtPlayerError",n}return n(r,e),r}(t(function(t){function r(e){var n="function"==typeof Map?new Map:void 0;return t.exports=r=function(e){if(null===e||!p(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return l(e,arguments,c(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),f(t,e)},r(e)}t.exports=r})(Error));function d(e,t){if(!e)throw new h(t)}function v(){}v.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function o(){r.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),r=n[e],o=[];if(r&&t)for(var i=0,a=r.length;i<a;i++)r[i].fn!==t&&r[i].fn._!==t&&o.push(r[i]);return o.length?n[e]=o:delete n[e],this}};var y=v,m=function(){function t(e){o(this,t),this.art=e,this.init()}return i(t,[{key:"init",value:function(){this.art.refs.$container.innerHTML='\n <div class="artplayer-wrap">\n <video class="artplayer-video" webkit-playsinline playsinline></video>\n <div class="artplayer-controls"></div>\n <div class="artplayer-layers"></div>\n <div class="artplayer-loading"></div>\n <div class="artplayer-notice"></div>\n </div>\n ',this.art.refs.$wrap=this.art.refs.$container.querySelector(".artplayer-wrap"),this.art.refs.$video=this.art.refs.$container.querySelector(".artplayer-video"),this.art.refs.$controls=this.art.refs.$container.querySelector(".artplayer-controls"),this.art.refs.$layers=this.art.refs.$container.querySelector(".artplayer-layers"),this.art.refs.$loading=this.art.refs.$container.querySelector(".artplayer-loading"),this.art.refs.$notice=this.art.refs.$container.querySelector(".artplayer-notice")}}]),t}(),b={},g={zh:b,"zh-cn":b,"zh-tw":{},en:{},jp:{}},S=function(){function n(e){var t=e.option;o(this,n),this.language=g[t.lang.toLowerCase()]||g.en}return i(n,[{key:"get",value:function(e){return this.language[e]||e}}]),n}(),E=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadaLine truncated
+32 -27
View File
@@ -198,13 +198,17 @@
function (_Error) {
inherits(ArtPlayerError, _Error);
function ArtPlayerError(message) {
function ArtPlayerError(message, context) {
var _this;
classCallCheck(this, ArtPlayerError);
_this = possibleConstructorReturn(this, getPrototypeOf(ArtPlayerError).call(this, message));
Error.captureStackTrace(assertThisInitialized(assertThisInitialized(_this)), _this.constructor);
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(assertThisInitialized(assertThisInitialized(_this)), context || _this.constructor);
}
_this.name = 'ArtPlayerError';
return _this;
}
@@ -586,46 +590,46 @@
classCallCheck(this, Controls);
};
var Contextmenu = function Contextmenu(_ref) {//
var option = _ref.option;
var Contextmenu = function Contextmenu(art) {
classCallCheck(this, Contextmenu);
this.art = art;
};
var Danmu = function Danmu(_ref) {//
var option = _ref.option;
var Danmu = function Danmu(art) {
classCallCheck(this, Danmu);
this.art = art;
};
var Info = function Info(_ref) {//
var option = _ref.option;
var Info = function Info(art) {
classCallCheck(this, Info);
this.art = art;
};
var Captions = function Captions(_ref) {//
var Subtitle = function Subtitle(art) {
classCallCheck(this, Subtitle);
var option = _ref.option;
classCallCheck(this, Captions);
this.art = art;
};
var Events = function Events(_ref) {//
var option = _ref.option;
var Events = function Events(art) {
classCallCheck(this, Events);
this.art = art;
};
var Hotkey = function Hotkey(_ref) {//
var option = _ref.option;
var Hotkey = function Hotkey(art) {
classCallCheck(this, Hotkey);
this.art = art;
};
var Layers = function Layers(art) {
classCallCheck(this, Layers);
this.art = art;
};
var id = 0;
@@ -664,10 +668,11 @@
this.controls = new Controls(this);
this.contextmenu = new Contextmenu(this);
this.danmaku = new Danmu(this);
this.subtitle = new Captions(this);
this.subtitle = new Subtitle(this);
this.info = new Info(this);
this.events = new Events(this);
this.hotkey = new Hotkey(this);
this.layers = new Layers(this);
this.id = id++;
instances.push(this);
}
+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","../../node_modules/tiny-emitter/index.js","../../src/template.js","../../src/i18n/zh-CN.js","../../src/i18n/zh-TW.js","../../src/i18n/en.js","../../src/i18n/jp.js","../../src/i18n/index.js","../../src/utils/mediaElement.js","../../src/player.js","../../src/utils/mimeCodeces.js","../../src/utils/mseConfig.js","../../src/mse.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmaku.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.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(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\n\nmodule.exports = _isNativeFunction;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) 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","../../node_modules/tiny-emitter/index.js","../../src/template.js","../../src/i18n/zh-CN.js","../../src/i18n/zh-TW.js","../../src/i18n/en.js","../../src/i18n/jp.js","../../src/i18n/index.js","../../src/utils/mediaElement.js","../../src/player.js","../../src/utils/mimeCodeces.js","../../src/utils/mseConfig.js","../../src/mse.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmaku.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.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(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\n\nmodule.exports = _isNativeFunction;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" |Line truncated
+2 -2
View File
@@ -1,5 +1,5 @@
export default class Contextmenu {
constructor({ option }) {
//
constructor(art) {
this.art = art;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
export default class Danmu {
constructor({ option }) {
//
constructor(art) {
this.art = art;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
export default class Events {
constructor({ option }) {
//
constructor(art) {
this.art = art;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
export default class Hotkey {
constructor({ option }) {
//
constructor(art) {
this.art = art;
}
}
+2
View File
@@ -12,6 +12,7 @@ import Info from './info';
import Subtitle from './subtitle';
import Events from './events';
import Hotkey from './hotkey';
import Layers from './layers';
let id = 0;
export const instances = [];
@@ -77,6 +78,7 @@ class Artplayer extends Emitter {
this.info = new Info(this);
this.events = new Events(this);
this.hotkey = new Hotkey(this);
this.layers = new Layers(this);
this.id = id++;
instances.push(this);
+2 -2
View File
@@ -1,5 +1,5 @@
export default class Info {
constructor({ option }) {
//
constructor(art) {
this.art = art;
}
}
+5
View File
@@ -0,0 +1,5 @@
export default class Layers {
constructor(art) {
this.art = art;
}
}
-1
View File
@@ -85,7 +85,6 @@ export default class Mse {
this.art.on('mediaSource:sourceopen', () => {
this.sourceBuffer = this.mediaSource.addSourceBuffer(option.mimeCodec);
sourceBuffer.events.forEach(eventName => {
this.sourceBuffer.addEventListener(eventName, this.sourceBufferEventFn);
this.art.destroyEvents.push(() => {
+3 -3
View File
@@ -1,5 +1,5 @@
export default class Captions {
constructor({ option }) {
//
export default class Subtitle {
constructor(art) {
this.art = art;
}
}
+4 -2
View File
@@ -1,7 +1,9 @@
export default class ArtPlayerError extends Error {
constructor(message) {
constructor(message, context) {
super(message);
Error.captureStackTrace(this, this.constructor);
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, context || this.constructor);
}
this.name = 'ArtPlayerError';
}
}