update docs

This commit is contained in:
Harvey Zack committed 2023-04-23 00:21:38 +08:00
1 parent 7c8a3c2c7d
commit 3b57470957
14 files changed
+29 -46

No files matched your search

@@ -9,13 +9,11 @@
```js{18-21,25}
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);
// optional
art.dash = dash;
art.once('url', () => dash.destroy());
art.once('destroy', () => dash.destroy());
art.on('destroy', () => dash.destroy());
} else {
art.notice.show = 'Unsupported playback format: mpd';
}
@@ -9,14 +9,12 @@
```js{19-22,26}
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();
// optional
art.flv = flv;
art.once('url', () => flv.destroy());
art.once('destroy', () => flv.destroy());
art.on('destroy', () => flv.destroy());
} else {
art.notice.show = 'Unsupported playback format: flv';
}
@@ -9,14 +9,12 @@
```js{21-24,28}
function playM3u8(video, url, art) {
if (Hls.isSupported()) {
if (art.hls) art.hls.destroy();
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
// optional
art.hls = hls;
art.once('url', () => hls.destroy());
art.once('destroy', () => hls.destroy());
art.on('destroy', () => hls.destroy());
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
} else {
@@ -8,6 +8,7 @@
```js{21-24,28}
function playTorrent(video, url, art) {
if (art.torrent) art.torrent.destroy();
const torrent = new WebTorrent();
torrent.add(url, function (torrent) {
var file = torrent.files[0];
@@ -15,11 +16,8 @@ function playTorrent(video, url, art) {
autoplay: art.option.autoplay,
});
});
// optional
art.torrent = torrent;
art.once('url', () => torrent.destroy());
art.once('destroy', () => torrent.destroy());
art.on('destroy', () => torrent.destroy());
}
var art = new Artplayer({
@@ -9,13 +9,11 @@
```js{18-21,25}
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);
// optional
art.dash = dash;
art.once('url', () => dash.destroy());
art.once('destroy', () => dash.destroy());
art.on('destroy', () => dash.destroy());
} else {
art.notice.show = 'Unsupported playback format: mpd';
}
@@ -9,14 +9,12 @@
```js{19-22,26}
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();
// optional
art.flv = flv;
art.once('url', () => flv.destroy());
art.once('destroy', () => flv.destroy());
art.on('destroy', () => flv.destroy());
} else {
art.notice.show = 'Unsupported playback format: flv';
}
@@ -9,14 +9,12 @@
```js{21-24,28}
function playM3u8(video, url, art) {
if (Hls.isSupported()) {
if (art.hls) art.hls.destroy();
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
// optional
art.hls = hls;
art.once('url', () => hls.destroy());
art.once('destroy', () => hls.destroy());
art.on('destroy', () => hls.destroy());
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
} else {
@@ -8,6 +8,7 @@
```js{21-24,28}
function playTorrent(video, url, art) {
if (art.torrent) art.torrent.destroy();
const torrent = new WebTorrent();
torrent.add(url, function (torrent) {
var file = torrent.files[0];
@@ -15,11 +16,8 @@ function playTorrent(video, url, art) {
autoplay: art.option.autoplay,
});
});
// optional
art.torrent = torrent;
art.once('url', () => torrent.destroy());
art.once('destroy', () => torrent.destroy());
art.on('destroy', () => torrent.destroy());
}
var art = new Artplayer({
-1
View File
@@ -26,7 +26,6 @@ export default function urlMix(art) {
if (oldUrl !== art.url) {
art.option.url = url;
art.emit('url', url);
if (art.isReady && oldUrl) {
art.once('video:canplay', () => {
art.emit('restart', url);
+1 -1
View File
@@ -9,8 +9,8 @@ import {
removeClass,
inverseClass,
createElement,
isStringOrNumber,
} from './dom';
import { isStringOrNumber } from './format';
import { errorHandle } from './error';
import validator from 'option-validator';
import { ComponentOption } from '../scheme';