mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:53:25 +00:00
chore: cleanup
This commit is contained in:
@@ -169,7 +169,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
|
|
||||||
let highestQuality;
|
let highestQuality;
|
||||||
let url;
|
let url;
|
||||||
let tracks;
|
let _tracks;
|
||||||
|
|
||||||
switch (stream.type) {
|
switch (stream.type) {
|
||||||
case "file":
|
case "file":
|
||||||
@@ -178,16 +178,12 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
return url ?? null;
|
return url ?? null;
|
||||||
case "hls":
|
case "hls":
|
||||||
url = stream.playlist;
|
url = stream.playlist;
|
||||||
tracks = await extractTracksFromHLS(url, {
|
_tracks = await extractTracksFromHLS(url, {
|
||||||
...stream.preferredHeaders,
|
...stream.preferredHeaders,
|
||||||
...stream.headers,
|
...stream.headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tracks) {
|
|
||||||
console.log(tracks);
|
|
||||||
}
|
|
||||||
|
|
||||||
setVideoSrc({
|
setVideoSrc({
|
||||||
uri: url,
|
uri: url,
|
||||||
headers: {
|
headers: {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import type { Item } from "parse-hls";
|
||||||
import hls from "parse-hls";
|
import hls from "parse-hls";
|
||||||
import { default as toWebVTT } from "srt-webvtt";
|
import { default as toWebVTT } from "srt-webvtt";
|
||||||
|
|
||||||
@@ -105,10 +106,16 @@ export function findHighestQuality(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface HLSPlaylist {
|
||||||
|
video: Item[];
|
||||||
|
audio: Item[];
|
||||||
|
subtitles: Item[];
|
||||||
|
}
|
||||||
|
|
||||||
export async function extractTracksFromHLS(
|
export async function extractTracksFromHLS(
|
||||||
playlistUrl: string,
|
playlistUrl: string,
|
||||||
headers: Record<string, string>,
|
headers: Record<string, string>,
|
||||||
) {
|
): Promise<HLSPlaylist | null> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(playlistUrl, { headers }).then((res) =>
|
const response = await fetch(playlistUrl, { headers }).then((res) =>
|
||||||
res.text(),
|
res.text(),
|
||||||
|
Reference in New Issue
Block a user