Commit 78e34c8 1 parent f882cf9 commit 78e34c8 Copy full SHA for 78e34c8
File tree 2 files changed +13
-0
lines changed
src/view/com/util/post-embeds
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
24
24
useActiveVideoWeb ( )
25
25
const [ onScreen , setOnScreen ] = useState ( false )
26
26
const [ isFullscreen ] = useFullscreen ( )
27
+ const lastKnownTime = useRef < number | undefined > ( )
27
28
28
29
useEffect ( ( ) => {
29
30
if ( ! ref . current ) return
@@ -82,6 +83,7 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
82
83
active = { active }
83
84
setActive = { setActive }
84
85
onScreen = { onScreen }
86
+ lastKnownTime = { lastKnownTime }
85
87
/>
86
88
</ ViewportObserver >
87
89
</ ErrorBoundary >
Original file line number Diff line number Diff line change @@ -13,11 +13,13 @@ export function VideoEmbedInnerWeb({
13
13
active,
14
14
setActive,
15
15
onScreen,
16
+ lastKnownTime,
16
17
} : {
17
18
embed : AppBskyEmbedVideo . View
18
19
active : boolean
19
20
setActive : ( ) => void
20
21
onScreen : boolean
22
+ lastKnownTime : React . MutableRefObject < number | undefined >
21
23
} ) {
22
24
const containerRef = useRef < HTMLDivElement > ( null )
23
25
const videoRef = useRef < HTMLVideoElement > ( null )
@@ -40,6 +42,12 @@ export function VideoEmbedInnerWeb({
40
42
setHlsLoading,
41
43
} )
42
44
45
+ useEffect ( ( ) => {
46
+ if ( lastKnownTime . current && videoRef . current ) {
47
+ videoRef . current . currentTime = lastKnownTime . current
48
+ }
49
+ } , [ lastKnownTime ] )
50
+
43
51
return (
44
52
< View style = { [ a . flex_1 , a . rounded_md , a . overflow_hidden ] } >
45
53
< div ref = { containerRef } style = { { height : '100%' , width : '100%' } } >
@@ -52,6 +60,9 @@ export function VideoEmbedInnerWeb({
52
60
preload = "none"
53
61
muted = { ! focused }
54
62
aria-labelledby = { embed . alt ? figId : undefined }
63
+ onTimeUpdate = { e => {
64
+ lastKnownTime . current = e . currentTarget . currentTime
65
+ } }
55
66
/>
56
67
{ embed . alt && (
57
68
< figcaption
You can’t perform that action at this time.
0 commit comments