mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-09 17:58:21 +00:00
Add a hacky audio support.
This commit is contained in:
parent
5e76940c39
commit
19a134b441
@ -55,6 +55,7 @@ export default {
|
||||
title: "Loading...",
|
||||
},
|
||||
player: null,
|
||||
audioplayer: null,
|
||||
sponsors: null,
|
||||
};
|
||||
},
|
||||
@ -66,10 +67,15 @@ export default {
|
||||
if (this.player) {
|
||||
this.player.dispose();
|
||||
}
|
||||
if (this.audioplayer) {
|
||||
this.audioplayer.pause()
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"$route.query.v": function (v) {
|
||||
if (v) {
|
||||
if (this.audioplayer)
|
||||
this.audioplayer.pause()
|
||||
this.getVideoData();
|
||||
this.getSponsors();
|
||||
}
|
||||
@ -126,6 +132,14 @@ export default {
|
||||
|
||||
var src = [];
|
||||
|
||||
if (this.video.livestream) {
|
||||
|
||||
src.push({
|
||||
src: this.video.hls,
|
||||
type: 'application/x-mpegURL'
|
||||
})
|
||||
|
||||
} else {
|
||||
this.video.videoStreams.map((stream) =>
|
||||
src.push({
|
||||
src: stream.url,
|
||||
@ -141,10 +155,13 @@ export default {
|
||||
label: stream.quality,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
this.audioplayer = new Audio((this.video.audioStreams.slice(-1)[0].url));
|
||||
|
||||
this.player.src(src);
|
||||
|
||||
if (noPrevPlayer)
|
||||
if (noPrevPlayer) {
|
||||
this.player.on('timeupdate', () => {
|
||||
if (this.sponsors && this.sponsors.segments) {
|
||||
const time = this.player.currentTime()
|
||||
@ -153,13 +170,36 @@ export default {
|
||||
const end = segment.segment[1]
|
||||
if (time >= segment.segment[0] && time < end) {
|
||||
this.player.currentTime(end)
|
||||
this.audioplayer.currentTime = end
|
||||
segment.skipped = true
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (this.audioplayer) {
|
||||
if (Math.abs(this.audioplayer.currentTime - this.player.currentTime()) > 0.25) {
|
||||
this.audioplayer.currentTime = this.player.currentTime()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.player.on('play', () => {
|
||||
this.audioplayer.play()
|
||||
});
|
||||
|
||||
this.player.on('pause', () => {
|
||||
this.audioplayer.currentTime = this.player.currentTime()
|
||||
this.audioplayer.pause()
|
||||
});
|
||||
|
||||
this.player.on('volumechange', () => {
|
||||
this.audioplayer.volume = this.player.volume()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if (!noPrevPlayer)
|
||||
this.player.remoteTextTracks().map(track => this.player.removeRemoteTextTrack(track));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user