1
1
import React , { useCallback , useEffect , useRef , useState } from 'react'
2
2
import { Pressable , View } from 'react-native'
3
- import Animated , { FadeInDown , FadeOutDown } from 'react-native-reanimated'
3
+ import Animated , { FadeInDown } from 'react-native-reanimated'
4
4
import { VideoPlayer , VideoView } from 'expo-video'
5
5
import { msg } from '@lingui/macro'
6
6
import { useLingui } from '@lingui/react'
@@ -10,14 +10,14 @@ import {HITSLOP_30} from '#/lib/constants'
10
10
import { useAppState } from '#/lib/hooks/useAppState'
11
11
import { logger } from '#/logger'
12
12
import { useVideoPlayer } from '#/view/com/util/post-embeds/VideoPlayerContext'
13
- import { android , atoms as a , useTheme } from '#/alf'
13
+ import { atoms as a , useTheme } from '#/alf'
14
14
import { Mute_Stroke2_Corner0_Rounded as MuteIcon } from '#/components/icons/Mute'
15
15
import { SpeakerVolumeFull_Stroke2_Corner0_Rounded as UnmuteIcon } from '#/components/icons/Speaker'
16
- import { Text } from '#/components/Typography'
17
16
import {
18
17
AudioCategory ,
19
18
PlatformInfo ,
20
19
} from '../../../../../../modules/expo-bluesky-swiss-army'
20
+ import { TimeIndicator } from './TimeIndicator'
21
21
22
22
export function VideoEmbedInnerNative ( ) {
23
23
const player = useVideoPlayer ( )
@@ -86,10 +86,6 @@ function Controls({
86
86
Math . floor ( player . currentTime ) ,
87
87
)
88
88
89
- const timeRemaining = duration - currentTime
90
- const minutes = Math . floor ( timeRemaining / 60 )
91
- const seconds = String ( timeRemaining % 60 ) . padStart ( 2 , '0' )
92
-
93
89
useEffect ( ( ) => {
94
90
const interval = setInterval ( ( ) => {
95
91
// duration gets reset to 0 on loop
@@ -143,37 +139,12 @@ function Controls({
143
139
// 1. timeRemaining is a number - was seeing NaNs
144
140
// 2. duration is greater than 0 - means metadata has loaded
145
141
// 3. we're less than 5 second into the video
142
+ const timeRemaining = duration - currentTime
146
143
const showTime = ! isNaN ( timeRemaining ) && duration > 0 && currentTime <= 5
147
144
148
145
return (
149
146
< View style = { [ a . absolute , a . inset_0 ] } >
150
- { showTime && (
151
- < Animated . View
152
- entering = { FadeInDown . duration ( 300 ) }
153
- exiting = { FadeOutDown . duration ( 500 ) }
154
- style = { [
155
- {
156
- backgroundColor : 'rgba(0, 0, 0, 0.75)' ,
157
- borderRadius : 6 ,
158
- paddingHorizontal : 6 ,
159
- paddingVertical : 3 ,
160
- position : 'absolute' ,
161
- left : 5 ,
162
- bottom : 5 ,
163
- minHeight : 20 ,
164
- justifyContent : 'center' ,
165
- } ,
166
- ] } >
167
- < Text
168
- style = { [
169
- { color : t . palette . white , fontSize : 12 } ,
170
- a . font_bold ,
171
- android ( { lineHeight : 1.25 } ) ,
172
- ] } >
173
- { minutes } :{ seconds }
174
- </ Text >
175
- </ Animated . View >
176
- ) }
147
+ { showTime && < TimeIndicator time = { timeRemaining } /> }
177
148
< Pressable
178
149
onPress = { onPressFullscreen }
179
150
style = { a . flex_1 }
@@ -185,7 +156,7 @@ function Controls({
185
156
< Animated . View
186
157
entering = { FadeInDown . duration ( 300 ) }
187
158
style = { {
188
- backgroundColor : 'rgba(0, 0, 0, 0.75 )' ,
159
+ backgroundColor : 'rgba(0, 0, 0, 0.5 )' ,
189
160
borderRadius : 6 ,
190
161
paddingHorizontal : 6 ,
191
162
paddingVertical : 3 ,
0 commit comments