mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 06:26:16 -08:00
typofix
This commit is contained in:
1 parent
54eb34d291
commit
813335e310
4 files changed
+7
-140
No files matched your search
+4
-134
@@ -706,136 +706,6 @@
|
||||
return Player;
|
||||
}();
|
||||
|
||||
var Mse =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Mse(art) {
|
||||
classCallCheck(this, Mse);
|
||||
|
||||
this.art = art;
|
||||
this.setMimeCodec();
|
||||
this.init();
|
||||
this.eventBind();
|
||||
this.eventStart();
|
||||
this.repeat = 0;
|
||||
this.maxRepeat = 5;
|
||||
}
|
||||
|
||||
createClass(Mse, [{
|
||||
key: "setMimeCodec",
|
||||
value: function setMimeCodec() {
|
||||
var option = this.art.option;
|
||||
|
||||
if (!option.type) {
|
||||
var type = getExt(option.url);
|
||||
errorHandle(Object.keys(config.mimeCodec).includes(type), "Can't find video's type '".concat(type, "' from '").concat(option.url, "'"));
|
||||
option.type = type;
|
||||
}
|
||||
|
||||
if (!option.mimeCodec) {
|
||||
var mimeCodec = config.mimeCodec[option.type];
|
||||
errorHandle(mimeCodec, "Can't find video's mimeCodec from ".concat(option.type));
|
||||
option.mimeCodec = mimeCodec;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "init",
|
||||
value: function init() {
|
||||
var _this$art = this.art,
|
||||
option = _this$art.option,
|
||||
$video = _this$art.refs.$video;
|
||||
errorHandle(MediaSource.isTypeSupported(option.mimeCodec), "Unsupported MIME type or codec: ".concat(option.mimeCodec));
|
||||
this.mediaSource = new MediaSource();
|
||||
$video.src = URL.createObjectURL(this.mediaSource);
|
||||
this.art.events.destroyEvents.push(function () {
|
||||
URL.revokeObjectURL($video.src);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "eventBind",
|
||||
value: function eventBind() {
|
||||
var _this = this;
|
||||
|
||||
var proxy = this.art.events.proxy;
|
||||
var _config$mse = config.mse,
|
||||
mediaSource = _config$mse.mediaSource,
|
||||
sourceBufferList = _config$mse.sourceBufferList;
|
||||
mediaSource.events.forEach(function (eventName) {
|
||||
proxy(_this.mediaSource, eventName, function (event) {
|
||||
_this.art.emit("mediaSource:".concat(event.type), event);
|
||||
});
|
||||
});
|
||||
sourceBufferList.events.forEach(function (eventName) {
|
||||
proxy(_this.mediaSource.sourceBuffers, eventName, function (event) {
|
||||
_this.art.emit("sourceBuffers:".concat(event.type), event);
|
||||
});
|
||||
proxy(_this.mediaSource.activeSourceBuffers, eventName, function (event) {
|
||||
_this.art.emit("activeSourceBuffers:".concat(event.type), event);
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "eventStart",
|
||||
value: function eventStart() {
|
||||
var _this2 = this;
|
||||
|
||||
var option = this.art.option;
|
||||
var proxy = this.art.events.proxy;
|
||||
var sourceBuffer = config.mse.sourceBuffer;
|
||||
this.art.on('mediaSource:sourceopen', function () {
|
||||
_this2.sourceBuffer = _this2.mediaSource.addSourceBuffer(option.mimeCodec);
|
||||
sourceBuffer.events.forEach(function (eventName) {
|
||||
proxy(_this2.sourceBuffer, eventName, function (event) {
|
||||
_this2.art.emit("sourceBuffer:".concat(event.type), event);
|
||||
});
|
||||
});
|
||||
});
|
||||
this.art.on('sourceBuffer:updateend', function () {
|
||||
_this2.mediaSource.endOfStream();
|
||||
});
|
||||
this.fetchUrl();
|
||||
}
|
||||
}, {
|
||||
key: "fetchUrl",
|
||||
value: function fetchUrl() {
|
||||
var _this3 = this;
|
||||
|
||||
var _this$art2 = this.art,
|
||||
url = _this$art2.option.url,
|
||||
notice = _this$art2.notice,
|
||||
i18n = _this$art2.i18n,
|
||||
loading = _this$art2.loading;
|
||||
this.art.emit('player:fetch:start', url);
|
||||
this.request(url).then(function (response) {
|
||||
_this3.sourceBuffer.appendBuffer(response);
|
||||
|
||||
_this3.art.emit('player:fetch:success', url);
|
||||
}).catch(function (err) {
|
||||
if (_this3.repeat++ < _this3.maxRepeat) {
|
||||
_this3.fetchUrl();
|
||||
} else {
|
||||
notice.show(i18n.get('Video load failed'));
|
||||
console.warn(err);
|
||||
loading.hide();
|
||||
|
||||
_this3.art.emit('player:fetch:failure', url);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "request",
|
||||
value: function request(url) {
|
||||
return fetch(url).then(function (response) {
|
||||
return response.arrayBuffer();
|
||||
}).catch(function (err) {
|
||||
throw new ArtPlayerError(err.message);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Mse;
|
||||
}();
|
||||
|
||||
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), "'."));
|
||||
@@ -1949,7 +1819,7 @@
|
||||
console.log(this);
|
||||
};
|
||||
|
||||
var Mse$1 = function Mse(art) {
|
||||
var Mse = function Mse(art) {
|
||||
classCallCheck(this, Mse);
|
||||
|
||||
this.art = art;
|
||||
@@ -1958,7 +1828,7 @@
|
||||
|
||||
var plugins = {
|
||||
Srt: Srt,
|
||||
Mse: Mse$1
|
||||
Mse: Mse
|
||||
};
|
||||
|
||||
var id$2 = 0;
|
||||
@@ -2008,8 +1878,7 @@
|
||||
this.i18n = new I18n(this);
|
||||
this.notice = new Notice(this);
|
||||
this.events = new Events(this);
|
||||
this.player = new Player(this); // this.mse = new Mse(this);
|
||||
|
||||
this.player = new Player(this);
|
||||
this.layers = new Layers(this);
|
||||
this.controls = new Controls(this);
|
||||
this.contextmenu = new Contextmenu(this);
|
||||
@@ -2053,6 +1922,7 @@
|
||||
var args = Array.from(arguments).slice(1);
|
||||
args.unshift(this);
|
||||
installedPlugins[name] = construct(Plugin, toConsumableArray(args));
|
||||
this.prototype.emit('use', Plugin);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -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/isNativeFunction.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/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","../../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/plugins/srt.js","../../src/plugins/mse.js","../../src/plugins/index.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;Line 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/isNativeFunction.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/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/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","../../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/plugins/srt.js","../../src/plugins/mse.js","../../src/plugins/index.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.defineLine truncated
|
||||
+1
-2
@@ -6,7 +6,6 @@ import Emitter from 'tiny-emitter';
|
||||
import Template from './template';
|
||||
import I18n from './i18n';
|
||||
import Player from './player';
|
||||
import Mse from './mse';
|
||||
import Controls from './controls';
|
||||
import Contextmenu from './contextmenu';
|
||||
import Danmu from './danmu';
|
||||
@@ -81,6 +80,7 @@ class Artplayer extends Emitter {
|
||||
const args = Array.from(arguments).slice(1);
|
||||
args.unshift(this);
|
||||
installedPlugins[name] = new Plugin(...args);
|
||||
this.prototype.emit('use', Plugin);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -102,7 +102,6 @@ class Artplayer extends Emitter {
|
||||
this.notice = new Notice(this);
|
||||
this.events = new Events(this);
|
||||
this.player = new Player(this);
|
||||
// this.mse = new Mse(this);
|
||||
this.layers = new Layers(this);
|
||||
this.controls = new Controls(this);
|
||||
this.contextmenu = new Contextmenu(this);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import Srt from './srt';
|
||||
import Mse from './mse';
|
||||
|
||||
const plugins = {
|
||||
export default {
|
||||
Srt,
|
||||
Mse
|
||||
};
|
||||
|
||||
export default plugins;
|
||||
Reference in new issue
Block a user