diff --git a/package.json b/package.json index bc1f01695..8c1c88b18 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "mark.js": "^8.11.1", "mitt": "^3.0.1", "monaco-editor": "0.55.1", - "mpegts.js": "^1.8.0", + "mpegts.js": "github:OpenListTeam/mpegts.js#1e51e0f6f918cf08e05dfae9c7bfcf658d6b4ac2", "qrcode": "^1.5.4", "rehype-katex": "7.0.1", "rehype-raw": "^7.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 849437169..7182d0723 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -117,8 +117,8 @@ importers: specifier: 0.55.1 version: 0.55.1 mpegts.js: - specifier: ^1.8.0 - version: 1.8.0 + specifier: github:OpenListTeam/mpegts.js#1e51e0f6f918cf08e05dfae9c7bfcf658d6b4ac2 + version: https://codeload.github.com/OpenListTeam/mpegts.js/tar.gz/1e51e0f6f918cf08e05dfae9c7bfcf658d6b4ac2 qrcode: specifier: ^1.5.4 version: 1.5.4 @@ -2911,8 +2911,9 @@ packages: monaco-editor@0.55.1: resolution: {integrity: sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==} - mpegts.js@1.8.0: - resolution: {integrity: sha512-ZtujqtmTjWgcDDkoOnLvrOKUTO/MKgLHM432zGDI8oPaJ0S+ebPxg1nEpDpLw6I7KmV/GZgUIrfbWi3qqEircg==} + mpegts.js@https://codeload.github.com/OpenListTeam/mpegts.js/tar.gz/1e51e0f6f918cf08e05dfae9c7bfcf658d6b4ac2: + resolution: {gitHosted: true, integrity: sha512-o+XY4uWTcXr6aDJOf6Et+zuWexpBYZxBCmn2tYI5+VWToK5Do6ueEc0c4xuetKA/MyvbavInkGZBgHLevEpfhw==, tarball: https://codeload.github.com/OpenListTeam/mpegts.js/tar.gz/1e51e0f6f918cf08e05dfae9c7bfcf658d6b4ac2} + version: 1.8.1 ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -3555,10 +3556,6 @@ packages: webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - webworkify-webpack@https://codeload.github.com/xqq/webworkify-webpack/tar.gz/24d1e719b4a6cac37a518b2bb10fe124527ef4ef: - resolution: {gitHosted: true, tarball: https://codeload.github.com/xqq/webworkify-webpack/tar.gz/24d1e719b4a6cac37a518b2bb10fe124527ef4ef} - version: 2.1.5 - whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} @@ -6719,10 +6716,9 @@ snapshots: dompurify: 3.2.7 marked: 14.0.0 - mpegts.js@1.8.0: + mpegts.js@https://codeload.github.com/OpenListTeam/mpegts.js/tar.gz/1e51e0f6f918cf08e05dfae9c7bfcf658d6b4ac2: dependencies: es6-promise: 4.2.8 - webworkify-webpack: https://codeload.github.com/xqq/webworkify-webpack/tar.gz/24d1e719b4a6cac37a518b2bb10fe124527ef4ef ms@2.1.3: {} @@ -7385,8 +7381,6 @@ snapshots: webidl-conversions@3.0.1: {} - webworkify-webpack@https://codeload.github.com/xqq/webworkify-webpack/tar.gz/24d1e719b4a6cac37a518b2bb10fe124527ef4ef: {} - whatwg-url@5.0.0: dependencies: tr46: 0.0.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index bfd92dc7d..486005a77 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,7 +1,10 @@ allowBuilds: "@swc/core": true core-js: true + mpegts.js: true patchedDependencies: # if https://github.com/chenxch/vite-plugin-dynamic-base/pull/36 is merged, # this patch can be removed vite-plugin-dynamic-base: patches/vite-plugin-dynamic-base.patch +onlyBuiltDependencies: + - mpegts.js diff --git a/src/pages/home/previews/video.tsx b/src/pages/home/previews/video.tsx index f1ebad170..84dd90522 100644 --- a/src/pages/home/previews/video.tsx +++ b/src/pages/home/previews/video.tsx @@ -132,6 +132,18 @@ const Preview = () => { flvPlayer.attachMediaElement(video) flvPlayer.load() }, + m2ts: function (video: HTMLMediaElement, url: string) { + flvPlayer?.destroy() + flvPlayer = mpegts.createPlayer( + { + type: "m2ts", + url: url, + }, + { referrerPolicy: "same-origin" }, + ) + flvPlayer.attachMediaElement(video) + flvPlayer.load() + }, m3u8: function (video: HTMLMediaElement, url: string) { hlsPlayer?.destroy() hlsPlayer = new Hls()