mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-13 07:46:17 -08:00
docs(dash): [SITE-DASH-01] add bilingual guides and fix example lifecycle
This commit is contained in:
1 parent
4ea0ba94ae
commit
319dccb605
70 files changed
+4005
-1695
No files matched your search
@@ -4,45 +4,55 @@
|
||||
// import dashjs from 'dashjs';
|
||||
// import artplayerPluginDashControl from 'artplayer-plugin-dash-control';
|
||||
|
||||
const useDash = dashjs.supportsMediaSource()
|
||||
let dash
|
||||
|
||||
function destroyDash() {
|
||||
const previous = dash
|
||||
dash = undefined
|
||||
if (previous)
|
||||
previous.destroy()
|
||||
}
|
||||
|
||||
const art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: 'https://media.axprod.net/TestVectors/v7-Clear/Manifest_1080p.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.lang.toUpperCase(),
|
||||
// I18n
|
||||
title: 'Audio',
|
||||
auto: 'Auto',
|
||||
},
|
||||
}),
|
||||
],
|
||||
plugins: useDash
|
||||
? [
|
||||
artplayerPluginDashControl({
|
||||
quality: {
|
||||
// Show quality choices in the controls
|
||||
control: true,
|
||||
// Show quality choices in settings
|
||||
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.lang?.toUpperCase() || String(track.id ?? 'Audio'),
|
||||
// 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)
|
||||
destroyDash()
|
||||
if (useDash) {
|
||||
dash = dashjs.MediaPlayer().create()
|
||||
art.dash = dash
|
||||
art.on('destroy', () => dash.destroy())
|
||||
dash.initialize(video, url, art.option.autoplay)
|
||||
}
|
||||
else {
|
||||
art.notice.show = 'Unsupported playback format: mpd'
|
||||
@@ -50,3 +60,5 @@ const art = new Artplayer({
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
art.on('destroy', destroyDash)
|
||||
Reference in new issue
Block a user