mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 04:31:20 -08:00
35 lines
836 B
Markdown
35 lines
836 B
Markdown
# flv.js
|
|
|
|
👉 [https://github.com/Bilibili/flv.js](https://github.com/Bilibili/flv.js)
|
|
|
|
<div className="run-code" data-libs="https://cdnjs.cloudflare.com/ajax/libs/flv.js/1.6.2/flv.min.js">
|
|
▶ Run Code
|
|
</div>
|
|
|
|
```js{19,24}
|
|
function playFlv(video, url, art) {
|
|
if (flvjs.isSupported()) {
|
|
if (art.flv) art.flv.destroy();
|
|
const flv = flvjs.createPlayer({ type: 'flv', url });
|
|
flv.attachMediaElement(video);
|
|
flv.load();
|
|
art.flv = flv;
|
|
art.on('destroy', () => flv.destroy());
|
|
} else {
|
|
art.notice.show = 'Unsupported playback format: flv';
|
|
}
|
|
}
|
|
|
|
var art = new Artplayer({
|
|
container: '.artplayer-app',
|
|
url: '/assets/sample/video.flv',
|
|
type: 'flv',
|
|
customType: {
|
|
flv: playFlv,
|
|
},
|
|
});
|
|
|
|
art.on('ready', () => {
|
|
console.info(art.flv);
|
|
});
|
|
``` |