WebTorrent supporting judgement
This commit is contained in:
parent
5a12be0554
commit
8e69adab3c
|
|
@ -374,17 +374,22 @@ class DPlayer {
|
|||
// https://github.com/webtorrent/webtorrent
|
||||
case 'webtorrent':
|
||||
if (WebTorrent) {
|
||||
this.container.classList.add('dplayer-loading');
|
||||
const client = new WebTorrent();
|
||||
const torrentId = video.src;
|
||||
client.add(torrentId, (torrent) => {
|
||||
const file = torrent.files.find((file) => file.name.endsWith('.mp4'));
|
||||
file.renderTo(this.video, {
|
||||
autoplay: this.options.autoplay
|
||||
}, () => {
|
||||
this.container.classList.remove('dplayer-loading');
|
||||
if (WebTorrent.WEBRTC_SUPPORT) {
|
||||
this.container.classList.add('dplayer-loading');
|
||||
const client = new WebTorrent();
|
||||
const torrentId = video.src;
|
||||
client.add(torrentId, (torrent) => {
|
||||
const file = torrent.files.find((file) => file.name.endsWith('.mp4'));
|
||||
file.renderTo(this.video, {
|
||||
autoplay: this.options.autoplay
|
||||
}, () => {
|
||||
this.container.classList.remove('dplayer-loading');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.notice('Error: Webtorrent is not supported.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.notice('Error: Can\'t find Webtorrent.');
|
||||
|
|
|
|||
Loading…
Reference in New Issue