Skip to main content

第三方库

flv.js

▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
autoplay: true,
url: '/assets/sample/video.flv',
customType: {
flv: function (video, url) {
if (flvjs.isSupported()) {
const flvPlayer = flvjs.createPlayer({
type: 'flv',
url: url,
});
flvPlayer.attachMediaElement(video);
flvPlayer.load();
} else {
art.notice.show = '不支持播放格式:flv';
}
},
},
});

hls.js

▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
autoplay: true,
url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
customType: {
m3u8: function (video, url) {
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
} else {
const canPlay = video.canPlayType('application/vnd.apple.mpegurl');
if (canPlay === 'probably' || canPlay == 'maybe') {
video.src = url;
} else {
art.notice.show = '不支持播放格式:m3u8';
}
}
},
},
});

dash.js

▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
autoplay: true,
url: 'https://dash.akamaized.net/envivio/EnvivioDash3/manifest.mpd',
customType: {
mpd: function (video, url) {
var player = dashjs.MediaPlayer().create();
player.initialize(video, url, true);
},
},
});

shaka-player

▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
autoplay: true,
url: '//storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd',
customType: {
mpd: function (video, url) {
shaka.polyfill.installAll();
var player = new shaka.Player(video);
player.load(url);
},
},
});

webtorrent

▶ Run Code
var art = new Artplayer({
container: '.artplayer-app',
autoplay: true,
url: 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4',
type: 'torrent',
customType: {
torrent: function (video, url, art) {
var client = new WebTorrent();
art.loading.show = true;
client.add(url, function (torrent) {
var file = torrent.files[0];
file.renderTo(video, {
autoplay: true,
});
});
},
},
});

art.on('ready', () => {
art.template.$video.controls = false;
});