mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 02:51:20 -08:00
更新url重连次数的刷新
This commit is contained in:
1 parent
a4876e6c73
commit
a84521cc98
6 files changed
+46
-30
No files matched your search
+26
-18
@@ -881,6 +881,7 @@
|
|||||||
if (promise !== undefined) {
|
if (promise !== undefined) {
|
||||||
promise.then().catch(function (err) {
|
promise.then().catch(function (err) {
|
||||||
notice.show(err, true, 3000);
|
notice.show(err, true, 3000);
|
||||||
|
console.warn(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -962,9 +963,12 @@
|
|||||||
$video = _this$art7.refs.$video,
|
$video = _this$art7.refs.$video,
|
||||||
i18n = _this$art7.i18n,
|
i18n = _this$art7.i18n,
|
||||||
notice = _this$art7.notice,
|
notice = _this$art7.notice,
|
||||||
isPlaying = _this$art7.isPlaying;
|
isPlaying = _this$art7.isPlaying,
|
||||||
|
option = _this$art7.option;
|
||||||
var currentTime = this.currentTime();
|
var currentTime = this.currentTime();
|
||||||
$video.src = url;
|
$video.src = url;
|
||||||
|
option.url = url;
|
||||||
|
this.reconnectTime = 0;
|
||||||
this.seek(currentTime);
|
this.seek(currentTime);
|
||||||
|
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
@@ -1810,7 +1814,7 @@
|
|||||||
var elink = document.createElement('a');
|
var elink = document.createElement('a');
|
||||||
setStyle(elink, 'display', 'none');
|
setStyle(elink, 'display', 'none');
|
||||||
elink.href = dataUri;
|
elink.href = dataUri;
|
||||||
elink.download = "".concat(secondToTime($video.currentTime), ".png");
|
elink.download = "ArtPlayer_".concat(secondToTime($video.currentTime), ".png");
|
||||||
document.body.appendChild(elink);
|
document.body.appendChild(elink);
|
||||||
elink.click();
|
elink.click();
|
||||||
document.body.removeChild(elink);
|
document.body.removeChild(elink);
|
||||||
@@ -1827,6 +1831,7 @@
|
|||||||
classCallCheck(this, Quality);
|
classCallCheck(this, Quality);
|
||||||
|
|
||||||
this.option = option;
|
this.option = option;
|
||||||
|
this.playIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
createClass(Quality, [{
|
createClass(Quality, [{
|
||||||
@@ -1834,34 +1839,36 @@
|
|||||||
value: function apply(art) {
|
value: function apply(art) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
this.art = art;
|
var $control = this.option.$control;
|
||||||
var _this$art = this.art,
|
var option = art.option,
|
||||||
option = _this$art.option,
|
_art$events = art.events,
|
||||||
_this$art$events = _this$art.events,
|
proxy = _art$events.proxy,
|
||||||
proxy = _this$art$events.proxy,
|
hover = _art$events.hover,
|
||||||
hover = _this$art$events.hover,
|
player = art.player;
|
||||||
player = _this$art.player;
|
|
||||||
var defaultQuality = option.quality.find(function (item) {
|
var defaultQuality = option.quality.find(function (item) {
|
||||||
return item.default;
|
return item.default;
|
||||||
}) || option.quality[0];
|
}) || option.quality[0];
|
||||||
var $qualityName = append(this.option.$control, "<div class=\"art-quality-name\">".concat(defaultQuality.name, "</div>"));
|
this.playIndex = option.quality.indexOf(defaultQuality);
|
||||||
|
var $qualityName = append($control, "<div class=\"art-quality-name\">".concat(defaultQuality.name, "</div>"));
|
||||||
var qualityList = option.quality.map(function (item, index) {
|
var qualityList = option.quality.map(function (item, index) {
|
||||||
return "<div class=\"art-quality-item\" data-index=\"".concat(index, "\">").concat(item.name, "</div>");
|
return "<div class=\"art-quality-item\" data-index=\"".concat(index, "\">").concat(item.name, "</div>");
|
||||||
}).join('');
|
}).join('');
|
||||||
var $qualitys = append(this.option.$control, "<div class=\"art-qualitys\">".concat(qualityList, "</div>"));
|
var $qualitys = append($control, "<div class=\"art-qualitys\">".concat(qualityList, "</div>"));
|
||||||
hover(this.option.$control, function () {
|
hover($control, function () {
|
||||||
_this.option.$control.classList.add('hover');
|
$control.classList.add('hover');
|
||||||
}, function () {
|
}, function () {
|
||||||
_this.option.$control.classList.remove('hover');
|
$control.classList.remove('hover');
|
||||||
});
|
});
|
||||||
proxy($qualitys, 'click', function (event) {
|
proxy($qualitys, 'click', function (event) {
|
||||||
var _option$quality$event = option.quality[event.target.dataset.index],
|
var index = Number(event.target.dataset.index);
|
||||||
url = _option$quality$event.url,
|
var _option$quality$index = option.quality[index],
|
||||||
name = _option$quality$event.name;
|
url = _option$quality$index.url,
|
||||||
|
name = _option$quality$index.name;
|
||||||
|
|
||||||
if (url && name) {
|
if (url && name && _this.playIndex !== index) {
|
||||||
player.switch(url, name);
|
player.switch(url, name);
|
||||||
$qualityName.innerHTML = name;
|
$qualityName.innerHTML = name;
|
||||||
|
_this.playIndex = index;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2934,6 +2941,7 @@
|
|||||||
controls: [],
|
controls: [],
|
||||||
highlight: [],
|
highlight: [],
|
||||||
moreVideoAttr: {
|
moreVideoAttr: {
|
||||||
|
'crossOrigin': 'anonymous',
|
||||||
'controls': false,
|
'controls': false,
|
||||||
'preload': 'auto',
|
'preload': 'auto',
|
||||||
'webkit-playsinline': true,
|
'webkit-playsinline': true,
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"artplayer.js","sources":["../../node_modules/@babel/runtime/helpers/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/construct.js","../../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArray.js","../../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../../node_modules/@babel/runtime/helpers/toConsumableArray.js","../../node_modules/@babel/runtime/helpers/classCallCheck.js","../../node_modules/@babel/runtime/helpers/createClass.js","../../node_modules/@babel/runtime/helpers/typeof.js","../../node_modules/@babel/runtime/helpers/assertThisInitialized.js","../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/defineProperty.js","../../node_modules/@babel/runtime/helpers/objectSpread.js","../../node_modules/@babel/runtime/helpers/isNativeFunction.js","../../node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/index.js","../../node_modules/option-validator/dist/option-validator.js","../../src/scheme/validElement.js","../../src/scheme/index.js","../../src/config/mimeCodec.js","../../src/config/mse.js","../../src/config/video.js","../../src/config/index.js","../../node_modules/tiny-emitter/index.js","../../src/template.js","../../src/i18n.js","../../src/player.js","../../src/controls/danmu.js","../../src/controls/fullscreen.js","../../src/controls/fullscreen-web.js","../../src/controls/pip.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/icons/index.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/thumbnails.js","../../src/controls/screenshot.js","../../src/controls/quality.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/index.js"],"sourcesContent":["function _setPrototypeOf(o, p) {\n module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nmodule.exports = _setPrototypeOf;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _construct(Parent, args, Class) {\n if (isNativeReflectConstruct()) {\n module.exports = _construct = Reflect.construct;\n } else {\n module.exports = _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\n\nmodule.exports = _construct;","function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}\n\nmodule.exports = _arrayWithoutHoles;","function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}\n\nmodule.exports = _nonIterableSpread;","var arrayWithoutHoles = require(\"./arrayWithoutHoles\");\n\nvar iterableToArray = require(\"./iterableToArray\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptoLine truncated
|
{"version":3,"file":"artplayer.js","sources":["../../node_modules/@babel/runtime/helpers/setPrototypeOf.js","../../node_modules/@babel/runtime/helpers/construct.js","../../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../../node_modules/@babel/runtime/helpers/iterableToArray.js","../../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../../node_modules/@babel/runtime/helpers/toConsumableArray.js","../../node_modules/@babel/runtime/helpers/classCallCheck.js","../../node_modules/@babel/runtime/helpers/createClass.js","../../node_modules/@babel/runtime/helpers/typeof.js","../../node_modules/@babel/runtime/helpers/assertThisInitialized.js","../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../../node_modules/@babel/runtime/helpers/inherits.js","../../node_modules/@babel/runtime/helpers/defineProperty.js","../../node_modules/@babel/runtime/helpers/objectSpread.js","../../node_modules/@babel/runtime/helpers/isNativeFunction.js","../../node_modules/@babel/runtime/helpers/wrapNativeSuper.js","../../src/utils/index.js","../../node_modules/option-validator/dist/option-validator.js","../../src/scheme/validElement.js","../../src/scheme/index.js","../../src/config/mimeCodec.js","../../src/config/mse.js","../../src/config/video.js","../../src/config/index.js","../../node_modules/tiny-emitter/index.js","../../src/template.js","../../src/i18n.js","../../src/player.js","../../src/controls/danmu.js","../../src/controls/fullscreen.js","../../src/controls/fullscreen-web.js","../../src/controls/pip.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/icons/index.js","../../src/controls/playAndPause.js","../../src/controls/progress.js","../../src/controls/subtitle.js","../../src/controls/time.js","../../src/controls/volume.js","../../src/controls/setting.js","../../src/controls/thumbnails.js","../../src/controls/screenshot.js","../../src/controls/quality.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.js","../../src/subtitle.js","../../src/events.js","../../src/hotkey.js","../../src/layers.js","../../src/loading.js","../../src/notice.js","../../src/mask.js","../../src/index.js"],"sourcesContent":["function _setPrototypeOf(o, p) {\n module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nmodule.exports = _setPrototypeOf;","var setPrototypeOf = require(\"./setPrototypeOf\");\n\nfunction isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _construct(Parent, args, Class) {\n if (isNativeReflectConstruct()) {\n module.exports = _construct = Reflect.construct;\n } else {\n module.exports = _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\n\nmodule.exports = _construct;","function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}\n\nmodule.exports = _arrayWithoutHoles;","function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}\n\nmodule.exports = _nonIterableSpread;","var arrayWithoutHoles = require(\"./arrayWithoutHoles\");\n\nvar iterableToArray = require(\"./iterableToArray\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptoLine truncated
|
||||||
+13
-9
@@ -3,27 +3,31 @@ import { append } from '../utils';
|
|||||||
export default class Quality {
|
export default class Quality {
|
||||||
constructor(option) {
|
constructor(option) {
|
||||||
this.option = option;
|
this.option = option;
|
||||||
|
this.playIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(art) {
|
apply(art) {
|
||||||
this.art = art;
|
const { $control } = this.option;
|
||||||
const { option, events: { proxy, hover }, player } = this.art;
|
const { option, events: { proxy, hover }, player } = art;
|
||||||
const defaultQuality = option.quality.find(item => item.default) || option.quality[0];
|
const defaultQuality = option.quality.find(item => item.default) || option.quality[0];
|
||||||
const $qualityName = append(this.option.$control, `<div class="art-quality-name">${defaultQuality.name}</div>`);
|
this.playIndex = option.quality.indexOf(defaultQuality);
|
||||||
|
const $qualityName = append($control, `<div class="art-quality-name">${defaultQuality.name}</div>`);
|
||||||
const qualityList = option.quality.map((item, index) => `<div class="art-quality-item" data-index="${index}">${item.name}</div>`).join('');
|
const qualityList = option.quality.map((item, index) => `<div class="art-quality-item" data-index="${index}">${item.name}</div>`).join('');
|
||||||
const $qualitys = append(this.option.$control, `<div class="art-qualitys">${qualityList}</div>`);
|
const $qualitys = append($control, `<div class="art-qualitys">${qualityList}</div>`);
|
||||||
|
|
||||||
hover(this.option.$control, () => {
|
hover($control, () => {
|
||||||
this.option.$control.classList.add('hover');
|
$control.classList.add('hover');
|
||||||
}, () => {
|
}, () => {
|
||||||
this.option.$control.classList.remove('hover');
|
$control.classList.remove('hover');
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy($qualitys, 'click', event => {
|
proxy($qualitys, 'click', event => {
|
||||||
const { url, name } = option.quality[event.target.dataset.index];
|
const index = Number(event.target.dataset.index);
|
||||||
if (url && name) {
|
const { url, name } = option.quality[index];
|
||||||
|
if (url && name && this.playIndex !== index) {
|
||||||
player.switch(url, name);
|
player.switch(url, name);
|
||||||
$qualityName.innerHTML = name;
|
$qualityName.innerHTML = name;
|
||||||
|
this.playIndex = index;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default class Screenshot {
|
|||||||
const elink = document.createElement('a');
|
const elink = document.createElement('a');
|
||||||
setStyle(elink, 'display', 'none');
|
setStyle(elink, 'display', 'none');
|
||||||
elink.href = dataUri;
|
elink.href = dataUri;
|
||||||
elink.download = `${secondToTime($video.currentTime)}.png`;
|
elink.download = `ArtPlayer_${secondToTime($video.currentTime)}.png`;
|
||||||
document.body.appendChild(elink);
|
document.body.appendChild(elink);
|
||||||
elink.click();
|
elink.click();
|
||||||
document.body.removeChild(elink);
|
document.body.removeChild(elink);
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ class Artplayer extends Emitter {
|
|||||||
controls: [],
|
controls: [],
|
||||||
highlight: [],
|
highlight: [],
|
||||||
moreVideoAttr: {
|
moreVideoAttr: {
|
||||||
|
'crossOrigin': 'anonymous',
|
||||||
'controls': false,
|
'controls': false,
|
||||||
'preload': 'auto',
|
'preload': 'auto',
|
||||||
'webkit-playsinline': true,
|
'webkit-playsinline': true,
|
||||||
|
|||||||
+4
-1
@@ -121,6 +121,7 @@ export default class Player {
|
|||||||
if (promise !== undefined) {
|
if (promise !== undefined) {
|
||||||
promise.then().catch(err => {
|
promise.then().catch(err => {
|
||||||
notice.show(err, true, 3000);
|
notice.show(err, true, 3000);
|
||||||
|
console.warn(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
notice.show(i18n.get('Play'));
|
notice.show(i18n.get('Play'));
|
||||||
@@ -175,9 +176,11 @@ export default class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch(url, name = 'Unknown') {
|
switch(url, name = 'Unknown') {
|
||||||
const { refs: { $video }, i18n, notice, isPlaying } = this.art;
|
const { refs: { $video }, i18n, notice, isPlaying, option } = this.art;
|
||||||
const currentTime = this.currentTime();
|
const currentTime = this.currentTime();
|
||||||
$video.src = url;
|
$video.src = url;
|
||||||
|
option.url = url;
|
||||||
|
this.reconnectTime = 0;
|
||||||
this.seek(currentTime);
|
this.seek(currentTime);
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
this.play();
|
this.play();
|
||||||
|
|||||||
Reference in new issue
Block a user