mega-stream-proxy 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -49
- package/dist/megaFile.js +22 -9
- package/dist/{Player/playerAndroid/MegaVideoPlayerAndroid.d.ts → player/MegaVideoPlayer.d.ts} +4 -13
- package/dist/player/MegaVideoPlayer.js +307 -0
- package/dist/{Player/playerweb → player}/PlayerControls.d.ts +2 -14
- package/dist/player/PlayerControls.js +289 -0
- package/dist/{Player/playerweb → player}/SubtitleDisplay.d.ts +3 -3
- package/dist/{Player/playerweb → player}/SubtitleDisplay.js +1 -1
- package/dist/player/index.d.ts +3 -0
- package/dist/player/index.js +3 -0
- package/dist/{Player/playerweb/MegaVideoPlayer.d.ts → playerweb/MegaVideoPlayerWeb.d.ts} +6 -18
- package/dist/{Player/playerweb/MegaVideoPlayer.js → playerweb/MegaVideoPlayerWeb.js} +18 -18
- package/dist/{Player/playerAndroid/PlayerControlsAndroid.d.ts → playerweb/PlayerControlsWeb.d.ts} +2 -16
- package/dist/playerweb/PlayerControlsWeb.js +289 -0
- package/dist/playerweb/SubtitleDisplayWeb.d.ts +15 -0
- package/dist/playerweb/SubtitleDisplayWeb.js +32 -0
- package/dist/playerweb/index.d.ts +3 -0
- package/dist/playerweb/index.js +3 -0
- package/dist/proxy/native.js +11 -3
- package/expo-module.config.json +3 -0
- package/package.json +15 -18
- package/src/megaFile.ts +28 -15
- package/src/player/MegaVideoPlayer.tsx +474 -0
- package/src/{Player/playerweb → player}/PlayerControls.tsx +200 -369
- package/src/{Player/playerweb → player}/SubtitleDisplay.tsx +3 -3
- package/src/player/index.ts +7 -0
- package/src/{Player/playerweb/MegaVideoPlayer.tsx → playerweb/MegaVideoPlayerWeb.tsx} +41 -58
- package/src/playerweb/PlayerControlsWeb.tsx +629 -0
- package/src/playerweb/SubtitleDisplayWeb.tsx +48 -0
- package/src/playerweb/index.ts +3 -0
- package/src/proxy/native.ts +10 -3
- package/dist/Player/native.d.ts +0 -3
- package/dist/Player/native.js +0 -3
- package/dist/Player/playerAndroid/MegaVideoPlayerAndroid.js +0 -624
- package/dist/Player/playerAndroid/PlayerControlsAndroid.js +0 -370
- package/dist/Player/playerAndroid/SubtitleDisplayAndroid.d.ts +0 -21
- package/dist/Player/playerAndroid/SubtitleDisplayAndroid.js +0 -55
- package/dist/Player/playerAndroid/index.d.ts +0 -3
- package/dist/Player/playerAndroid/index.js +0 -3
- package/dist/Player/playerweb/PlayerControls.js +0 -346
- package/dist/Player/playerweb/index.d.ts +0 -3
- package/dist/Player/playerweb/index.js +0 -3
- package/dist/Player/web.d.ts +0 -3
- package/dist/Player/web.js +0 -3
- package/src/Player/playerAndroid/MegaVideoPlayerAndroid.tsx +0 -825
- package/src/Player/playerAndroid/PlayerControlsAndroid.tsx +0 -824
- package/src/Player/playerAndroid/SubtitleDisplayAndroid.tsx +0 -80
- package/src/Player/playerAndroid/index.ts +0 -7
- package/src/Player/playerweb/index.ts +0 -3
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { StyleSheet, Text, View } from "react-native";
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type SubCueShape = { start: number; end: number; text: string };
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Renders the active subtitle cue over the video surface. Positioned
|
|
7
7
|
* absolutely with zIndex 1 (below the controls at zIndex 2, above the
|
|
8
8
|
* video background at zIndex 0).
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function SubtitleDisplay({
|
|
11
11
|
cue,
|
|
12
12
|
enabled,
|
|
13
13
|
fontSize,
|
|
14
14
|
}: {
|
|
15
|
-
cue:
|
|
15
|
+
cue: SubCueShape | null;
|
|
16
16
|
enabled: boolean;
|
|
17
17
|
fontSize: number;
|
|
18
18
|
}) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export {
|
|
2
|
+
MegaVideoPlayer,
|
|
3
|
+
type MegaVideoPlayerProps,
|
|
4
|
+
type MegaVideoPlayerHandle,
|
|
5
|
+
} from "./MegaVideoPlayer.js";
|
|
6
|
+
export { PlayerControls, type PlayerControlsProps } from "./PlayerControls.js";
|
|
7
|
+
export { SubtitleDisplay, type SubCueShape } from "./SubtitleDisplay.js";
|
|
@@ -11,18 +11,19 @@ import { ActivityIndicator, StyleSheet, Text, View } from "react-native";
|
|
|
11
11
|
import { createVideoPlayer, VideoView, type VideoPlayer } from "expo-video";
|
|
12
12
|
import { Ionicons } from "@expo/vector-icons";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { PlayerControls } from "./PlayerControlsWeb.js";
|
|
15
|
+
import { SubtitleDisplay } from "./SubtitleDisplayWeb.js";
|
|
15
16
|
import {
|
|
16
17
|
loadSubtitles,
|
|
17
18
|
type SubCue,
|
|
18
19
|
type SubtitleFormat,
|
|
19
20
|
type SubtitleTrack,
|
|
20
|
-
} from "
|
|
21
|
+
} from "../subtitles/index.js";
|
|
21
22
|
|
|
22
23
|
/** expo-video listener subscriptions just need `remove()`. */
|
|
23
24
|
type EventSubscriptionLike = { remove(): void };
|
|
24
25
|
|
|
25
|
-
export type
|
|
26
|
+
export type MegaVideoPlayerProps = {
|
|
26
27
|
/** A playable URL — a direct stream or the first part URL. */
|
|
27
28
|
uri?: string | null;
|
|
28
29
|
/** Ordered additional part URLs for multi-part episodes, played in sequence. */
|
|
@@ -40,24 +41,14 @@ export type MegaVideoPlayerWebProps = {
|
|
|
40
41
|
initialSubtitleLang?: string | null;
|
|
41
42
|
/** shift the cue timestamps by an offset in seconds (can be negative) */
|
|
42
43
|
subtitleOffset?: number;
|
|
43
|
-
/** resolution labels in display order — the FIRST is the default source
|
|
44
|
-
* (the episode URL), e.g. ["Default", "1080p", "720p", "480p"]. */
|
|
45
|
-
resolutions?: string[];
|
|
46
|
-
/** currently active resolution label */
|
|
47
|
-
resolution?: string;
|
|
48
|
-
/** select a resolution — the parent resolves the label to its URL and
|
|
49
|
-
* updates `uri` so the new source is loaded. */
|
|
50
|
-
onSelectResolution?: (label: string) => void;
|
|
51
44
|
autoPlay?: boolean;
|
|
52
45
|
onEnd?: () => void;
|
|
53
46
|
onError?: (message: string) => void;
|
|
54
47
|
onProgress?: (info: { currentTime: number; duration: number }) => void;
|
|
55
48
|
onFullscreenChange?: (fullscreen: boolean) => void;
|
|
56
|
-
width?: number;
|
|
57
|
-
height?: number;
|
|
58
49
|
};
|
|
59
50
|
|
|
60
|
-
type
|
|
51
|
+
type MegaVideoPlayerState = {
|
|
61
52
|
playing: boolean;
|
|
62
53
|
buffering: boolean;
|
|
63
54
|
loading: boolean;
|
|
@@ -72,13 +63,11 @@ type MegaVideoPlayerWebState = {
|
|
|
72
63
|
subtitleError: string | null;
|
|
73
64
|
error: string | null;
|
|
74
65
|
fullscreen: boolean;
|
|
75
|
-
width?: number;
|
|
76
|
-
height?: number;
|
|
77
66
|
};
|
|
78
67
|
|
|
79
|
-
export class
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
export class MegaVideoPlayer extends React.Component<
|
|
69
|
+
MegaVideoPlayerProps,
|
|
70
|
+
MegaVideoPlayerState
|
|
82
71
|
> {
|
|
83
72
|
private player: VideoPlayer;
|
|
84
73
|
private subs: EventSubscriptionLike[] = [];
|
|
@@ -89,7 +78,7 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
89
78
|
private tracks: SubtitleTrack[] = [];
|
|
90
79
|
private sourceIndexRef = 0;
|
|
91
80
|
|
|
92
|
-
constructor(props:
|
|
81
|
+
constructor(props: MegaVideoPlayerProps) {
|
|
93
82
|
super(props);
|
|
94
83
|
this.state = {
|
|
95
84
|
playing: false,
|
|
@@ -106,8 +95,6 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
106
95
|
subtitleError: null,
|
|
107
96
|
error: null,
|
|
108
97
|
fullscreen: false,
|
|
109
|
-
width: this.props.width,
|
|
110
|
-
height: this.props.height,
|
|
111
98
|
};
|
|
112
99
|
|
|
113
100
|
this.player = createVideoPlayer(null);
|
|
@@ -193,7 +180,7 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
193
180
|
}
|
|
194
181
|
}
|
|
195
182
|
|
|
196
|
-
componentDidUpdate(prevProps:
|
|
183
|
+
componentDidUpdate(prevProps: MegaVideoPlayerProps) {
|
|
197
184
|
if (this.props.uri !== prevProps.uri && this.props.uri) {
|
|
198
185
|
this.sourceIndexRef = Math.max(
|
|
199
186
|
0,
|
|
@@ -411,39 +398,38 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
411
398
|
}
|
|
412
399
|
|
|
413
400
|
return (
|
|
414
|
-
<View
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
{
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
contentFit="contain"
|
|
434
|
-
allowsFullscreen={false}
|
|
435
|
-
/>
|
|
401
|
+
<View style={[styles.wrap, s.fullscreen && styles.fullscreen]}>
|
|
402
|
+
<View
|
|
403
|
+
style={{
|
|
404
|
+
width: "100%",
|
|
405
|
+
height: "100%",
|
|
406
|
+
justifyContent: "center",
|
|
407
|
+
alignItems: "center",
|
|
408
|
+
}}
|
|
409
|
+
>
|
|
410
|
+
<VideoView
|
|
411
|
+
player={this.player}
|
|
412
|
+
style={{
|
|
413
|
+
width: "100%",
|
|
414
|
+
height: "auto",
|
|
415
|
+
}}
|
|
416
|
+
nativeControls={false}
|
|
417
|
+
contentFit="contain"
|
|
418
|
+
/>
|
|
419
|
+
</View>
|
|
436
420
|
|
|
437
421
|
{s.loading && (
|
|
438
|
-
<View
|
|
439
|
-
style={[styles.centerBadge, { width: this.state.width }]}
|
|
440
|
-
pointerEvents="none"
|
|
441
|
-
>
|
|
422
|
+
<View style={styles.centerBadge} pointerEvents="none">
|
|
442
423
|
<ActivityIndicator color="#e50914" size="large" />
|
|
443
424
|
<Text style={styles.loadingText}>Starting stream…</Text>
|
|
444
425
|
</View>
|
|
445
426
|
)}
|
|
446
427
|
|
|
428
|
+
<SubtitleDisplay
|
|
429
|
+
cue={activeCue}
|
|
430
|
+
enabled={s.subtitlesOn}
|
|
431
|
+
fontSize={s.subFontSize}
|
|
432
|
+
/>
|
|
447
433
|
{s.subtitlesOn && s.subtitleError && !s.cues.length && (
|
|
448
434
|
<View pointerEvents="none" style={styles.subErrorWrap}>
|
|
449
435
|
<Text style={styles.subErrorText}>
|
|
@@ -452,7 +438,7 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
452
438
|
</View>
|
|
453
439
|
)}
|
|
454
440
|
|
|
455
|
-
<
|
|
441
|
+
<PlayerControls
|
|
456
442
|
playing={s.playing}
|
|
457
443
|
buffering={s.buffering}
|
|
458
444
|
currentTime={s.currentTime}
|
|
@@ -467,9 +453,6 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
467
453
|
onSelectSubtitleTrack={this.selectSubtitleTrack}
|
|
468
454
|
subtitleFontSize={s.subFontSize}
|
|
469
455
|
onChangeSubtitleFontSize={this.changeSubtitleFontSize}
|
|
470
|
-
resolutions={this.props.resolutions}
|
|
471
|
-
resolution={this.props.resolution}
|
|
472
|
-
onSelectResolution={this.props.onSelectResolution}
|
|
473
456
|
onToggleVisible={this.toggleControls}
|
|
474
457
|
onPlayPause={this.playPause}
|
|
475
458
|
onSkip={this.skip}
|
|
@@ -478,11 +461,6 @@ export class MegaVideoPlayerWeb extends React.Component<
|
|
|
478
461
|
onToggleSubtitles={this.toggleSubtitles}
|
|
479
462
|
onVolume={this.changeVolume}
|
|
480
463
|
onFullscreen={this.enterFullscreen}
|
|
481
|
-
width={this.state.width}
|
|
482
|
-
height={this.state.height}
|
|
483
|
-
cue={activeCue}
|
|
484
|
-
enabled={s.subtitlesOn}
|
|
485
|
-
fontSize={s.subFontSize}
|
|
486
464
|
/>
|
|
487
465
|
</View>
|
|
488
466
|
);
|
|
@@ -547,5 +525,10 @@ const styles = StyleSheet.create({
|
|
|
547
525
|
paddingVertical: 4,
|
|
548
526
|
borderRadius: 4,
|
|
549
527
|
overflow: "hidden",
|
|
528
|
+
position: "absolute",
|
|
529
|
+
top: 0,
|
|
530
|
+
bottom: 0,
|
|
531
|
+
left: 0,
|
|
532
|
+
right: 0,
|
|
550
533
|
},
|
|
551
534
|
});
|