feat: pluginOptions flv mediaDataSource and config
This commit is contained in:
parent
2ed6ef8912
commit
af4d697b19
|
|
@ -598,7 +598,13 @@ const dp = new DPlayer({
|
|||
},
|
||||
pluginOptions: {
|
||||
flv: {
|
||||
// flv config
|
||||
// refer to https://github.com/bilibili/flv.js/blob/master/docs/api.md#flvjscreateplayer
|
||||
mediaDataSource: {
|
||||
// mediaDataSource config
|
||||
},
|
||||
config: {
|
||||
// config
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -582,7 +582,13 @@ const dp = new DPlayer({
|
|||
},
|
||||
pluginOptions: {
|
||||
flv: {
|
||||
// flv config
|
||||
// refer to https://github.com/bilibili/flv.js/blob/master/docs/api.md#flvjscreateplayer
|
||||
mediaDataSource: {
|
||||
// mediaDataSource config
|
||||
},
|
||||
config: {
|
||||
// config
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export default (options) => {
|
|||
video: {},
|
||||
contextmenu: [],
|
||||
mutex: true,
|
||||
pluginOptions: { hls: {}, flvjs: {}, dash: {}, webtorrent: {} },
|
||||
pluginOptions: { hls: {}, flv: {}, dash: {}, webtorrent: {} },
|
||||
};
|
||||
for (const defaultKey in defaultOption) {
|
||||
if (defaultOption.hasOwnProperty(defaultKey) && !options.hasOwnProperty(defaultKey)) {
|
||||
|
|
|
|||
|
|
@ -370,11 +370,13 @@ class DPlayer {
|
|||
case 'flv':
|
||||
if (window.flvjs) {
|
||||
if (window.flvjs.isSupported()) {
|
||||
const options = Object.assign(this.options.pluginOptions.flvjs, {
|
||||
type: 'flv',
|
||||
url: video.src,
|
||||
});
|
||||
const flvPlayer = window.flvjs.createPlayer(options);
|
||||
const flvPlayer = window.flvjs.createPlayer(
|
||||
Object.assign(this.options.pluginOptions.flv.mediaDataSource || {}, {
|
||||
type: 'flv',
|
||||
url: video.src,
|
||||
}),
|
||||
this.options.pluginOptions.flv.config
|
||||
);
|
||||
this.plugins.flvjs = flvPlayer;
|
||||
flvPlayer.attachMediaElement(video);
|
||||
flvPlayer.load();
|
||||
|
|
@ -395,10 +397,7 @@ class DPlayer {
|
|||
// https://github.com/Dash-Industry-Forum/dash.js
|
||||
case 'dash':
|
||||
if (window.dashjs) {
|
||||
const dashjsPlayer = window.dashjs
|
||||
.MediaPlayer()
|
||||
.create()
|
||||
.initialize(video, video.src, false);
|
||||
const dashjsPlayer = window.dashjs.MediaPlayer().create().initialize(video, video.src, false);
|
||||
const options = this.options.pluginOptions.dash;
|
||||
dashjsPlayer.updateSettings(options);
|
||||
this.plugins.dash = dashjsPlayer;
|
||||
|
|
@ -427,7 +426,7 @@ class DPlayer {
|
|||
const file = torrent.files.find((file) => file.name.endsWith('.mp4'));
|
||||
file.renderTo(this.video, {
|
||||
autoplay: this.options.autoplay,
|
||||
controls: false
|
||||
controls: false,
|
||||
});
|
||||
});
|
||||
this.events.on('destroy', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue