add Artplayer.LOG_VERSION

This commit is contained in:
Harvey Zack committed 2023-08-22 20:51:39 +08:00
1 parent 3179d1241e
commit 894a9db1d7
34 files changed
+182 -136

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- 更新组件时,支持填写只更新的字段 [pull/549](https://github.com/zhw2590582/ArtPlayer/pull/549)
- 当 `autoPlayback` 和 `autoplay` 同时为 `true` 时,会自动跳转播放
- 添加 `muted` 事件,当静音的状态变化时触发
- 添加 `Artplayer.LOG_VERSION` 全局配置,设置是否打印播放器版本,默认为 `true`
## [5.0.9] - 2023-5-14
+76 -68
View File
@@ -236,13 +236,13 @@ class Artplayer extends (0, _emitterDefault.default) {
return instances;
}
static get version() {
return "5.0.9";
return "5.1.0";
}
static get env() {
return "development";
}
static get build() {
return "2023-05-18 11:30:49";
return "2023-08-22 20:37:01";
}
static get config() {
return 0, _configDefault.default;
@@ -396,6 +396,7 @@ Artplayer.FLIP = [
"vertical"
];
Artplayer.FULLSCREEN_WEB_IN_BODY = false;
Artplayer.LOG_VERSION = true;
if (typeof document !== "undefined") {
if (!document.getElementById("artplayer-style")) {
const $style = _utils.createElement("style");
@@ -405,7 +406,9 @@ if (typeof document !== "undefined") {
}
}
if (typeof window !== "undefined") window["Artplayer"] = Artplayer;
console.log(`%c ArtPlayer %c ${Artplayer.version} %c https://artplayer.org`, "color: #fff; background: #5f5f5f", "color: #fff; background: #4bc729", "");
setTimeout(()=>{
if (Artplayer.LOG_VERSION) console.log(`%c ArtPlayer %c ${Artplayer.version} %c https://artplayer.org`, "color: #fff; background: #5f5f5f", "color: #fff; background: #4bc729", "");
});
},{"bundle-text:./style/index.less":"SvnDa","option-validator":"2tbdu","./utils/emitter":"elSLF","./utils":"jmgNb","./scheme":"gL38d","./config":"2ZnKD","./template":"bDTDS","./i18n":"k0CtI","./player":"35XKf","./control":"faO0X","./contextmenu":"5npaZ","./info":"6vVKE","./subtitle":"4exyO","./events":"dz5ul","./hotkey":"1nFqF","./layer":"fvy8V","./loading":"h8KPY","./notice":"cr1XY","./mask":"llnR4","./icons":"gP6M7","./setting":"e5Aaq","./storage":"feFxw","./plugins":"h1hfO","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"SvnDa":[function(require,module,exports) {
module.exports = ".art-video-player {\n --art-theme: red;\n --art-font-color: #fff;\n --art-background-color: #000;\n --art-text-shadow-color: #00000080;\n --art-transition-duration: .2s;\n --art-padding: 10px;\n --art-border-radius: 3px;\n --art-progress-height: 6px;\n --art-progress-color: #fff3;\n --art-hover-color: #ffffff80;\n --art-loaded-color: #fff3;\n --art-loop-color: #ffffffbf;\n --art-state-size: 80px;\n --art-state-opacity: .8;\n --art-bottom-height: 100px;\n --art-bottom-offset: 20px;\n --art-bottom-gap: 5px;\n --art-highlight-width: 8px;\n --art-highlight-color: #ffffff80;\n --art-loop-width: 2px;\n --art-control-height: 46px;\n --art-control-opacity: .75;\n --art-control-icon-size: 36px;\n --art-control-icon-scale: 1.1;\n --art-volume-height: 120px;\n --art-volume-handle-size: 14px;\n --art-lock-size: 36px;\n --art-indicator-scale: 0;\n --art-indicator-size: 16px;\n --art-fullscreen-web-index: 9999;\n --art-settings-icon-size: 24px;\n --art-settings-max-height: 300px;\n --art-selector-max-height: 300px;\n --art-contextmenus-min-width: 250px;\n --art-subtitle-font-size: 20px;\n --art-subtitle-gap: 5px;\n --art-subtitle-bottom: 15px;\n --art-subtitle-border: #000;\n --art-widget-background: #000000d9;\n --art-tip-background: #00000080;\n --art-scrollbar-size: 4px;\n --art-scrollbar-background: #ffffff40;\n --art-scrollbar-background-hover: #ffffff80;\n --art-mini-progress-height: 2px;\n}\n\n.art-bg-cover {\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n}\n\n.art-bottom-gradient {\n background-image: linear-gradient(to top, #000, #0006, #0000);\n background-position: bottom;\n background-repeat: repeat-x;\n}\n\n.art-backdrop-filter {\n -webkit-backdrop-filter: saturate(180%) blur(20px);\n backdrop-filter: saturate(180%) blur(20px);\n background-color: #000000bf !important;\n}\n\n.art-truncate {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n\n.art-video-player {\n width: 100%;\n height: 100%;\n zoom: 1;\n text-align: left;\n direction: ltr;\n user-select: none;\n box-sizing: border-box;\n color: var(--art-font-color);\n background-color: var(--art-background-color);\n text-shadow: 0 0 2px var(--art-text-shadow-color);\n -webkit-tap-highlight-color: #0000;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n -ms-high-contrast-adjust: none;\n outline: 0;\n margin: 0 auto;\n padding: 0;\n font-family: PingFang SC, Helvetica Neue, Microsoft YaHei, Roboto, Arial, sans-serif;\n font-size: 14px;\n line-height: 1.3;\n position: relative;\n}\n\n.art-video-player *, .art-video-player :before, .art-video-player :after {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n\n.art-video-player ::-webkit-scrollbar {\n width: var(--art-scrollbar-size);\n height: var(--art-scrollbar-size);\n}\n\n.art-video-player ::-webkit-scrollbar-thumb {\n background-color: var(--art-scrollbar-background);\n}\n\n.art-video-player ::-webkit-scrollbar-thumb:hover {\n background-color: var(--art-scrollbar-background-hover);\n}\n\n.art-video-player img {\n max-width: 100%;\n vertical-align: top;\n}\n\n.art-video-player svg {\n fill: var(--art-font-color);\n}\n\n.art-video-player a {\n color: var(--art-font-color);\n text-decoration: none;\n}\n\n.art-icon {\n justify-content: center;\n align-items: center;\n line-height: 1;\n display: flex;\n}\n\n.art-video-player.art-backdrop .art-contextmenus, .art-video-player.art-backdrop .art-info, .art-video-player.art-backdrop .art-settings, .art-video-player.art-backdrop .art-layer-auto-playback, .art-video-player.art-backdrop .art-selector-list, .art-video-player.art-backdrop .art-volume-inner {\n -webkit-backdrop-filter: saturate(180%) blur(20px);\n backdrop-filter: saturate(180%) blur(20px);\n background-color: #000000bf !important;\n}\n\n.art-video {\n z-index: 10;\n width: 100%;\n height: 100%;\n cursor: pointer;\n position: absolute;\n inset: 0;\n}\n\n.art-poster {\n z-index: 11;\n width: 100%;\n height: 100%;\n pointer-events: none;\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n position: absolute;\n inset: 0;\n}\n\n.art-video-player .art-subtitle {\n z-index: 20;\n width: 100%;\n text-align: center;\n pointer-events: none;\n justify-content: center;\n align-items: center;\n gap: var(--art-subtitle-gap);\n bottom: var(--art-subtitle-bottom);\n font-size: var(--art-subtitle-font-size);\n transition: bottom var(--art-transition-duration) ease;\n text-shadow: var(--art-subtitle-border) 1px 0 1px, var(--art-subtitle-border) 0 1px 1px, var(--art-subtitle-border) -1px 0 1px, var(--art-subtitle-border) 0 -1px 1px, var(--art-subtitle-border) 1px 1px 1px, var(--art-subtitle-border) -1px -1px 1px, var(--art-subtitle-border) 1px -1px 1px, var(--art-subtitle-border) -1px 1px 1px;\n flex-direction: column;\n padding: 0 5%;\n display: none;\nLine truncated
@@ -558,8 +561,8 @@ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
class Emitter {
on(name, fn, ctx) {
const e = this.e || (this.e = {});
(e[name] || (e[name] = [])).push({
const e = this.e ?? (this.e = {});
(e[name] ?? (e[name] = [])).push({
fn,
ctx
});
@@ -575,12 +578,12 @@ class Emitter {
return this.on(name, listener, ctx);
}
emit(name, ...data) {
const evtArr = ((this.e || (this.e = {}))[name] || []).slice();
const evtArr = ((this.e ?? (this.e = {}))[name] ?? []).slice();
for(let i = 0; i < evtArr.length; i += 1)evtArr[i].fn.apply(evtArr[i].ctx, data);
return this;
}
off(name, callback) {
const e = this.e || (this.e = {});
const e = this.e ?? (this.e = {});
const evts = e[name];
const liveEvents = [];
if (evts && callback) {
@@ -683,7 +686,7 @@ function hasClass(target, className) {
function append(parent, child) {
if (child instanceof Element) parent.appendChild(child);
else parent.insertAdjacentHTML("beforeend", String(child));
return parent.lastElementChild || parent.lastChild;
return parent.lastElementChild ?? parent.lastChild;
}
function remove(child) {
return child.parentNode.removeChild(child);
@@ -715,8 +718,8 @@ function tooltip(target, msg, pos = "top") {
}
function isInViewport(el, offset = 0) {
const rect = el.getBoundingClientRect();
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
const windowHeight = window.innerHeight ?? document.documentElement.clientHeight;
const windowWidth = window.innerWidth ?? document.documentElement.clientWidth;
const vertInView = rect.top - offset <= windowHeight && rect.top + rect.height + offset >= 0;
const horInView = rect.left - offset <= windowWidth + offset && rect.left + rect.width + offset >= 0;
return vertInView && horInView;
@@ -756,8 +759,8 @@ const isWechat = /MicroMessenger/i.test(userAgent);
const isIE = /MSIE|Trident/i.test(userAgent);
const isAndroid = /android/i.test(userAgent);
const isIOS = /iPad|iPhone|iPod/i.test(userAgent) && !window.MSStream;
const isIOS13 = isIOS || userAgent.includes("Macintosh") && navigator.maxTouchPoints >= 1;
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) || isIOS13;
const isIOS13 = isIOS ?? (userAgent.includes("Macintosh") && navigator.maxTouchPoints >= 1);
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) ?? isIOS13;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"622b3":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
@@ -767,7 +770,7 @@ parcelHelpers.export(exports, "errorHandle", ()=>errorHandle);
class ArtPlayerError extends Error {
constructor(message, context){
super(message);
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, context || this.constructor);
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, context ?? this.constructor);
this.name = "ArtPlayerError";
}
}
@@ -929,6 +932,7 @@ function isStringOrNumber(val) {
].includes(typeof val);
}
function secondToTime(second) {
if (!second) return "00:00";
const add0 = (num)=>num < 10 ? `0${num}` : String(num);
const hour = Math.floor(second / 3600);
const min = Math.floor((second - hour * 3600) / 60);
@@ -949,7 +953,7 @@ function escape(str) {
">": "&gt;",
"'": "&#39;",
'"': "&quot;"
})[tag] || tag);
})[tag] ?? tag);
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"gL38d":[function(require,module,exports) {
@@ -964,7 +968,7 @@ const n = "number";
const o = "object";
const f = "function";
function validElement(value, type, paths) {
return (0, _utils.errorHandle)(type === s || type === n || value instanceof Element, `${paths.join(".")} require '${s}' or 'Element' type`);
return (0, _utils.errorHandle)((type === s) ?? type === n ?? value instanceof Element, `${paths.join(".")} require '${s}' or 'Element' type`);
}
const ComponentOption = {
html: validElement,
@@ -1221,7 +1225,7 @@ class Template {
<div class="art-info-panel">
<div class="art-info-item">
<div class="art-info-title">Player version:</div>
<div class="art-info-content">${"5.0.9"}</div>
<div class="art-info-content">${"5.1.0"}</div>
</div>
<div class="art-info-item">
<div class="art-info-title">Video url:</div>
@@ -1331,10 +1335,10 @@ class I18n {
}
init() {
const lang = this.art.option.lang.toLowerCase();
this.language = this.languages[lang] || {};
this.language = this.languages[lang] ?? {};
}
get(key) {
return this.language[key] || key;
return this.language[key] ?? key;
}
update(value) {
this.languages = (0, _utils.mergeDeep)(this.languages, value);
@@ -1497,7 +1501,7 @@ function urlMix(art) {
async set (newUrl) {
if (newUrl) {
const oldUrl = art.url;
const typeName = option.type || (0, _utils.getExt)(newUrl);
const typeName = option.type ?? (0, _utils.getExt)(newUrl);
const typeCallback = option.customType[typeName];
if (typeName && typeCallback) {
await (0, _utils.sleep)();
@@ -1622,7 +1626,7 @@ var _utils = require("../utils");
function volumeMix(art) {
const { template: { $video } , i18n , notice , storage } = art;
(0, _utils.def)(art, "volume", {
get: ()=>$video.volume || 0,
get: ()=>$video.volume ?? 0,
set: (percentage)=>{
$video.volume = (0, _utils.clamp)(percentage, 0, 1);
notice.show = `${i18n.get("Volume")}: ${parseInt($video.volume * 100, 10)}`;
@@ -1633,6 +1637,7 @@ function volumeMix(art) {
get: ()=>$video.muted,
set: (muted)=>{
$video.muted = muted;
art.emit("muted", muted);
}
});
}
@@ -1645,7 +1650,7 @@ var _utils = require("../utils");
function currentTimeMix(art) {
const { $video } = art.template;
(0, _utils.def)(art, "currentTime", {
get: ()=>$video.currentTime || 0,
get: ()=>$video.currentTime ?? 0,
set: (time)=>{
time = parseFloat(time);
if (Number.isNaN(time)) return;
@@ -1664,7 +1669,7 @@ function durationMix(art) {
get: ()=>{
const { duration } = art.template.$video;
if (duration === Infinity) return 0;
return duration || 0;
return duration ?? 0;
}
});
}
@@ -1738,7 +1743,7 @@ function aspectRatioMix(art) {
const { i18n , notice , template: { $video , $player } } = art;
(0, _utils.def)(art, "aspectRatio", {
get () {
return $player.dataset.aspectRatio || "default";
return $player.dataset.aspectRatio ?? "default";
},
set (ratio) {
if (!ratio) ratio = "default";
@@ -1865,7 +1870,7 @@ function fullscreenMix(art) {
};
art.once("video:loadedmetadata", ()=>{
if ((0, _screenfullDefault.default).isEnabled) nativeScreenfull(art);
else if (document.fullscreenEnabled || $video.webkitSupportsFullscreen) webkitScreenfull(art);
else if (document.fullscreenEnabled ?? $video.webkitSupportsFullscreen) webkitScreenfull(art);
else (0, _utils.def)(art, "fullscreen", {
get () {
return false;
@@ -2223,7 +2228,7 @@ function flipMix(art) {
const { template: { $player } , i18n , notice } = art;
(0, _utils.def)(art, "flip", {
get () {
return $player.dataset.flip || "normal";
return $player.dataset.flip ?? "normal";
},
set (flip) {
if (!flip) flip = "normal";
@@ -2370,7 +2375,7 @@ function loopMix(art) {
});
art.on("video:timeupdate", ()=>{
if (interval.length) {
if (art.currentTime < interval[0] || art.currentTime > interval[1]) art.seek = interval[0];
if ((art.currentTime < interval[0]) ?? art.currentTime > interval[1]) art.seek = interval[0];
}
});
}
@@ -2474,7 +2479,7 @@ function stateMix(art) {
"fullscreenWeb"
];
(0, _utils.def)(art, "state", {
get: ()=>states.find((name)=>art[name]) || "standard",
get: ()=>states.find((name)=>art[name]) ?? "standard",
set (name) {
for(let index = 0; index < states.length; index++){
const prop = states[index];
@@ -2560,7 +2565,7 @@ function qualityMix(art) {
(0, _utils.def)(art, "quality", {
set (quality) {
const { controls , notice , i18n } = art;
const qualityDefault = quality.find((item)=>item.default) || quality[0];
const qualityDefault = quality.find((item)=>item.default) ?? quality[0];
controls.update({
name: "quality",
position: "right",
@@ -2659,7 +2664,6 @@ function eventInit(art) {
(0, _utils.addClass)($player, "art-error");
await (0, _utils.sleep)(constructor.RECONNECT_SLEEP_TIME);
notice.show = i18n.get("Video Load Failed");
art.destroy(false);
}
});
// art.on('video:loadeddata', () => {
@@ -2894,10 +2898,10 @@ class Component {
}
add(getOption) {
const option = typeof getOption === "function" ? getOption(this.art) : getOption;
option.html = option.html || "";
option.html = option.html ?? "";
(0, _optionValidatorDefault.default)(option, (0, _scheme.ComponentOption));
if (!this.$parent || !this.name || option.disable) return;
const name = option.name || `${this.name}${this.id}`;
if (!this.$parent ?? !this.name ?? option.disable) return;
const name = option.name ?? `${this.name}${this.id}`;
const item = this.cache.get(name);
(0, _error.errorHandle)(!item, `Can't add an existing [${name}] to the [${this.name}]`);
this.id += 1;
@@ -2905,7 +2909,7 @@ class Component {
(0, _dom.addClass)($ref, `art-${this.name}`);
(0, _dom.addClass)($ref, `art-${this.name}-${name}`);
const childs = Array.from(this.$parent.children);
$ref.dataset.index = option.index || this.id;
$ref.dataset.index = option.index ?? this.id;
const nextChild = childs.find((item)=>Number(item.dataset.index) >= Number($ref.dataset.index));
if (nextChild) nextChild.insertAdjacentElement("beforebegin", $ref);
else (0, _dom.append)(this.$parent, $ref);
@@ -2954,12 +2958,12 @@ class Component {
};
hover($ref, setLeft);
const destroyEvent = proxy($list, "click", async (event)=>{
const path = event.composedPath() || [];
const path = event.composedPath() ?? [];
const $item = path.find((item)=>(0, _dom.hasClass)(item, "art-selector-item"));
if (!$item) return;
(0, _dom.inverseClass)($item, "art-current");
const index = Number($item.dataset.index);
const find = option.selector[index] || {};
const find = option.selector[index] ?? {};
$value.innerText = $item.innerText;
if (option.onSelect) {
const result = await option.onSelect.call(this.art, find, $item, event);
@@ -2980,7 +2984,10 @@ class Component {
}
update(option) {
const item = this.cache.get(option.name);
if (item) this.remove(option.name);
if (item) {
option = Object.assign(item.option, option);
this.remove(option.name);
}
return this.add(option);
}
}
@@ -3308,7 +3315,7 @@ function volume(option) {
return 1 - (event.clientY - top) / height;
}
function update() {
if (art.muted || art.volume === 0) {
if (art.muted ?? art.volume === 0) {
(0, _utils.setStyle)($volume, "display", "none");
(0, _utils.setStyle)($close, "display", "flex");
(0, _utils.setStyle)($indicator, "top", "100%");
@@ -3392,12 +3399,12 @@ function thumbnails(options) {
function showThumbnails(event) {
const { width: posWidth } = (0, _progress.getPosFromEvent)(art, event);
const { url , number , column , width , height } = option.thumbnails;
const width2 = width || image.naturalWidth / column;
const height2 = height || width2 / ($video.videoWidth / $video.videoHeight);
const width2 = width ?? image.naturalWidth / column;
const height2 = height ?? width2 / ($video.videoWidth / $video.videoHeight);
const perWidth = $progress.clientWidth / number;
const perIndex = Math.floor(posWidth / perWidth);
const yIndex = Math.ceil(perIndex / column) - 1;
const xIndex = perIndex % column || column - 1;
const xIndex = (perIndex % column) ?? column - 1;
(0, _utils.setStyle)($control, "backgroundImage", `url(${url})`);
(0, _utils.setStyle)($control, "height", `${height2}px`);
(0, _utils.setStyle)($control, "width", `${width2}px`);
@@ -3680,7 +3687,7 @@ parcelHelpers.defineInteropFlag(exports);
function version(option) {
return {
...option,
html: `<a href="https://artplayer.org" target="_blank">ArtPlayer ${"5.0.9"}</a>`
html: `<a href="https://artplayer.org" target="_blank">ArtPlayer ${"5.1.0"}</a>`
};
}
exports.default = version;
@@ -3717,7 +3724,7 @@ class Info extends (0, _componentDefault.default) {
this.show = false;
});
let timer = null;
const $types = (0, _utils.queryAll)("[data-video]", $infoPanel) || [];
const $types = (0, _utils.queryAll)("[data-video]", $infoPanel) ?? [];
this.art.on("destroy", ()=>clearTimeout(timer));
function loop() {
for(let index = 0; index < $types.length; index++){
@@ -3820,7 +3827,7 @@ class Subtitle extends (0, _componentDefault.default) {
const decoder = new TextDecoder(subtitleOption.encoding);
const text = decoder.decode(buffer);
this.art.emit("subtitleLoad", subtitleOption.url);
switch(subtitleOption.type || (0, _utils.getExt)(subtitleOption.url)){
switch(subtitleOption.type ?? (0, _utils.getExt)(subtitleOption.url)){
case "srt":
{
const vtt = (0, _utils.srtToVtt)(text);
@@ -3849,6 +3856,7 @@ class Subtitle extends (0, _componentDefault.default) {
this.art.emit("subtitleSwitch", subUrl);
return subUrl;
}).catch((err)=>{
$subtitle.innerHTML = "";
notice.show = err;
throw err;
});
@@ -4030,7 +4038,7 @@ function GetSlideDirection(startX, startY, endX, endY) {
if (angle >= -45 && angle < 45) result = 4;
else if (angle >= 45 && angle < 135) result = 1;
else if (angle >= -135 && angle < -45) result = 2;
else if (angle >= 135 && angle <= 180 || angle >= -180 && angle < -135) result = 3;
else if ((angle >= 135 && angle <= 180) ?? (angle >= -180 && angle < -135)) result = 3;
return result;
}
function gestureInit(art, events) {
@@ -4063,7 +4071,7 @@ function gestureInit(art, events) {
1,
2
].includes(direction);
const isLegal = isHorizontal && !art.isRotate || isVertical && art.isRotate;
const isLegal = (isHorizontal && !art.isRotate) ?? (isVertical && art.isRotate);
if (isLegal) {
const ratioX = (0, _utils.clamp)((pageX - startX) / art.width, -1, 1);
const ratioY = (0, _utils.clamp)((pageY - startY) / art.height, -1, 1);
@@ -4494,7 +4502,7 @@ class Setting extends (0, _componentDefault.default) {
const item = option[index];
item.$parentItem = parentItem;
item.$parentList = parentList;
Setting.makeRecursion(item.selector || [], item, option);
Setting.makeRecursion(item.selector ?? [], item, option);
}
return option;
}
@@ -4528,7 +4536,7 @@ class Setting extends (0, _componentDefault.default) {
const item = option[index];
if (item.name === name) return item;
else {
const result = this.find(name, item.selector || []);
const result = this.find(name, item.selector ?? []);
if (result) return result;
}
}
@@ -4536,7 +4544,7 @@ class Setting extends (0, _componentDefault.default) {
remove(name) {
const item = this.find(name);
(0, _error.errorHandle)(item, `Can't find [${name}] from the [setting]`);
const parent = item.$parentItem?.selector || this.option;
const parent = item.$parentItem?.selector ?? this.option;
parent.splice(parent.indexOf(item), 1);
this.option = Setting.makeRecursion(this.option);
this.destroy();
@@ -4590,10 +4598,10 @@ class Setting extends (0, _componentDefault.default) {
switch(type){
case "switch":
case "range":
(0, _utils.append)($icon, (0, _utils.isStringOrNumber)(item.icon) || item.icon instanceof Element ? item.icon : icons.config);
(0, _utils.append)($icon, (0, _utils.isStringOrNumber)(item.icon) ?? item.icon instanceof Element ? item.icon : icons.config);
break;
case "selector":
if (item.selector && item.selector.length) (0, _utils.append)($icon, (0, _utils.isStringOrNumber)(item.icon) || item.icon instanceof Element ? item.icon : icons.config);
if (item.selector && item.selector.length) (0, _utils.append)($icon, (0, _utils.isStringOrNumber)(item.icon) ?? item.icon instanceof Element ? item.icon : icons.config);
else (0, _utils.append)($icon, icons.check);
break;
default:
@@ -4612,7 +4620,7 @@ class Setting extends (0, _componentDefault.default) {
});
const $html = (0, _utils.createElement)("div");
(0, _utils.addClass)($html, "art-setting-item-left-text");
(0, _utils.append)($html, item.html || "");
(0, _utils.append)($html, item.html ?? "");
(0, _utils.append)($left, $html);
item.$html = $html;
(0, _utils.def)(item, "html", {
@@ -4626,7 +4634,7 @@ class Setting extends (0, _componentDefault.default) {
});
const $tooltip = (0, _utils.createElement)("div");
(0, _utils.addClass)($tooltip, "art-setting-item-right-tooltip");
(0, _utils.append)($tooltip, item.tooltip || "");
(0, _utils.append)($tooltip, item.tooltip ?? "");
(0, _utils.append)($right, $tooltip);
item.$tooltip = $tooltip;
(0, _utils.def)(item, "tooltip", {
@@ -4671,10 +4679,10 @@ class Setting extends (0, _componentDefault.default) {
const $state = (0, _utils.createElement)("div");
(0, _utils.addClass)($state, "art-setting-item-right-icon");
const $range = (0, _utils.append)($state, '<input type="range">');
$range.value = item.range[0] || 0;
$range.min = item.range[1] || 0;
$range.max = item.range[2] || 10;
$range.step = item.range[3] || 1;
$range.value = item.range[0] ?? 0;
$range.min = item.range[1] ?? 0;
$range.max = item.range[2] ?? 10;
$range.step = item.range[3] ?? 1;
(0, _utils.addClass)($range, "art-setting-range");
(0, _utils.append)($right, $state);
item.$range = $range;
@@ -4754,7 +4762,7 @@ class Setting extends (0, _componentDefault.default) {
updateStyle(width) {
const { controls , constructor , template: { $player , $setting } } = this.art;
if (controls.setting && !(0, _utils.isMobile)) {
const settingWidth = width || constructor.SETTING_WIDTH;
const settingWidth = width ?? constructor.SETTING_WIDTH;
const { left: controlLeft , width: controlWidth } = controls.setting.getBoundingClientRect();
const { left: playerLeft , width: playerWidth } = $player.getBoundingClientRect();
const settingLeft = controlLeft - playerLeft + controlWidth / 2 - settingWidth / 2;
@@ -4778,7 +4786,7 @@ class Setting extends (0, _componentDefault.default) {
} else {
const $panel = (0, _utils.createElement)("div");
(0, _utils.addClass)($panel, "art-setting-panel");
$panel.dataset.width = width || constructor.SETTING_WIDTH;
$panel.dataset.width = width ?? constructor.SETTING_WIDTH;
$panel.dataset.height = option.length * constructor.SETTING_ITEM_HEIGHT;
if (option[0] && option[0].$parentItem) {
(0, _utils.append)($panel, this.creatHeader(option[0]));
@@ -4960,7 +4968,7 @@ class Storage {
}
get(key) {
try {
const storage = JSON.parse(window.localStorage.getItem(this.name)) || {};
const storage = JSON.parse(window.localStorage.getItem(this.name)) ?? {};
return key ? storage[key] : storage;
} catch (error) {
return key ? this.settings[key] : this.settings;
@@ -5024,7 +5032,7 @@ class Plugins {
add(plugin) {
this.id += 1;
const result = plugin.call(this.art, this.art);
const pluginName = result && result.name || plugin.name || `plugin${this.id}`;
const pluginName = (result && result.name) ?? plugin.name ?? `plugin${this.id}`;
(0, _utils.errorHandle)(!(0, _utils.has)(this, pluginName), `Cannot add a plugin that already has the same name: ${pluginName}`);
(0, _utils.def)(this, pluginName, {
value: result
@@ -5070,7 +5078,7 @@ function autoOrientation(art) {
if (state) {
const { videoWidth , videoHeight } = $video;
const { clientWidth: viewWidth , clientHeight: viewHeight } = document.documentElement;
if (videoWidth > videoHeight && viewWidth < viewHeight || videoWidth < videoHeight && viewWidth > viewHeight) // There is a conflict with the fullscreen event, and it is changed to asynchronous execution
if ((videoWidth > videoHeight && viewWidth < viewHeight) ?? (videoWidth < videoHeight && viewWidth > viewHeight)) // There is a conflict with the fullscreen event, and it is changed to asynchronous execution
setTimeout(()=>{
(0, _utils.setStyle)($player, "width", `${viewHeight}px`);
(0, _utils.setStyle)($player, "height", `${viewWidth}px`);
@@ -5091,7 +5099,7 @@ function autoOrientation(art) {
if (state) {
const { videoWidth , videoHeight } = $video;
const { clientWidth: viewWidth , clientHeight: viewHeight } = document.documentElement;
if (videoWidth > videoHeight && viewWidth < viewHeight || videoWidth < videoHeight && viewWidth > viewHeight) {
if ((videoWidth > videoHeight && viewWidth < viewHeight) ?? (videoWidth < videoHeight && viewWidth > viewHeight)) {
const oppositeOrientation = lastOrientation.startsWith("portrait") ? "landscape" : "portrait";
await screen.orientation.lock(oppositeOrientation);
(0, _utils.addClass)($player, "art-auto-orientation-fullscreen");
@@ -5129,16 +5137,16 @@ function autoPlayback(art) {
const $close = (0, _utils.query)(".art-auto-playback-close", $autoPlayback);
art.on("video:timeupdate", ()=>{
if (art.playing) {
const times = storage.get("times") || {};
const times = storage.get("times") ?? {};
const keys = Object.keys(times);
if (keys.length > constructor.AUTO_PLAYBACK_MAX) delete times[keys[0]];
times[art.option.id || art.option.url] = art.currentTime;
times[art.option.id ?? art.option.url] = art.currentTime;
storage.set("times", times);
}
});
art.on("ready", ()=>{
const times = storage.get("times") || {};
const currentTime = times[art.option.id || art.option.url];
const times = storage.get("times") ?? {};
const currentTime = times[art.option.id ?? art.option.url];
if (currentTime && currentTime >= constructor.AUTO_PLAYBACK_MIN) {
(0, _utils.append)($close, icons.close);
(0, _utils.setStyle)($autoPlayback, "display", "flex");
@@ -5163,13 +5171,13 @@ function autoPlayback(art) {
return {
name: "auto-playback",
get times () {
return storage.get("times") || {};
return storage.get("times") ?? {};
},
clear () {
return storage.del("times");
},
delete (id) {
const times = storage.get("times") || {};
const times = storage.get("times") ?? {};
delete times[id];
storage.set("times", times);
return times;
+1 -1
View File
@@ -1 +1 @@
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;;AACA;;AACA;;AACA;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAI,KAAK;AACT,MAAM,YAAY,EAAE;AACL,MAAM,kBAAkB,CAAA,GAAA,uBAAO,AAAD;IACzC,YAAY,MAAM,EAAE,aAAa,CAAE;QAC/B,KAAK;QAEL,IAAI,CAAC,EAAE,GAAG,EAAE;QAEZ,MAAM,cAAc,OAAM,SAAS,CAAC,UAAU,MAAM,EAAE;QACtD,YAAY,SAAS,GAAG,OAAO,SAAS;QAExC,IAAI,CAAC,MAAM,GAAG,CAAA,GAAA,+BAAS,AAAD,EAAE,aAAa,CAAA,GAAA,sBAAM,AAAD;QAE1C,IAAI,CAAC,MAAM,GAAG,KAAK;QACnB,IAAI,CAAC,OAAO,GAAG,KAAK;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK;QACpB,IAAI,CAAC,QAAQ,GAAG,KAAK;QACrB,IAAI,CAAC,SAAS,GAAG,KAAK;QAEtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA,GAAA,wBAAQ,AAAD,EAAE,IAAI;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA,GAAA,sBAAM,AAAD,EAAE,IAAI;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA,GAAA,uBAAO,A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,GAAG;AAC9B,UAAU,iBAAiB,GAAG;AAC9B,UAAU,qBAAqB,GAAG;AAClC,UAAU,kBAAkB,GAAG;AAC/B,UAAU,oBAAoB,GAAG;AACjC,UAAU,iBAAiB,GAAG;AAC9B,UAAU,YAAY,GAAG;AACzB,UAAU,kBAAkB,GAAG,IAAI;AACnC,UAAU,mBAAmB,GAAG,IAAI;AACpC,UAAU,iBAAiB,GAAG,KAAK;AACnC,UAAU,qBAAqB,GAAG;AAClC,UAAU,cAAc,GAAG;AAC3B,UAAU,kBAAkB,GAAG;AAC/B,UAAU,iBAAiB,GAAG;AAC9B,UAAU,gBAAgB,GAAG;AAC7B,UAAU,WAAW,GAAG;AACxB,UAAU,SAAS,GAAG;AACtB,UAAU,aAAa,GAAG;IAAC;IAAK;IAAM;IAAG;IAAM;IAAK;CAAE;AACtD,UAAU,YAAY,GAAG;IAAC;IAAW;IAAO;CAAO;AACnD,UAAU,IAAI,GAAG;IAAC;IAAU;IAAc;CAAW;AACrD,UAAU,sBAAsB,GAAG,KAAK;AACxC,UAAU,WAAW,GAAG,IAAI;AAE5B,IAAI,OAAO,aAAa,aACpB;IAAA,IAAI,CAAC,SAAS,cAAc,CAAC,oBAAoB;QAC7C,MAAM,SAAS,OAAM,aLine truncated
@@ -505,4 +505,19 @@ var art = new Artplayer({
url: '/assets/sample/video.mp4',
fullscreenWeb: true,
});
```
## LOG_VERSION
设置是否打印播放器版本,默认为 `true`
<div className="run-code">▶ Run Code</div>
```js
Artplayer.LOG_VERSION = false;
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
```
@@ -505,4 +505,19 @@ var art = new Artplayer({
url: '/assets/sample/video.mp4',
fullscreenWeb: true,
});
```
## LOG_VERSION
设置是否打印播放器版本,默认为 `true`
<div className="run-code">▶ Run Code</div>
```js
Artplayer.LOG_VERSION = false;
var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
});
```
+3 -3
View File
@@ -18,12 +18,12 @@ export default function thumbnails(options) {
function showThumbnails(event) {
const { width: posWidth } = getPosFromEvent(art, event);
const { url, number, column, width, height } = option.thumbnails;
const width2 = width || image.naturalWidth / column;
const height2 = height || width2 / ($video.videoWidth / $video.videoHeight);
const width2 = width ?? image.naturalWidth / column;
const height2 = height ?? width2 / ($video.videoWidth / $video.videoHeight);
const perWidth = $progress.clientWidth / number;
const perIndex = Math.floor(posWidth / perWidth);
const yIndex = Math.ceil(perIndex / column) - 1;
const xIndex = perIndex % column || column - 1;
const xIndex = perIndex % column ?? column - 1;
setStyle($control, 'backgroundImage', `url(${url})`);
setStyle($control, 'height', `${height2}px`);
setStyle($control, 'width', `${width2}px`);
+1 -1
View File
@@ -22,7 +22,7 @@ export default function volume(option) {
}
function update() {
if (art.muted || art.volume === 0) {
if (art.muted ?? art.volume === 0) {
setStyle($volume, 'display', 'none');
setStyle($close, 'display', 'flex');
setStyle($indicator, 'top', '100%');
+2 -2
View File
@@ -21,7 +21,7 @@ function GetSlideDirection(startX, startY, endX, endY) {
result = 1;
} else if (angle >= -135 && angle < -45) {
result = 2;
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
} else if ((angle >= 135 && angle <= 180) ?? (angle >= -180 && angle < -135)) {
result = 3;
}
@@ -58,7 +58,7 @@ export default function gestureInit(art, events) {
const direction = GetSlideDirection(startX, startY, pageX, pageY);
const isHorizontal = [3, 4].includes(direction);
const isVertical = [1, 2].includes(direction);
const isLegal = (isHorizontal && !art.isRotate) || (isVertical && art.isRotate);
const isLegal = (isHorizontal && !art.isRotate) ?? (isVertical && art.isRotate);
if (isLegal) {
const ratioX = clamp((pageX - startX) / art.width, -1, 1);
const ratioY = clamp((pageY - startY) / art.height, -1, 1);
+2 -2
View File
@@ -30,11 +30,11 @@ export default class I18n {
init() {
const lang = this.art.option.lang.toLowerCase();
this.language = this.languages[lang] || {};
this.language = this.languages[lang] ?? {};
}
get(key) {
return this.language[key] || key;
return this.language[key] ?? key;
}
update(value) {
+11 -6
View File
@@ -241,6 +241,7 @@ Artplayer.PLAYBACK_RATE = [0.5, 0.75, 1, 1.25, 1.5, 2];
Artplayer.ASPECT_RATIO = ['default', '4:3', '16:9'];
Artplayer.FLIP = ['normal', 'horizontal', 'vertical'];
Artplayer.FULLSCREEN_WEB_IN_BODY = false;
Artplayer.LOG_VERSION = true;
if (typeof document !== 'undefined') {
if (!document.getElementById('artplayer-style')) {
@@ -255,9 +256,13 @@ if (typeof window !== 'undefined') {
window['Artplayer'] = Artplayer;
}
console.log(
`%c ArtPlayer %c ${Artplayer.version} %c https://artplayer.org`,
'color: #fff; background: #5f5f5f',
'color: #fff; background: #4bc729',
'',
);
setTimeout(() => {
if (Artplayer.LOG_VERSION) {
console.log(
`%c ArtPlayer %c ${Artplayer.version} %c https://artplayer.org`,
'color: #fff; background: #5f5f5f',
'color: #fff; background: #4bc729',
'',
);
}
});
+1 -1
View File
@@ -23,7 +23,7 @@ export default class Info extends Component {
});
let timer = null;
const $types = queryAll('[data-video]', $infoPanel) || [];
const $types = queryAll('[data-video]', $infoPanel) ?? [];
this.art.on('destroy', () => clearTimeout(timer));
function loop() {
@@ -9,7 +9,7 @@ export default function aspectRatioMix(art) {
def(art, 'aspectRatio', {
get() {
return $player.dataset.aspectRatio || 'default';
return $player.dataset.aspectRatio ?? 'default';
},
set(ratio) {
if (!ratio) ratio = 'default';
@@ -4,7 +4,7 @@ export default function currentTimeMix(art) {
const { $video } = art.template;
def(art, 'currentTime', {
get: () => $video.currentTime || 0,
get: () => $video.currentTime ?? 0,
set: (time) => {
time = parseFloat(time);
if (Number.isNaN(time)) return;
+1 -1
View File
@@ -5,7 +5,7 @@ export default function durationMix(art) {
get: () => {
const { duration } = art.template.$video;
if (duration === Infinity) return 0;
return duration || 0;
return duration ?? 0;
},
});
}
+1 -1
View File
@@ -9,7 +9,7 @@ export default function flipMix(art) {
def(art, 'flip', {
get() {
return $player.dataset.flip || 'normal';
return $player.dataset.flip ?? 'normal';
},
set(flip) {
if (!flip) flip = 'normal';
@@ -53,7 +53,7 @@ export default function fullscreenMix(art) {
art.once('video:loadedmetadata', () => {
if (screenfull.isEnabled) {
nativeScreenfull(art);
} else if (document.fullscreenEnabled || $video.webkitSupportsFullscreen) {
} else if (document.fullscreenEnabled ?? $video.webkitSupportsFullscreen) {
webkitScreenfull(art);
} else {
def(art, 'fullscreen', {
+1 -1
View File
@@ -22,7 +22,7 @@ export default function loopMix(art) {
art.on('video:timeupdate', () => {
if (interval.length) {
if (art.currentTime < interval[0] || art.currentTime > interval[1]) {
if (art.currentTime < interval[0] ?? art.currentTime > interval[1]) {
art.seek = interval[0];
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ export default function qualityMix(art) {
def(art, 'quality', {
set(quality) {
const { controls, notice, i18n } = art;
const qualityDefault = quality.find((item) => item.default) || quality[0];
const qualityDefault = quality.find((item) => item.default) ?? quality[0];
controls.update({
name: 'quality',
position: 'right',
+1 -1
View File
@@ -3,7 +3,7 @@ import { def } from '../utils';
export default function stateMix(art) {
const states = ['mini', 'pip', 'fullscreen', 'fullscreenWeb'];
def(art, 'state', {
get: () => states.find((name) => art[name]) || 'standard',
get: () => states.find((name) => art[name]) ?? 'standard',
set(name) {
for (let index = 0; index < states.length; index++) {
const prop = states[index];
+1 -1
View File
@@ -13,7 +13,7 @@ export default function urlMix(art) {
async set(newUrl) {
if (newUrl) {
const oldUrl = art.url;
const typeName = option.type || getExt(newUrl);
const typeName = option.type ?? getExt(newUrl);
const typeCallback = option.customType[typeName];
if (typeName && typeCallback) {
+1 -1
View File
@@ -9,7 +9,7 @@ export default function volumeMix(art) {
} = art;
def(art, 'volume', {
get: () => $video.volume || 0,
get: () => $video.volume ?? 0,
set: (percentage) => {
$video.volume = clamp(percentage, 0, 1);
notice.show = `${i18n.get('Volume')}: ${parseInt($video.volume * 100, 10)}`;
@@ -11,7 +11,7 @@ export default function autoOrientation(art) {
const { videoWidth, videoHeight } = $video;
const { clientWidth: viewWidth, clientHeight: viewHeight } = document.documentElement;
if (
(videoWidth > videoHeight && viewWidth < viewHeight) ||
(videoWidth > videoHeight && viewWidth < viewHeight) ??
(videoWidth < videoHeight && viewWidth > viewHeight)
) {
// There is a conflict with the fullscreen event, and it is changed to asynchronous execution
@@ -40,7 +40,7 @@ export default function autoOrientation(art) {
const { videoWidth, videoHeight } = $video;
const { clientWidth: viewWidth, clientHeight: viewHeight } = document.documentElement;
if (
(videoWidth > videoHeight && viewWidth < viewHeight) ||
(videoWidth > videoHeight && viewWidth < viewHeight) ??
(videoWidth < videoHeight && viewWidth > viewHeight)
) {
const oppositeOrientation = lastOrientation.startsWith('portrait') ? 'landscape' : 'portrait';
@@ -25,19 +25,19 @@ export default function autoPlayback(art) {
art.on('video:timeupdate', () => {
if (art.playing) {
const times = storage.get('times') || {};
const times = storage.get('times') ?? {};
const keys = Object.keys(times);
if (keys.length > constructor.AUTO_PLAYBACK_MAX) {
delete times[keys[0]];
}
times[art.option.id || art.option.url] = art.currentTime;
times[art.option.id ?? art.option.url] = art.currentTime;
storage.set('times', times);
}
});
art.on('ready', () => {
const times = storage.get('times') || {};
const currentTime = times[art.option.id || art.option.url];
const times = storage.get('times') ?? {};
const currentTime = times[art.option.id ?? art.option.url];
if (currentTime && currentTime >= constructor.AUTO_PLAYBACK_MIN) {
append($close, icons.close);
setStyle($autoPlayback, 'display', 'flex');
@@ -67,13 +67,13 @@ export default function autoPlayback(art) {
return {
name: 'auto-playback',
get times() {
return storage.get('times') || {};
return storage.get('times') ?? {};
},
clear() {
return storage.del('times');
},
delete(id) {
const times = storage.get('times') || {};
const times = storage.get('times') ?? {};
delete times[id];
storage.set('times', times);
return times;
+1 -1
View File
@@ -40,7 +40,7 @@ export default class Plugins {
add(plugin) {
this.id += 1;
const result = plugin.call(this.art, this.art);
const pluginName = (result && result.name) || plugin.name || `plugin${this.id}`;
const pluginName = (result && result.name) ?? plugin.name ?? `plugin${this.id}`;
errorHandle(!has(this, pluginName), `Cannot add a plugin that already has the same name: ${pluginName}`);
def(this, pluginName, {
value: result,
+1 -1
View File
@@ -9,7 +9,7 @@ const f = 'function';
function validElement(value, type, paths) {
return errorHandle(
type === s || type === n || value instanceof Element,
type === s ?? type === n ?? value instanceof Element,
`${paths.join('.')} require '${s}' or 'Element' type`,
);
}
+13 -13
View File
@@ -60,7 +60,7 @@ export default class Setting extends Component {
const item = option[index];
item.$parentItem = parentItem;
item.$parentList = parentList;
Setting.makeRecursion(item.selector || [], item, option);
Setting.makeRecursion(item.selector ?? [], item, option);
}
return option;
}
@@ -111,7 +111,7 @@ export default class Setting extends Component {
if (item.name === name) {
return item;
} else {
const result = this.find(name, item.selector || []);
const result = this.find(name, item.selector ?? []);
if (result) return result;
}
}
@@ -120,7 +120,7 @@ export default class Setting extends Component {
remove(name) {
const item = this.find(name);
errorHandle(item, `Can't find [${name}] from the [setting]`);
const parent = item.$parentItem?.selector || this.option;
const parent = item.$parentItem?.selector ?? this.option;
parent.splice(parent.indexOf(item), 1);
this.option = Setting.makeRecursion(this.option);
this.destroy();
@@ -190,13 +190,13 @@ export default class Setting extends Component {
switch (type) {
case 'switch':
case 'range':
append($icon, isStringOrNumber(item.icon) || item.icon instanceof Element ? item.icon : icons.config);
append($icon, isStringOrNumber(item.icon) ?? item.icon instanceof Element ? item.icon : icons.config);
break;
case 'selector':
if (item.selector && item.selector.length) {
append(
$icon,
isStringOrNumber(item.icon) || item.icon instanceof Element ? item.icon : icons.config,
isStringOrNumber(item.icon) ?? item.icon instanceof Element ? item.icon : icons.config,
);
} else {
append($icon, icons.check);
@@ -223,7 +223,7 @@ export default class Setting extends Component {
const $html = createElement('div');
addClass($html, 'art-setting-item-left-text');
append($html, item.html || '');
append($html, item.html ?? '');
append($left, $html);
item.$html = $html;
@@ -241,7 +241,7 @@ export default class Setting extends Component {
const $tooltip = createElement('div');
addClass($tooltip, 'art-setting-item-right-tooltip');
append($tooltip, item.tooltip || '');
append($tooltip, item.tooltip ?? '');
append($right, $tooltip);
item.$tooltip = $tooltip;
@@ -290,10 +290,10 @@ export default class Setting extends Component {
const $state = createElement('div');
addClass($state, 'art-setting-item-right-icon');
const $range = append($state, '<input type="range">');
$range.value = item.range[0] || 0;
$range.min = item.range[1] || 0;
$range.max = item.range[2] || 10;
$range.step = item.range[3] || 1;
$range.value = item.range[0] ?? 0;
$range.min = item.range[1] ?? 0;
$range.max = item.range[2] ?? 10;
$range.step = item.range[3] ?? 1;
addClass($range, 'art-setting-range');
append($right, $state);
item.$range = $range;
@@ -398,7 +398,7 @@ export default class Setting extends Component {
} = this.art;
if (controls.setting && !isMobile) {
const settingWidth = width || constructor.SETTING_WIDTH;
const settingWidth = width ?? constructor.SETTING_WIDTH;
const { left: controlLeft, width: controlWidth } = controls.setting.getBoundingClientRect();
const { left: playerLeft, width: playerWidth } = $player.getBoundingClientRect();
const settingLeft = controlLeft - playerLeft + controlWidth / 2 - settingWidth / 2;
@@ -424,7 +424,7 @@ export default class Setting extends Component {
} else {
const $panel = createElement('div');
addClass($panel, 'art-setting-panel');
$panel.dataset.width = width || constructor.SETTING_WIDTH;
$panel.dataset.width = width ?? constructor.SETTING_WIDTH;
$panel.dataset.height = option.length * constructor.SETTING_ITEM_HEIGHT;
if (option[0] && option[0].$parentItem) {
+1 -1
View File
@@ -6,7 +6,7 @@ export default class Storage {
get(key) {
try {
const storage = JSON.parse(window.localStorage.getItem(this.name)) || {};
const storage = JSON.parse(window.localStorage.getItem(this.name)) ?? {};
return key ? storage[key] : storage;
} catch (error) {
return key ? this.settings[key] : this.settings;
+2 -1
View File
@@ -117,7 +117,7 @@ export default class Subtitle extends Component {
const decoder = new TextDecoder(subtitleOption.encoding);
const text = decoder.decode(buffer);
this.art.emit('subtitleLoad', subtitleOption.url);
switch (subtitleOption.type || getExt(subtitleOption.url)) {
switch (subtitleOption.type ?? getExt(subtitleOption.url)) {
case 'srt': {
const vtt = srtToVtt(text);
const vttNew = subtitleOption.onVttLoad(vtt);
@@ -145,6 +145,7 @@ export default class Subtitle extends Component {
return subUrl;
})
.catch((err) => {
$subtitle.innerHTML = '';
notice.show = err;
throw err;
});
@@ -4,5 +4,5 @@ export const isWechat = /MicroMessenger/i.test(userAgent);
export const isIE = /MSIE|Trident/i.test(userAgent);
export const isAndroid = /android/i.test(userAgent);
export const isIOS = /iPad|iPhone|iPod/i.test(userAgent) && !window.MSStream;
export const isIOS13 = isIOS || (userAgent.includes('Macintosh') && navigator.maxTouchPoints >= 1);
export const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) || isIOS13;
export const isIOS13 = isIOS ?? (userAgent.includes('Macintosh') && navigator.maxTouchPoints >= 1);
export const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) ?? isIOS13;
+6 -6
View File
@@ -46,10 +46,10 @@ export default class Component {
add(getOption) {
const option = typeof getOption === 'function' ? getOption(this.art) : getOption;
option.html = option.html || '';
option.html = option.html ?? '';
validator(option, ComponentOption);
if (!this.$parent || !this.name || option.disable) return;
const name = option.name || `${this.name}${this.id}`;
if (!this.$parent ?? !this.name ?? option.disable) return;
const name = option.name ?? `${this.name}${this.id}`;
const item = this.cache.get(name);
errorHandle(!item, `Can't add an existing [${name}] to the [${this.name}]`);
@@ -59,7 +59,7 @@ export default class Component {
addClass($ref, `art-${this.name}-${name}`);
const childs = Array.from(this.$parent.children);
$ref.dataset.index = option.index || this.id;
$ref.dataset.index = option.index ?? this.id;
const nextChild = childs.find((item) => Number(item.dataset.index) >= Number($ref.dataset.index));
if (nextChild) {
nextChild.insertAdjacentElement('beforebegin', $ref);
@@ -135,12 +135,12 @@ export default class Component {
hover($ref, setLeft);
const destroyEvent = proxy($list, 'click', async (event) => {
const path = event.composedPath() || [];
const path = event.composedPath() ?? [];
const $item = path.find((item) => hasClass(item, 'art-selector-item'));
if (!$item) return;
inverseClass($item, 'art-current');
const index = Number($item.dataset.index);
const find = option.selector[index] || {};
const find = option.selector[index] ?? {};
$value.innerText = $item.innerText;
if (option.onSelect) {
const result = await option.onSelect.call(this.art, find, $item, event);
+3 -3
View File
@@ -26,7 +26,7 @@ export function append(parent, child) {
} else {
parent.insertAdjacentHTML('beforeend', String(child));
}
return parent.lastElementChild || parent.lastChild;
return parent.lastElementChild ?? parent.lastChild;
}
export function remove(child) {
@@ -68,8 +68,8 @@ export function tooltip(target, msg, pos = 'top') {
export function isInViewport(el, offset = 0) {
const rect = el.getBoundingClientRect();
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
const windowHeight = window.innerHeight ?? document.documentElement.clientHeight;
const windowWidth = window.innerWidth ?? document.documentElement.clientWidth;
const vertInView = rect.top - offset <= windowHeight && rect.top + rect.height + offset >= 0;
const horInView = rect.left - offset <= windowWidth + offset && rect.left + rect.width + offset >= 0;
return vertInView && horInView;
+4 -4
View File
@@ -1,7 +1,7 @@
export default class Emitter {
on(name, fn, ctx) {
const e = this.e || (this.e = {});
(e[name] || (e[name] = [])).push({ fn, ctx });
const e = this.e ?? (this.e = {});
(e[name] ?? (e[name] = [])).push({ fn, ctx });
return this;
}
@@ -16,7 +16,7 @@ export default class Emitter {
}
emit(name, ...data) {
const evtArr = ((this.e || (this.e = {}))[name] || []).slice();
const evtArr = ((this.e ?? (this.e = {}))[name] ?? []).slice();
for (let i = 0; i < evtArr.length; i += 1) {
evtArr[i].fn.apply(evtArr[i].ctx, data);
}
@@ -24,7 +24,7 @@ export default class Emitter {
}
off(name, callback) {
const e = this.e || (this.e = {});
const e = this.e ?? (this.e = {});
const evts = e[name];
const liveEvents = [];
if (evts && callback) {
+1 -1
View File
@@ -2,7 +2,7 @@ export class ArtPlayerError extends Error {
constructor(message, context) {
super(message);
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, context || this.constructor);
Error.captureStackTrace(this, context ?? this.constructor);
}
this.name = 'ArtPlayerError';
}
+2 -1
View File
@@ -11,6 +11,7 @@ export function isStringOrNumber(val) {
}
export function secondToTime(second) {
if (!second) return '00:00';
const add0 = (num) => (num < 10 ? `0${num}` : String(num));
const hour = Math.floor(second / 3600);
const min = Math.floor((second - hour * 3600) / 60);
@@ -28,6 +29,6 @@ export function escape(str) {
'>': '&gt;',
"'": '&#39;',
'"': '&quot;',
}[tag] || tag),
}[tag] ?? tag),
);
}