From 3391ca1fed2e197bf7c3876c8e1c670a5dfb3997 Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Sat, 18 Feb 2023 11:34:45 +0800 Subject: [PATCH] artplayer-plugin-hls-quality.js v1.0.1 --- CHANGELOG_CN.md | 2 ++ docs/assets/example/hls.quality.js | 23 ++++++++++++++----- docs/compiled/artplayer-plugin-hls-quality.js | 4 ++-- .../artplayer-plugin-hls-quality.legacy.js | 4 ++-- .../artplayer-plugin-hls-quality/index.js | 13 ++++++----- .../artplayer-plugin-hls-quality/index.js.map | 2 +- .../dist/artplayer-plugin-hls-quality.js | 4 ++-- .../artplayer-plugin-hls-quality.legacy.js | 4 ++-- .../artplayer-plugin-hls-quality/package.json | 4 ++-- .../artplayer-plugin-hls-quality/src/index.js | 7 +++--- .../types/artplayer-plugin-hls-quality.d.ts | 1 + 11 files changed, 42 insertions(+), 26 deletions(-) diff --git a/CHANGELOG_CN.md b/CHANGELOG_CN.md index 3b2b51721..f109ef0c1 100644 --- a/CHANGELOG_CN.md +++ b/CHANGELOG_CN.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +- 插件 `artplayerPluginHlsQuality` 添加 `getResolution` 函数选项,用于获取从 `level` 中分辨率的文本 + ## [4.6.2] - 2023-1-26 - `Artplayer.PROGRESS_HEIGHT` 默认值改为 `6` diff --git a/docs/assets/example/hls.quality.js b/docs/assets/example/hls.quality.js index 0f9bbde2d..b1c5496d6 100644 --- a/docs/assets/example/hls.quality.js +++ b/docs/assets/example/hls.quality.js @@ -10,17 +10,28 @@ var art = new Artplayer({ // Show quality in setting setting: true, + // Get the resolution text from level + getResolution: (level) => level.height + 'P', + // I18n title: 'Quality', auto: 'Auto', }), ], customType: { - m3u8: function (video, url) { - // Attach the Hls instance to the Artplayer instance - art.hls = new Hls(); - art.hls.loadSource(url); - art.hls.attachMedia(video); - }, + m3u8: function playM3u8(video, url, art) { + if (Hls.isSupported()) { + const hls = new Hls(); + hls.loadSource(url); + hls.attachMedia(video); + art.hls = hls; + art.once('url', () => hls.destroy()); + art.once('destroy', () => hls.destroy()); + } else if (video.canPlayType('application/vnd.apple.mpegurl')) { + video.src = url; + } else { + art.notice.show = 'Unsupported playback format: m3u8'; + } + } }, }); diff --git a/docs/compiled/artplayer-plugin-hls-quality.js b/docs/compiled/artplayer-plugin-hls-quality.js index 38b3967ea..3657a0ab6 100644 --- a/docs/compiled/artplayer-plugin-hls-quality.js +++ b/docs/compiled/artplayer-plugin-hls-quality.js @@ -1,7 +1,7 @@ /*! - * artplayer-plugin-hls-quality.js v1.0.0 + * artplayer-plugin-hls-quality.js v1.0.1 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2023 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,o,r){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l[o]&&l[o],u=i.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,n){if(!u[t]){if(!e[t]){var r="function"==typeof l[o]&&l[o];if(!n&&r)return r(t,!0);if(i)return i(t,!0);if(f&&"string"==typeof t)return f(t);var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}c.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},c.cache={};var a=u[t]=new d.Module(t);e[t][0].call(a.exports,c,a,a.exports,this)}return u[t].exports;function c(e){var t=c.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=e,d.cache=u,d.parent=i,d.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(d,"root",{get:function(){return l[o]}}),l[o]=d;for(var s=0;s{const{$video:n}=t.template,{errorHandle:o}=t.constructor.utils;return t.on("ready",(function(){const r=t.hls||window.hls;o(r&&r.media===n,'Cannot find instance of HLS from "art.hls" or "window.hls"');const i=e.auto||"Auto",u=e.title||"Quality",f=r.levels[r.currentLevel],d=f?f.height+"P":i;e.control&&t.controls.add({name:"hls-quality",position:"right",html:d,style:{padding:"0 10px"},selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:e=>(r.nextLevel=e.level,e.html)}),e.setting&&t.setting.add({name:"hls-quality",tooltip:d,html:u,icon:l.default,width:200,selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:function(e){return r.nextLevel=e.level,e.html}})})),{name:"artplayerPluginHlsQuality"}}}n.default=i,i.env="production",i.version="1.0.0",i.build="2023-01-26 15:27:10","undefined"!=typeof window&&(window.artplayerPluginHlsQuality=i)},{"bundle-text:./image.svg":"5VXix","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"5VXix":[function(e,t,n){t.exports=''},{}],"9pCYc":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eEHR6"],"eEHR6","parcelRequire4dc0"); \ No newline at end of file +!function(e,t,n,o,r){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0,u=i.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,n){if(!u[t]){if(!e[t]){var o="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0;if(!n&&o)return o(t,!0);if(i)return i(t,!0);if(c&&"string"==typeof t)return c(t);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}a.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},a.cache={};var d=u[t]=new f.Module(t);e[t][0].call(d.exports,a,d,d.exports,this)}return u[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=u,f.parent=i,f.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(f,"root",{get:function(){return l.parcelRequire4dc0}}),l.parcelRequire4dc0=f;for(var d=0;d{const{$video:n}=t.template,{errorHandle:o}=t.constructor.utils;return t.on("ready",(function(){const r=t.hls||window.hls;o(r&&r.media===n,'Cannot find instance of HLS from "art.hls" or "window.hls"');const i=e.auto||"Auto",u=e.title||"Quality",c=e.getResolution||(e=>(e.height||"Unknown ")+"P"),f=r.levels[r.currentLevel],d=f?c(f):i;e.control&&t.controls.add({name:"hls-quality",position:"right",html:d,style:{padding:"0 10px"},selector:r.levels.map(((e,t)=>({html:c(e),level:e.level||t,default:f===e}))),onSelect:e=>(r.nextLevel=e.level,e.html)}),e.setting&&t.setting.add({name:"hls-quality",tooltip:d,html:u,icon:l.default,width:200,selector:r.levels.map(((e,t)=>({html:c(e),level:e.level||t,default:f===e}))),onSelect:function(e){return r.nextLevel=e.level,e.html}})})),{name:"artplayerPluginHlsQuality"}}}n.default=i,i.env="production",i.version="1.0.1",i.build="2023-02-18 11:24:38","undefined"!=typeof window&&(window.artplayerPluginHlsQuality=i)},{"bundle-text:./image.svg":"5VXix","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"5VXix":[function(e,t,n){t.exports=''},{}],"9pCYc":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eEHR6"],"eEHR6"); \ No newline at end of file diff --git a/docs/compiled/artplayer-plugin-hls-quality.legacy.js b/docs/compiled/artplayer-plugin-hls-quality.legacy.js index 96335e398..3ab82a525 100644 --- a/docs/compiled/artplayer-plugin-hls-quality.legacy.js +++ b/docs/compiled/artplayer-plugin-hls-quality.legacy.js @@ -1,7 +1,7 @@ /*! - * artplayer-plugin-hls-quality.js v1.0.0 + * artplayer-plugin-hls-quality.js v1.0.1 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2023 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,o,r){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l[o]&&l[o],u=i.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,n){if(!u[t]){if(!e[t]){var r="function"==typeof l[o]&&l[o];if(!n&&r)return r(t,!0);if(i)return i(t,!0);if(f&&"string"==typeof t)return f(t);var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}c.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},c.cache={};var a=u[t]=new d.Module(t);e[t][0].call(a.exports,c,a,a.exports,this)}return u[t].exports;function c(e){var t=c.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=e,d.cache=u,d.parent=i,d.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(d,"root",{get:function(){return l[o]}}),l[o]=d;for(var s=0;s{const{$video:n}=t.template,{errorHandle:o}=t.constructor.utils;return t.on("ready",(function(){const r=t.hls||window.hls;o(r&&r.media===n,'Cannot find instance of HLS from "art.hls" or "window.hls"');const i=e.auto||"Auto",u=e.title||"Quality",f=r.levels[r.currentLevel],d=f?f.height+"P":i;e.control&&t.controls.add({name:"hls-quality",position:"right",html:d,style:{padding:"0 10px"},selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:e=>(r.nextLevel=e.level,e.html)}),e.setting&&t.setting.add({name:"hls-quality",tooltip:d,html:u,icon:l.default,width:200,selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:function(e){return r.nextLevel=e.level,e.html}})})),{name:"artplayerPluginHlsQuality"}}}n.default=i,i.env="production",i.version="1.0.0",i.build="2023-01-26 15:27:11","undefined"!=typeof window&&(window.artplayerPluginHlsQuality=i)},{"bundle-text:./image.svg":"9cAMb","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"9cAMb":[function(e,t,n){t.exports=''},{}],"47PTV":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["3yim4"],"3yim4","parcelRequire4dc0"); \ No newline at end of file +!function(e,t,n,r,o){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0,u=i.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,n){if(!u[t]){if(!e[t]){var r="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0;if(!n&&r)return r(t,!0);if(i)return i(t,!0);if(f&&"string"==typeof t)return f(t);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var d=u[t]=new c.Module(t);e[t][0].call(d.exports,a,d,d.exports,this)}return u[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.exports={}},c.modules=e,c.cache=u,c.parent=i,c.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(c,"root",{get:function(){return l.parcelRequire4dc0}}),l.parcelRequire4dc0=c;for(var d=0;d'},{}],"47PTV":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["3yim4"],"3yim4"); \ No newline at end of file diff --git a/docs/uncompiled/artplayer-plugin-hls-quality/index.js b/docs/uncompiled/artplayer-plugin-hls-quality/index.js index 5e868a28f..ab634af72 100644 --- a/docs/uncompiled/artplayer-plugin-hls-quality/index.js +++ b/docs/uncompiled/artplayer-plugin-hls-quality/index.js @@ -156,8 +156,9 @@ function artplayerPluginHlsQuality(option) { errorHandle(hls && hls.media === $video, 'Cannot find instance of HLS from "art.hls" or "window.hls"'); const auto = option.auto || "Auto"; const title = option.title || "Quality"; + const getResolution = option.getResolution || ((level)=>(level.height || "Unknown ") + "P"); const defaultLevel = hls.levels[hls.currentLevel]; - const defaultHtml = defaultLevel ? defaultLevel.height + "P" : auto; + const defaultHtml = defaultLevel ? getResolution(defaultLevel) : auto; if (option.control) art.controls.add({ name: "hls-quality", position: "right", @@ -167,7 +168,7 @@ function artplayerPluginHlsQuality(option) { }, selector: hls.levels.map((item, index)=>{ return { - html: item.height + "P", + html: getResolution(item), level: item.level || index, default: defaultLevel === item }; @@ -185,7 +186,7 @@ function artplayerPluginHlsQuality(option) { width: 200, selector: hls.levels.map((item, index)=>{ return { - html: item.height + "P", + html: getResolution(item), level: item.level || index, default: defaultLevel === item }; @@ -204,12 +205,12 @@ function artplayerPluginHlsQuality(option) { } exports.default = artplayerPluginHlsQuality; artplayerPluginHlsQuality.env = "development"; -artplayerPluginHlsQuality.version = "1.0.0"; -artplayerPluginHlsQuality.build = "2022-12-31 21:23:08"; +artplayerPluginHlsQuality.version = "1.0.1"; +artplayerPluginHlsQuality.build = "2023-02-18 11:28:03"; if (typeof window !== "undefined") window["artplayerPluginHlsQuality"] = artplayerPluginHlsQuality; },{"bundle-text:./image.svg":"1HFaU","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"1HFaU":[function(require,module,exports) { -module.exports = "\r\n\r\n\r\n"; +module.exports = "\n\n\n"; },{}],"5dUr6":[function(require,module,exports) { exports.interopDefault = function(a) { diff --git a/docs/uncompiled/artplayer-plugin-hls-quality/index.js.map b/docs/uncompiled/artplayer-plugin-hls-quality/index.js.map index 376a42080..cbf5c23fa 100644 --- a/docs/uncompiled/artplayer-plugin-hls-quality/index.js.map +++ b/docs/uncompiled/artplayer-plugin-hls-quality/index.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;;AAEe,SAAS,0BAA0B,MAAM,EAAE;IACtD,OAAO,CAAC,MAAQ;QACZ,MAAM,EAAE,OAAM,EAAE,GAAG,IAAI,QAAQ;QAC/B,MAAM,EAAE,YAAW,EAAE,GAAG,IAAI,WAAW,CAAC,KAAK;QAE7C,SAAS,SAAS;YACd,MAAM,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG;YACjC,YAAY,OAAO,IAAI,KAAK,KAAK,QAAQ;YACzC,MAAM,OAAO,OAAO,IAAI,IAAI;YAC5B,MAAM,QAAQ,OAAO,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AE;IACpC,OAAO,KAAK,EAAE,UAAU,GAAG,IAAI;QAAC,SAAS;IAAC,CAAC;AAC7C;AAEA,QAAQ,iBAAiB,GAAG,SAAU,CAAC,EAAE;IACvC,OAAO,cAAc,CAAC,GAAG,cAAc;QAAC,OAAO,IAAI;IAAA;AACrD;AAEA,QAAQ,SAAS,GAAG,SAAU,MAAM,EAAE,IAAI,EAAE;IAC1C,OAAO,IAAI,CAAC,QAAQ,OAAO,CAAC,SAAU,GAAG,EAAE;QACzC,IAAI,QAAQ,aAAa,QAAQ,gBAAgB,KAAK,cAAc,CAAC,MACnE;QAGF,OAAO,cAAc,CAAC,MAAM,KAAK;YAC/B,YAAY,IAAI;YAChB,KAAK,WAAY;gBACf,OAAO,MAAM,CAAC,IAAI;YACpB;QACF;IACF;IAEA,OAAO;AACT;AAEA,QAAQ,MAAM,GAAG,SAAU,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE;IAC9C,OAAO,cAAc,CAAC,MAAM,UAAU;QACpC,YAAY,IAAI;QAChB,KAAK;IACP;AACF","sources":["packages/artplayer-plugin-hls-quality/src/index.js","node_modules/@parcel/runtime-js/lib/bundles/runtime-cdfe3d14efbab84d.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["import image from 'bundle-text:./image.svg';\n\nexport default function artplayerPluginHlsQuality(option) {\n return (art) => {\n const { $video } = art.template;\n const { errorHandle } = art.constructor.utils;\n\n function update() {\n const hls = art.hls || window.hls;\n errorHandle(hls && hls.media === $video, 'Cannot find instance of HLS from \"art.hls\" or \"window.hls\"');\n const auto = option.auto || 'Auto';\n const title = option.title || 'Quality';\n const defaultLevel = hls.levels[hls.currentLevel];\n const defaultHtml = defaultLevel ? defaultLevel.height + 'P' : auto;\n\n if (option.control) {\n art.controls.add({\n name: 'hls-quality',\n position: 'right',\n html: defaultHtml,\n style: { padding: '0 10px' },\n selector: hls.levels.map((item, index) => {\n return {\n html: item.height + 'P',\n level: item.level || index,\n default: defaultLevel === item,\n };\n }),\n onSelect(item) {\n hls.nextLevel = item.level;\n return item.html;\n },\n });\n }\n\n if (option.setting) {\n art.setting.add({\n name: 'hls-quality',\n tooltip: defaultHtml,\n html: title,\n icon: image,\n width: 200,\n selector: hls.levels.map((item, index) => {\n return {\n html: item.height + 'P',\n level: item.level || index,\n default: defaultLevel === item,\n };\n }),\n onSelect: function (item) {\n hls.nextLevel = item.level;\n return item.html;\n },\n });\n }\n }\n\n art.on('ready', update);\n\n return {\n name: 'artplayerPluginHlsQuality',\n };\n };\n}\n\nartplayerPluginHlsQuality.env = process.env.NODE_ENV;\nartplayerPluginHlsQuality.version = process.env.APP_VER;\nartplayerPluginHlsQuality.build = process.env.BUILD_DATE;\n\nif (typeof window !== 'undefined') {\n window['artplayerPluginHlsQuality'] = artplayerPluginHlsQuality;\n}\n","module.exports = \"138ab730cddc3409\";","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../../"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA,kDAA4C;;AAE7B,SAAS,yBAAyB,CAAC,MAAM,EAAE;IACtD,OAAO,CAAC,GAAG,GAAK;QACZ,MAAM,EAAE,MA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AC,UAAU,GAAG,CAAC,GAAG;QAAC,OAAO,EAAE,CAAC;KAAC,CAAC;CAC7C,CAAC;AAEF,OAAO,CAAC,iBAAiB,GAAG,SAAU,CAAC,EAAE;IACvC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE;QAAC,KAAK,EAAE,IAAI;KAAC,CAAC,CAAC;CACvD,CAAC;AAEF,OAAO,CAAC,SAAS,GAAG,SAAU,MAAM,EAAE,IAAI,EAAE;IAC1C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,SAAU,GAAG,EAAE;QACzC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,YAAY,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EACvE,OAAO;QAGT,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;YAC/B,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE,WAAY;gBACf,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;aACpB;SACF,CAAC,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;CACb,CAAC;AAEF,OAAO,CAAC,MAAM,GAAG,SAAU,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE;IAC9C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE;QACpC,UAAU,EAAE,IAAI;QAChB,GAAG,EAAE,GAAG;KACT,CAAC,CAAC;CACJ,CAAC","sources":["packages/artplayer-plugin-hls-quality/src/index.js","node_modules/@parcel/runtime-js/lib/bundles/runtime-cdfe3d14efbab84d.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["import image from 'bundle-text:./image.svg';\n\nexport default function artplayerPluginHlsQuality(option) {\n return (art) => {\n const { $video } = art.template;\n const { errorHandle } = art.constructor.utils;\n\n function update() {\n const hls = art.hls || window.hls;\n errorHandle(hls && hls.media === $video, 'Cannot find instance of HLS from \"art.hls\" or \"window.hls\"');\n const auto = option.auto || 'Auto';\n const title = option.title || 'Quality';\n const getResolution = option.getResolution || ((level) => (level.height || 'Unknown ') + 'P');\n const defaultLevel = hls.levels[hls.currentLevel];\n const defaultHtml = defaultLevel ? getResolution(defaultLevel) : auto;\n\n if (option.control) {\n art.controls.add({\n name: 'hls-quality',\n position: 'right',\n html: defaultHtml,\n style: { padding: '0 10px' },\n selector: hls.levels.map((item, index) => {\n return {\n html: getResolution(item),\n level: item.level || index,\n default: defaultLevel === item,\n };\n }),\n onSelect(item) {\n hls.nextLevel = item.level;\n return item.html;\n },\n });\n }\n\n if (option.setting) {\n art.setting.add({\n name: 'hls-quality',\n tooltip: defaultHtml,\n html: title,\n icon: image,\n width: 200,\n selector: hls.levels.map((item, index) => {\n return {\n html: getResolution(item),\n level: item.level || index,\n default: defaultLevel === item,\n };\n }),\n onSelect: function (item) {\n hls.nextLevel = item.level;\n return item.html;\n },\n });\n }\n }\n\n art.on('ready', update);\n\n return {\n name: 'artplayerPluginHlsQuality',\n };\n };\n}\n\nartplayerPluginHlsQuality.env = process.env.NODE_ENV;\nartplayerPluginHlsQuality.version = process.env.APP_VER;\nartplayerPluginHlsQuality.build = process.env.BUILD_DATE;\n\nif (typeof window !== 'undefined') {\n window['artplayerPluginHlsQuality'] = artplayerPluginHlsQuality;\n}\n","module.exports = \"138ab730cddc3409\";","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../../"} \ No newline at end of file diff --git a/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.js b/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.js index 38b3967ea..3657a0ab6 100644 --- a/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.js +++ b/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.js @@ -1,7 +1,7 @@ /*! - * artplayer-plugin-hls-quality.js v1.0.0 + * artplayer-plugin-hls-quality.js v1.0.1 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2023 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,o,r){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l[o]&&l[o],u=i.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,n){if(!u[t]){if(!e[t]){var r="function"==typeof l[o]&&l[o];if(!n&&r)return r(t,!0);if(i)return i(t,!0);if(f&&"string"==typeof t)return f(t);var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}c.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},c.cache={};var a=u[t]=new d.Module(t);e[t][0].call(a.exports,c,a,a.exports,this)}return u[t].exports;function c(e){var t=c.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=e,d.cache=u,d.parent=i,d.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(d,"root",{get:function(){return l[o]}}),l[o]=d;for(var s=0;s{const{$video:n}=t.template,{errorHandle:o}=t.constructor.utils;return t.on("ready",(function(){const r=t.hls||window.hls;o(r&&r.media===n,'Cannot find instance of HLS from "art.hls" or "window.hls"');const i=e.auto||"Auto",u=e.title||"Quality",f=r.levels[r.currentLevel],d=f?f.height+"P":i;e.control&&t.controls.add({name:"hls-quality",position:"right",html:d,style:{padding:"0 10px"},selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:e=>(r.nextLevel=e.level,e.html)}),e.setting&&t.setting.add({name:"hls-quality",tooltip:d,html:u,icon:l.default,width:200,selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:function(e){return r.nextLevel=e.level,e.html}})})),{name:"artplayerPluginHlsQuality"}}}n.default=i,i.env="production",i.version="1.0.0",i.build="2023-01-26 15:27:10","undefined"!=typeof window&&(window.artplayerPluginHlsQuality=i)},{"bundle-text:./image.svg":"5VXix","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"5VXix":[function(e,t,n){t.exports=''},{}],"9pCYc":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eEHR6"],"eEHR6","parcelRequire4dc0"); \ No newline at end of file +!function(e,t,n,o,r){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0,u=i.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,n){if(!u[t]){if(!e[t]){var o="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0;if(!n&&o)return o(t,!0);if(i)return i(t,!0);if(c&&"string"==typeof t)return c(t);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}a.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},a.cache={};var d=u[t]=new f.Module(t);e[t][0].call(d.exports,a,d,d.exports,this)}return u[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=u,f.parent=i,f.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(f,"root",{get:function(){return l.parcelRequire4dc0}}),l.parcelRequire4dc0=f;for(var d=0;d{const{$video:n}=t.template,{errorHandle:o}=t.constructor.utils;return t.on("ready",(function(){const r=t.hls||window.hls;o(r&&r.media===n,'Cannot find instance of HLS from "art.hls" or "window.hls"');const i=e.auto||"Auto",u=e.title||"Quality",c=e.getResolution||(e=>(e.height||"Unknown ")+"P"),f=r.levels[r.currentLevel],d=f?c(f):i;e.control&&t.controls.add({name:"hls-quality",position:"right",html:d,style:{padding:"0 10px"},selector:r.levels.map(((e,t)=>({html:c(e),level:e.level||t,default:f===e}))),onSelect:e=>(r.nextLevel=e.level,e.html)}),e.setting&&t.setting.add({name:"hls-quality",tooltip:d,html:u,icon:l.default,width:200,selector:r.levels.map(((e,t)=>({html:c(e),level:e.level||t,default:f===e}))),onSelect:function(e){return r.nextLevel=e.level,e.html}})})),{name:"artplayerPluginHlsQuality"}}}n.default=i,i.env="production",i.version="1.0.1",i.build="2023-02-18 11:24:38","undefined"!=typeof window&&(window.artplayerPluginHlsQuality=i)},{"bundle-text:./image.svg":"5VXix","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"5VXix":[function(e,t,n){t.exports=''},{}],"9pCYc":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["eEHR6"],"eEHR6"); \ No newline at end of file diff --git a/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.legacy.js b/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.legacy.js index 96335e398..3ab82a525 100644 --- a/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.legacy.js +++ b/packages/artplayer-plugin-hls-quality/dist/artplayer-plugin-hls-quality.legacy.js @@ -1,7 +1,7 @@ /*! - * artplayer-plugin-hls-quality.js v1.0.0 + * artplayer-plugin-hls-quality.js v1.0.1 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2023 Harvey Zack * Released under the MIT License. */ -!function(e,t,n,o,r){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l[o]&&l[o],u=i.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,n){if(!u[t]){if(!e[t]){var r="function"==typeof l[o]&&l[o];if(!n&&r)return r(t,!0);if(i)return i(t,!0);if(f&&"string"==typeof t)return f(t);var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s}c.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},c.cache={};var a=u[t]=new d.Module(t);e[t][0].call(a.exports,c,a,a.exports,this)}return u[t].exports;function c(e){var t=c.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=e,d.cache=u,d.parent=i,d.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(d,"root",{get:function(){return l[o]}}),l[o]=d;for(var s=0;s{const{$video:n}=t.template,{errorHandle:o}=t.constructor.utils;return t.on("ready",(function(){const r=t.hls||window.hls;o(r&&r.media===n,'Cannot find instance of HLS from "art.hls" or "window.hls"');const i=e.auto||"Auto",u=e.title||"Quality",f=r.levels[r.currentLevel],d=f?f.height+"P":i;e.control&&t.controls.add({name:"hls-quality",position:"right",html:d,style:{padding:"0 10px"},selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:e=>(r.nextLevel=e.level,e.html)}),e.setting&&t.setting.add({name:"hls-quality",tooltip:d,html:u,icon:l.default,width:200,selector:r.levels.map(((e,t)=>({html:e.height+"P",level:e.level||t,default:f===e}))),onSelect:function(e){return r.nextLevel=e.level,e.html}})})),{name:"artplayerPluginHlsQuality"}}}n.default=i,i.env="production",i.version="1.0.0",i.build="2023-01-26 15:27:11","undefined"!=typeof window&&(window.artplayerPluginHlsQuality=i)},{"bundle-text:./image.svg":"9cAMb","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"9cAMb":[function(e,t,n){t.exports=''},{}],"47PTV":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["3yim4"],"3yim4","parcelRequire4dc0"); \ No newline at end of file +!function(e,t,n,r,o){var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0,u=i.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,n){if(!u[t]){if(!e[t]){var r="function"==typeof l.parcelRequire4dc0&&l.parcelRequire4dc0;if(!n&&r)return r(t,!0);if(i)return i(t,!0);if(f&&"string"==typeof t)return f(t);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var d=u[t]=new c.Module(t);e[t][0].call(d.exports,a,d,d.exports,this)}return u[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.exports={}},c.modules=e,c.cache=u,c.parent=i,c.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(c,"root",{get:function(){return l.parcelRequire4dc0}}),l.parcelRequire4dc0=c;for(var d=0;d'},{}],"47PTV":[function(e,t,n){n.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},n.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.exportAll=function(e,t){return Object.keys(e).forEach((function(n){"default"===n||"__esModule"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t},n.export=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:n})}},{}]},["3yim4"],"3yim4"); \ No newline at end of file diff --git a/packages/artplayer-plugin-hls-quality/package.json b/packages/artplayer-plugin-hls-quality/package.json index 85c1a8c63..e8fee23a9 100644 --- a/packages/artplayer-plugin-hls-quality/package.json +++ b/packages/artplayer-plugin-hls-quality/package.json @@ -1,6 +1,6 @@ { "license": "MIT", - "version": "1.0.0", + "version": "1.0.1", "name": "artplayer-plugin-hls-quality", "types": "types/artplayer-plugin-hls-quality.d.ts", "description": "Iframe plugin for ArtPlayer", @@ -21,4 +21,4 @@ "video", "player" ] -} +} \ No newline at end of file diff --git a/packages/artplayer-plugin-hls-quality/src/index.js b/packages/artplayer-plugin-hls-quality/src/index.js index 589f3f808..25a2440be 100644 --- a/packages/artplayer-plugin-hls-quality/src/index.js +++ b/packages/artplayer-plugin-hls-quality/src/index.js @@ -10,8 +10,9 @@ export default function artplayerPluginHlsQuality(option) { errorHandle(hls && hls.media === $video, 'Cannot find instance of HLS from "art.hls" or "window.hls"'); const auto = option.auto || 'Auto'; const title = option.title || 'Quality'; + const getResolution = option.getResolution || ((level) => (level.height || 'Unknown ') + 'P'); const defaultLevel = hls.levels[hls.currentLevel]; - const defaultHtml = defaultLevel ? defaultLevel.height + 'P' : auto; + const defaultHtml = defaultLevel ? getResolution(defaultLevel) : auto; if (option.control) { art.controls.add({ @@ -21,7 +22,7 @@ export default function artplayerPluginHlsQuality(option) { style: { padding: '0 10px' }, selector: hls.levels.map((item, index) => { return { - html: item.height + 'P', + html: getResolution(item), level: item.level || index, default: defaultLevel === item, }; @@ -42,7 +43,7 @@ export default function artplayerPluginHlsQuality(option) { width: 200, selector: hls.levels.map((item, index) => { return { - html: item.height + 'P', + html: getResolution(item), level: item.level || index, default: defaultLevel === item, }; diff --git a/packages/artplayer-plugin-hls-quality/types/artplayer-plugin-hls-quality.d.ts b/packages/artplayer-plugin-hls-quality/types/artplayer-plugin-hls-quality.d.ts index 1c4404deb..9b7c66f9b 100644 --- a/packages/artplayer-plugin-hls-quality/types/artplayer-plugin-hls-quality.d.ts +++ b/packages/artplayer-plugin-hls-quality/types/artplayer-plugin-hls-quality.d.ts @@ -8,6 +8,7 @@ declare const artplayerPluginHlsQuality: (option: { setting?: boolean; title?: string; auto?: string; + getResolution?(level: any): String; }) => (art: Artplayer) => { name: 'artplayerPluginHlsQuality'; };