tangled
alpha
login
or
join now
dunkirk.sh
/
pstream-ng
1
fork
atom
pstream is dead; long live pstream
taciturnaxolotl.github.io/pstream-ng/
1
fork
atom
overview
issues
pulls
pipelines
Revert testview to how it was before
vlOd2
2 months ago
ceecfc7a
ca61d3b9
+2
-71
1 changed file
expand all
collapse all
unified
split
src
pages
developer
TestView.tsx
+2
-71
src/pages/developer/TestView.tsx
···
1
1
-
import { useCallback, useState } from "react";
1
1
+
import { useState } from "react";
2
2
3
3
import { Button } from "@/components/buttons/Button";
4
4
-
import { usePlayer } from "@/components/player/hooks/usePlayer";
5
5
-
import { PlaybackErrorPart } from "@/pages/parts/player/PlaybackErrorPart";
6
6
-
import { PlayerPart } from "@/pages/parts/player/PlayerPart";
7
7
-
import {
8
8
-
CaptionListItem,
9
9
-
PlayerMeta,
10
10
-
playerStatus,
11
11
-
} from "@/stores/player/slices/source";
12
12
-
import { SourceSliceSource } from "@/stores/player/utils/qualities";
13
13
-
14
14
-
const subtitlesTestMeta: PlayerMeta = {
15
15
-
type: "movie",
16
16
-
title: "Subtitles Test",
17
17
-
releaseYear: 2024,
18
18
-
tmdbId: "0",
19
19
-
};
20
20
-
21
21
-
const subtitlesTestSource: SourceSliceSource = {
22
22
-
type: "hls",
23
23
-
url: "http://localhost:8000/media/master.m3u8",
24
24
-
};
25
25
-
26
26
-
const subtitlesTestSubs: CaptionListItem[] = [
27
27
-
{
28
28
-
id: "http://localhost:8000/subs/en.srt",
29
29
-
display: "English",
30
30
-
language: "en",
31
31
-
url: "http://localhost:8000/subs/en.srt",
32
32
-
needsProxy: false,
33
33
-
},
34
34
-
{
35
35
-
id: "http://localhost:8000/subs/en-small.srt",
36
36
-
display: "English Small",
37
37
-
language: "en",
38
38
-
url: "http://localhost:8000/subs/en-small.srt",
39
39
-
needsProxy: false,
40
40
-
},
41
41
-
{
42
42
-
id: "http://localhost:8000/subs/ro.srt",
43
43
-
display: "Romanian",
44
44
-
language: "ro",
45
45
-
url: "http://localhost:8000/subs/ro.srt",
46
46
-
needsProxy: false,
47
47
-
},
48
48
-
];
49
4
50
5
// mostly empty view, add whatever you need
51
6
export default function TestView() {
52
52
-
const player = usePlayer();
53
53
-
const [showPlayer, setShowPlayer] = useState(false);
54
7
const [shouldCrash, setShouldCrash] = useState(false);
55
8
56
9
if (shouldCrash) {
57
10
throw new Error("I crashed");
58
11
}
59
12
60
60
-
const subtitlesTest = useCallback(async () => {
61
61
-
setShowPlayer(true);
62
62
-
player.reset();
63
63
-
await new Promise((r) => {
64
64
-
setTimeout(r, 100);
65
65
-
});
66
66
-
player.setShouldStartFromBeginning(true);
67
67
-
player.setMeta(subtitlesTestMeta);
68
68
-
player.playMedia(subtitlesTestSource, subtitlesTestSubs, null);
69
69
-
}, [player]);
70
70
-
71
71
-
return showPlayer ? (
72
72
-
<PlayerPart backUrl="/dev/">
73
73
-
{player && (player as any).status === playerStatus.PLAYBACK_ERROR ? (
74
74
-
<PlaybackErrorPart />
75
75
-
) : null}
76
76
-
</PlayerPart>
77
77
-
) : (
78
78
-
<>
79
79
-
<Button onClick={() => setShouldCrash(true)}>Crash me!</Button>
80
80
-
<Button onClick={() => subtitlesTest()}>Subtitles test</Button>
81
81
-
</>
82
82
-
);
13
13
+
return <Button onClick={() => setShouldCrash(true)}>Crash me!</Button>;
83
14
}