diff --git a/README.md b/README.md index dd408d9b2..9c56fb96f 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ var art = new Artplayer({ - [artplayer-plugin-ads](https://artplayer.org/?libs=./uncompiled/artplayer-plugin-ads/index.js&example=ads) (WIP) - [artplayer-plugin-iframe](https://artplayer.org/?libs=./uncompiled/artplayer-plugin-iframe/index.js&example=iframe) - [artplayer-plugin-hls-control](https://artplayer.org/?libs=https://cdnjs.cloudflare.com/ajax/libs/hls.js/8.0.0-beta.3/hls.min.js%0A./uncompiled/artplayer-plugin-hls-control/index.js&example=hls.control) -- [artplayer-plugin-dash-quality](https://artplayer.org/?libs=https://cdnjs.cloudflare.com/ajax/libs/dashjs/4.5.2/dash.all.min.js%0A./uncompiled/artplayer-plugin-dash-quality/index.js&example=dash.quality) +- [artplayer-plugin-dash-control](https://artplayer.org/?libs=https://cdnjs.cloudflare.com/ajax/libs/dashjs/4.5.2/dash.all.min.js%0A./uncompiled/artplayer-plugin-dash-control/index.js&example=dash.control) - [artplayer-plugin-vtt-thumbnail](https://artplayer.org/?libs=./uncompiled/artplayer-plugin-vtt-thumbnail/index.js&example=vtt.thumbnail) - [artplayer-plugin-multiple-subtitles](https://artplayer.org/?libs=./uncompiled/artplayer-plugin-multiple-subtitles/index.js&example=multiple.subtitles) - [artplayer-plugin-libass](https://artplayer.org/?libs=./uncompiled/artplayer-plugin-libass/index.js&example=libass) diff --git a/docs/assets/example/dash.control.js b/docs/assets/example/dash.control.js new file mode 100644 index 000000000..aca70d14c --- /dev/null +++ b/docs/assets/example/dash.control.js @@ -0,0 +1,50 @@ +// npm i dashjs +// npm i artplayer-plugin-dash-control + +// import dashjs from 'dashjs'; +// import artplayerPluginDashControl from 'artplayer-plugin-dash-control'; + +var art = new Artplayer({ + container: '.artplayer-app', + url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd', + setting: true, + plugins: [ + artplayerPluginDashControl({ + quality: { + // Show qualitys in control + control: true, + // Show qualitys in setting + setting: true, + // Get the quality name from level + getName: (level) => level.height + 'P', + // I18n + title: 'Quality', + auto: 'Auto', + }, + audio: { + // Show audios in control + control: true, + // Show audios in setting + setting: true, + // Get the audio name from track + getName: (track) => track.name, + // I18n + title: 'Audio', + auto: 'Auto', + } + }), + ], + customType: { + mpd: function playMpd(video, url, art) { + if (dashjs.supportsMediaSource()) { + if (art.dash) art.dash.destroy(); + const dash = dashjs.MediaPlayer().create(); + dash.initialize(video, url, art.option.autoplay); + art.dash = dash; + art.on('destroy', () => dash.destroy()); + } else { + art.notice.show = 'Unsupported playback format: mpd'; + } + } + }, +}); diff --git a/docs/assets/example/dash.quality.js b/docs/assets/example/dash.quality.js deleted file mode 100644 index bbc98b774..000000000 --- a/docs/assets/example/dash.quality.js +++ /dev/null @@ -1,40 +0,0 @@ -// npm i dashjs -// npm i artplayer-plugin-dash-quality - -// import dashjs from 'dashjs'; -// import artplayerPluginDashQuality from 'artplayer-plugin-dash-quality'; - -var art = new Artplayer({ - container: '.artplayer-app', - url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd', - setting: true, - plugins: [ - artplayerPluginDashQuality({ - // Show quality in control - control: true, - - // Show quality in setting - setting: true, - - // Get the resolution text from level - getResolution: (level) => level.height + 'P', - - // I18n - title: 'Quality', - auto: 'Auto', - }), - ], - customType: { - mpd: function playMpd(video, url, art) { - if (dashjs.supportsMediaSource()) { - if (art.dash) art.dash.destroy(); - const dash = dashjs.MediaPlayer().create(); - dash.initialize(video, url, art.option.autoplay); - art.dash = dash; - art.on('destroy', () => dash.destroy()); - } else { - art.notice.show = 'Unsupported playback format: mpd'; - } - } - }, -}); diff --git a/docs/index.html b/docs/index.html index 6b97d42e0..ebd8f0b32 100644 --- a/docs/index.html +++ b/docs/index.html @@ -73,7 +73,7 @@
  • artplayer-plugin-dash-quality + href="/?libs=https://cdnjs.cloudflare.com/ajax/libs/dashjs/4.5.2/dash.all.min.js%0A./uncompiled/artplayer-plugin-dash-control/index.js&example=dash.control">artplayer-plugin-dash-control
  • numeric require +// +// anything defined in a previous bundle is accessed via the +// orig method which is the require for previous bundles + +(function (modules, entry, mainEntry, parcelRequireName, globalName) { + /* eslint-disable no-undef */ + var globalObject = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; + /* eslint-enable no-undef */ + + // Save the require from previous bundle to this closure if any + var previousRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + + var cache = previousRequire.cache || {}; + // Do not use `require` to prevent Webpack from trying to bundle this call + var nodeRequire = + typeof module !== 'undefined' && + typeof module.require === 'function' && + module.require.bind(module); + + function newRequire(name, jumped) { + if (!cache[name]) { + if (!modules[name]) { + // if we cannot find the module within our internal map or + // cache jump to the current global require ie. the last bundle + // that was added to the page. + var currentRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + if (!jumped && currentRequire) { + return currentRequire(name, true); + } + + // If there are other bundles on this page the require from the + // previous one is saved to 'previousRequire'. Repeat this as + // many times as there are bundles until the module is found or + // we exhaust the require chain. + if (previousRequire) { + return previousRequire(name, true); + } + + // Try the node require function if it exists. + if (nodeRequire && typeof name === 'string') { + return nodeRequire(name); + } + + var err = new Error("Cannot find module '" + name + "'"); + err.code = 'MODULE_NOT_FOUND'; + throw err; + } + + localRequire.resolve = resolve; + localRequire.cache = {}; + + var module = (cache[name] = new newRequire.Module(name)); + + modules[name][0].call( + module.exports, + localRequire, + module, + module.exports, + this + ); + } + + return cache[name].exports; + + function localRequire(x) { + var res = localRequire.resolve(x); + return res === false ? {} : newRequire(res); + } + + function resolve(x) { + var id = modules[name][1][x]; + return id != null ? id : x; + } + } + + function Module(moduleName) { + this.id = moduleName; + this.bundle = newRequire; + this.exports = {}; + } + + newRequire.isParcelRequire = true; + newRequire.Module = Module; + newRequire.modules = modules; + newRequire.cache = cache; + newRequire.parent = previousRequire; + newRequire.register = function (id, exports) { + modules[id] = [ + function (require, module) { + module.exports = exports; + }, + {}, + ]; + }; + + Object.defineProperty(newRequire, 'root', { + get: function () { + return globalObject[parcelRequireName]; + }, + }); + + globalObject[parcelRequireName] = newRequire; + + for (var i = 0; i < entry.length; i++) { + newRequire(entry[i]); + } + + if (mainEntry) { + // Expose entry point to Node, AMD or browser globals + // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js + var mainExports = newRequire(mainEntry); + + // CommonJS + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = mainExports; + + // RequireJS + } else if (typeof define === 'function' && define.amd) { + define(function () { + return mainExports; + }); + + //