Skip to content

Commit c16421e

Browse files
committed
add: 240p order
1 parent 582be90 commit c16421e

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

components/VideoPlayer.tsx

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,25 @@ import { axiosIn } from "@/utils/axios";
4040
import { API_URL } from "@/constants/Strings";
4141
import { useAtomValue } from "jotai";
4242
import { tokenAtom } from "@/store/auth";
43-
import * as Sharing from "expo-sharing";
43+
import * as KeepAwake from "expo-keep-awake";
4444
import StreamUrlNotFound from "./ui/error/StreamUrlNotFound";
4545

4646
const VideoPlayer = memo(
4747
({
4848
episodeId,
4949
title,
5050
data,
51+
isHaveNextEpisode,
52+
isHavePrevEpisode,
53+
nextEpisode,
54+
prevEpisode,
5155
}: {
5256
episodeId: string;
5357
title?: string;
58+
isHaveNextEpisode: boolean;
59+
isHavePrevEpisode: boolean;
60+
nextEpisode: () => void;
61+
prevEpisode: () => void;
5462
data: Array<any>;
5563
}) => {
5664
if (data.length == 0 || data[0]?.source?.length == 0) {
@@ -217,7 +225,7 @@ const VideoPlayer = memo(
217225

218226
const allSources = data.flatMap((server: any) => server.source);
219227
allSources.sort((a, b) => {
220-
const qualityOrder = ["1080p", "720p", "480p", "360p", "4K"];
228+
const qualityOrder = ["1080p", "720p", "480p", "360p", "240p", 'auto', "4K"];
221229
return (
222230
qualityOrder.indexOf(a.quality) - qualityOrder.indexOf(b.quality)
223231
);
@@ -421,6 +429,12 @@ const VideoPlayer = memo(
421429
(status.playableDurationMillis ?? 0) <=
422430
status.positionMillis;
423431

432+
if (status.isPlaying) {
433+
KeepAwake.activateKeepAwakeAsync();
434+
} else {
435+
KeepAwake.deactivateKeepAwake();
436+
}
437+
424438
if (buffering) {
425439
setVideoStatus(VideoStatus.BUFFERING);
426440
} else {
@@ -599,6 +613,67 @@ const VideoPlayer = memo(
599613
setProgress(value);
600614
}}
601615
/>
616+
<View
617+
style={{
618+
display:
619+
orientation ==
620+
ScreenOrientation.Orientation.LANDSCAPE_LEFT ||
621+
orientation ==
622+
ScreenOrientation.Orientation.LANDSCAPE_RIGHT
623+
? "flex"
624+
: "none",
625+
flexDirection: "row",
626+
justifyContent: "space-between",
627+
marginTop: 10,
628+
paddingHorizontal: 16,
629+
}}
630+
>
631+
{isHavePrevEpisode ? (
632+
<GestureDetector
633+
gesture={Gesture.Tap().onEnd(() => {
634+
runOnJS(prevEpisode)();
635+
})}
636+
>
637+
<TouchableOpacity
638+
style={{
639+
flexDirection: "row",
640+
gap: 5,
641+
alignItems: "center",
642+
}}
643+
>
644+
<Feather name="skip-back" size={16} color="white" />
645+
<CustomText>Previous Episode</CustomText>
646+
</TouchableOpacity>
647+
</GestureDetector>
648+
) : (
649+
<View />
650+
)}
651+
652+
{isHaveNextEpisode ? (
653+
<GestureDetector
654+
gesture={Gesture.Tap().onEnd(() => {
655+
runOnJS(nextEpisode)();
656+
})}
657+
>
658+
<TouchableOpacity
659+
style={{
660+
flexDirection: "row",
661+
gap: 5,
662+
alignItems: "center",
663+
}}
664+
>
665+
<CustomText>Next Episode</CustomText>
666+
<Feather
667+
name="skip-forward"
668+
size={16}
669+
color="white"
670+
/>
671+
</TouchableOpacity>
672+
</GestureDetector>
673+
) : (
674+
<View />
675+
)}
676+
</View>
602677
</View>
603678
</View>
604679
</GestureDetector>

0 commit comments

Comments
 (0)