@@ -30,16 +30,8 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
3030 const [ duration , setDuration ] = createSignal ( 0 )
3131 const [ videoLoading , setVideoLoading ] = createSignal ( true )
3232 const [ errorMessage , setErrorMessage ] = createSignal < string > ( '' )
33- const selectionEndTime = ( ) => props . selection . endTime ?? duration ( )
34-
35- const clampTime = ( nextTime : number ) => {
36- const startTime = props . selection . startTime
37- const endTime = selectionEndTime ( )
38- return Math . max ( startTime , Math . min ( nextTime , endTime ) )
39- }
40-
4133 const seekTo = ( nextTime : number ) => {
42- const clampedTime = clampTime ( nextTime )
34+ const clampedTime = Math . max ( props . selection . startTime , Math . min ( nextTime , props . selection . endTime ?? duration ( ) ) )
4335 video . currentTime = clampedTime
4436 setCurrentTime ( clampedTime )
4537 props . onProgress ?.( clampedTime )
@@ -72,13 +64,7 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
7264 }
7365 }
7466
75- const togglePlayback = ( ) => {
76- if ( video . paused ) {
77- requestPlay ( )
78- } else {
79- video . pause ( )
80- }
81- }
67+ const togglePlayback = ( ) => ( video . paused ? requestPlay ( ) : video . pause ( ) )
8268 const skipBy = ( seconds : number ) => ( e : Event ) => {
8369 e . preventDefault ( )
8470 e . stopPropagation ( )
@@ -97,8 +83,6 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
9783 const onTimeUpdate = ( e : Event ) => {
9884 const nextCurrentTime = ( e . currentTarget as HTMLVideoElement ) . currentTime
9985 setCurrentTime ( nextCurrentTime )
100-
101- // If there is a selection, loop within it
10286 if ( nextCurrentTime < props . selection . startTime ) {
10387 seekTo ( props . selection . startTime )
10488 } else if ( props . selection . endTime !== undefined && nextCurrentTime > props . selection . endTime ) {
@@ -156,8 +140,6 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
156140 const player = Hls . createHls ( )
157141 player . attachMedia ( video )
158142 setHls ( player )
159-
160- // Hls error handler
161143 const { Events, ErrorTypes } = Hls . default
162144 player . on ( Events . ERROR , ( _ , data ) => {
163145 if ( data . fatal && data . type === ErrorTypes . NETWORK_ERROR ) onError ( )
@@ -173,7 +155,6 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
173155 }
174156 } )
175157
176- // State reset on route change
177158 createEffect (
178159 on ( routeName , ( ) => {
179160 setVideoLoading ( true )
@@ -208,7 +189,6 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
208189 props . class ,
209190 ) }
210191 >
211- { /* Video as background */ }
212192 < div class = "absolute inset-0 -z-10" >
213193 < video
214194 ref = { video }
@@ -222,26 +202,17 @@ const RouteVideoPlayer: VoidComponent<RouteVideoPlayerProps> = (props) => {
222202 disablepictureinpicture
223203 />
224204 </ div >
225-
226- { /* Loading animation */ }
227205 < Show when = { videoLoading ( ) } >
228206 < div class = "absolute inset-0 z-0 skeleton-loader" />
229207 </ Show >
230-
231- { /* Error message */ }
232208 < Show when = { errorMessage ( ) } >
233209 < div class = "absolute inset-0 z-0 flex flex-col items-center justify-center gap-1" >
234210 < IconButton name = "error" />
235211 < span class = "w-[90%] text-center text-wrap" > { errorMessage ( ) } </ span >
236212 </ div >
237213 </ Show >
238-
239- { /* Controls overlay */ }
240214 < div class = "absolute inset-0 flex items-end" ref = { controls } >
241- { /* Controls background gradient */ }
242215 < div class = "absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-black/50 to-transparent" />
243-
244- { /* Controls container */ }
245216 < div class = "relative flex w-full items-center gap-3 pb-3 px-2" >
246217 < IconButton name = "replay_10" aria-label = "Skip back 10 seconds" onClick = { skipBy ( - 10 ) } />
247218 < IconButton aria-label = { isPlaying ( ) ? 'Pause' : 'Play' } name = { isPlaying ( ) ? 'pause' : 'play_arrow' } filled />
0 commit comments