mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-22 13:37:23 +00:00
Add support for livestreams.
This commit is contained in:
parent
e528320b5c
commit
cc5c1258d4
@ -16,6 +16,7 @@
|
||||
"css-loader": "^5.2.6",
|
||||
"dompurify": "^2.2.9",
|
||||
"hotkeys-js": "^3.8.5",
|
||||
"mux.js": "^5.11.0",
|
||||
"register-service-worker": "^1.7.1",
|
||||
"shaka-player": "3.1.0",
|
||||
"uikit": "3.6.22",
|
||||
|
@ -9,6 +9,8 @@
|
||||
<script>
|
||||
import("shaka-player/dist/controls.css");
|
||||
const shaka = import("shaka-player/dist/shaka-player.ui.js");
|
||||
import muxjs from "mux.js";
|
||||
window.muxjs = muxjs;
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@ -24,6 +26,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
loadVideo() {
|
||||
const component = this;
|
||||
const videoEl = this.$refs.videoEl;
|
||||
|
||||
videoEl.setAttribute("poster", this.video.thumbnailUrl);
|
||||
@ -37,10 +40,18 @@ export default {
|
||||
streams.push(...this.video.audioStreams);
|
||||
streams.push(...this.video.videoStreams);
|
||||
|
||||
const dash = require("@/utils/DashUtils.js").default.generate_dash_file_from_formats(
|
||||
streams,
|
||||
this.video.duration,
|
||||
);
|
||||
var uri;
|
||||
|
||||
if (this.video.livestream) {
|
||||
uri = this.video.hls;
|
||||
} else {
|
||||
const dash = require("@/utils/DashUtils.js").default.generate_dash_file_from_formats(
|
||||
streams,
|
||||
this.video.duration,
|
||||
);
|
||||
|
||||
uri = "data:application/dash+xml;charset=utf-8;base64," + btoa(dash);
|
||||
}
|
||||
|
||||
if (noPrevPlayer)
|
||||
shaka
|
||||
@ -51,9 +62,19 @@ export default {
|
||||
|
||||
const localPlayer = new shaka.Player(videoEl);
|
||||
|
||||
this.setPlayerAttrs(localPlayer, videoEl, dash, shaka);
|
||||
localPlayer.getNetworkingEngine().registerRequestFilter((_type, request) => {
|
||||
const uri = request.uris[0];
|
||||
var url = new URL(uri);
|
||||
if (url.host.endsWith(".googlevideo.com")) {
|
||||
url.searchParams.set("host", url.host);
|
||||
url.host = new URL(component.video.proxyUrl).host;
|
||||
request.uris[0] = url.toString();
|
||||
}
|
||||
});
|
||||
|
||||
this.setPlayerAttrs(localPlayer, videoEl, uri, shaka);
|
||||
});
|
||||
else this.setPlayerAttrs(this.player, videoEl, dash, this.shaka);
|
||||
else this.setPlayerAttrs(this.player, videoEl, uri, this.shaka);
|
||||
|
||||
if (noPrevPlayer) {
|
||||
videoEl.addEventListener("timeupdate", () => {
|
||||
@ -85,7 +106,7 @@ export default {
|
||||
|
||||
//TODO: Add sponsors on seekbar: https://github.com/ajayyy/SponsorBlock/blob/e39de9fd852adb9196e0358ed827ad38d9933e29/src/js-components/previewBar.ts#L12
|
||||
},
|
||||
setPlayerAttrs(localPlayer, videoEl, dash, shaka) {
|
||||
setPlayerAttrs(localPlayer, videoEl, uri, shaka) {
|
||||
if (!this.ui) {
|
||||
this.ui = new shaka.ui.Overlay(localPlayer, this.$refs.container, videoEl);
|
||||
|
||||
@ -108,7 +129,7 @@ export default {
|
||||
if ((localStorage && localStorage.getItem("audioOnly") === "true") || this.$route.query.listen === "1")
|
||||
this.player.configure("manifest.disableVideo", true);
|
||||
|
||||
player.load("data:application/dash+xml;charset=utf-8;base64," + btoa(dash)).then(() => {
|
||||
player.load(uri).then(() => {
|
||||
this.video.subtitles.map(subtitle => {
|
||||
player.addTextTrackAsync(
|
||||
subtitle.url,
|
||||
|
14
yarn.lock
14
yarn.lock
@ -831,6 +831,13 @@
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
"@babel/runtime@^7.11.2":
|
||||
version "7.14.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.0.tgz#46794bc20b612c5f75e62dd071e24dfd95f1cbe6"
|
||||
integrity sha512-JELkvo/DlpNdJ7dlyw/eY7E0suy5i5GQH+Vlxaq1nsNJ+H7f4Vtv3jMeCEgRhZZQFXTjldYfQgv2qmM6M1v5wA==
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
"@babel/template@^7.0.0", "@babel/template@^7.12.13":
|
||||
version "7.12.13"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.13.tgz#530265be8a2589dbb37523844c5bcb55947fb327"
|
||||
@ -5807,6 +5814,13 @@ mute-stream@0.0.8:
|
||||
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
|
||||
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==
|
||||
|
||||
mux.js@^5.11.0:
|
||||
version "5.11.0"
|
||||
resolved "https://registry.yarnpkg.com/mux.js/-/mux.js-5.11.0.tgz#3c2c1fbd9d30720af2a1b12c1f2a2840c63100f6"
|
||||
integrity sha512-Q/iLfohHh5Pp6lW7EFtcxNuaCNJ3Ruywfy46pWLsY+yIxR1kXXImYY1wOhg8jLdBMs1kRaZqsiB4Zncsiw0a2Q==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.11.2"
|
||||
|
||||
mz@^2.4.0:
|
||||
version "2.7.0"
|
||||
resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32"
|
||||
|
Loading…
Reference in New Issue
Block a user