@@ -40,17 +40,25 @@ import { axiosIn } from "@/utils/axios";
40
40
import { API_URL } from "@/constants/Strings" ;
41
41
import { useAtomValue } from "jotai" ;
42
42
import { tokenAtom } from "@/store/auth" ;
43
- import * as Sharing from "expo-sharing " ;
43
+ import * as KeepAwake from "expo-keep-awake " ;
44
44
import StreamUrlNotFound from "./ui/error/StreamUrlNotFound" ;
45
45
46
46
const VideoPlayer = memo (
47
47
( {
48
48
episodeId,
49
49
title,
50
50
data,
51
+ isHaveNextEpisode,
52
+ isHavePrevEpisode,
53
+ nextEpisode,
54
+ prevEpisode,
51
55
} : {
52
56
episodeId : string ;
53
57
title ?: string ;
58
+ isHaveNextEpisode : boolean ;
59
+ isHavePrevEpisode : boolean ;
60
+ nextEpisode : ( ) => void ;
61
+ prevEpisode : ( ) => void ;
54
62
data : Array < any > ;
55
63
} ) => {
56
64
if ( data . length == 0 || data [ 0 ] ?. source ?. length == 0 ) {
@@ -217,7 +225,7 @@ const VideoPlayer = memo(
217
225
218
226
const allSources = data . flatMap ( ( server : any ) => server . source ) ;
219
227
allSources . sort ( ( a , b ) => {
220
- const qualityOrder = [ "1080p" , "720p" , "480p" , "360p" , "4K" ] ;
228
+ const qualityOrder = [ "1080p" , "720p" , "480p" , "360p" , "240p" , 'auto' , " 4K"] ;
221
229
return (
222
230
qualityOrder . indexOf ( a . quality ) - qualityOrder . indexOf ( b . quality )
223
231
) ;
@@ -421,6 +429,12 @@ const VideoPlayer = memo(
421
429
( status . playableDurationMillis ?? 0 ) <=
422
430
status . positionMillis ;
423
431
432
+ if ( status . isPlaying ) {
433
+ KeepAwake . activateKeepAwakeAsync ( ) ;
434
+ } else {
435
+ KeepAwake . deactivateKeepAwake ( ) ;
436
+ }
437
+
424
438
if ( buffering ) {
425
439
setVideoStatus ( VideoStatus . BUFFERING ) ;
426
440
} else {
@@ -599,6 +613,67 @@ const VideoPlayer = memo(
599
613
setProgress ( value ) ;
600
614
} }
601
615
/>
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 >
602
677
</ View >
603
678
</ View >
604
679
</ GestureDetector >
0 commit comments