mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-25 15:07: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...",
|
title: "Loading...",
|
||||||
},
|
},
|
||||||
player: null,
|
player: null,
|
||||||
|
audioplayer: null,
|
||||||
sponsors: null,
|
sponsors: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -66,10 +67,15 @@ export default {
|
|||||||
if (this.player) {
|
if (this.player) {
|
||||||
this.player.dispose();
|
this.player.dispose();
|
||||||
}
|
}
|
||||||
|
if (this.audioplayer) {
|
||||||
|
this.audioplayer.pause()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
"$route.query.v": function (v) {
|
"$route.query.v": function (v) {
|
||||||
if (v) {
|
if (v) {
|
||||||
|
if (this.audioplayer)
|
||||||
|
this.audioplayer.pause()
|
||||||
this.getVideoData();
|
this.getVideoData();
|
||||||
this.getSponsors();
|
this.getSponsors();
|
||||||
}
|
}
|
||||||
@ -126,9 +132,17 @@ export default {
|
|||||||
|
|
||||||
var src = [];
|
var src = [];
|
||||||
|
|
||||||
this.video.videoStreams.map((stream) =>
|
if (this.video.livestream) {
|
||||||
|
|
||||||
src.push({
|
src.push({
|
||||||
src: stream.url,
|
src: this.video.hls,
|
||||||
|
type: 'application/x-mpegURL'
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.video.videoStreams.map((stream) =>
|
||||||
|
src.push({
|
||||||
|
src: stream.url,
|
||||||
type: stream.mimeType,
|
type: stream.mimeType,
|
||||||
label: stream.quality,
|
label: stream.quality,
|
||||||
})
|
})
|
||||||
@ -138,13 +152,16 @@ export default {
|
|||||||
src.push({
|
src.push({
|
||||||
src: stream.url,
|
src: stream.url,
|
||||||
type: stream.mimeType,
|
type: stream.mimeType,
|
||||||
label: stream.quality,
|
label: stream.quality,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.audioplayer = new Audio((this.video.audioStreams.slice(-1)[0].url));
|
||||||
|
|
||||||
this.player.src(src);
|
this.player.src(src);
|
||||||
|
|
||||||
if (noPrevPlayer)
|
if (noPrevPlayer) {
|
||||||
this.player.on('timeupdate', () => {
|
this.player.on('timeupdate', () => {
|
||||||
if (this.sponsors && this.sponsors.segments) {
|
if (this.sponsors && this.sponsors.segments) {
|
||||||
const time = this.player.currentTime()
|
const time = this.player.currentTime()
|
||||||
@ -153,13 +170,36 @@ export default {
|
|||||||
const end = segment.segment[1]
|
const end = segment.segment[1]
|
||||||
if (time >= segment.segment[0] && time < end) {
|
if (time >= segment.segment[0] && time < end) {
|
||||||
this.player.currentTime(end)
|
this.player.currentTime(end)
|
||||||
|
this.audioplayer.currentTime = end
|
||||||
segment.skipped = true
|
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)
|
if (!noPrevPlayer)
|
||||||
this.player.remoteTextTracks().map(track => this.player.removeRemoteTextTrack(track));
|
this.player.remoteTextTracks().map(track => this.player.removeRemoteTextTrack(track));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user