1
- import React , { useCallback , useState } from 'react'
1
+ import React , { useCallback , useId , useState } from 'react'
2
2
import { View } from 'react-native'
3
3
import { Image } from 'expo-image'
4
4
import { AppBskyEmbedVideo } from '@atproto/api'
@@ -17,11 +17,14 @@ import {useActiveVideoNative} from './ActiveVideoNativeContext'
17
17
import * as VideoFallback from './VideoEmbedInner/VideoFallback'
18
18
19
19
export function VideoEmbed ( { embed} : { embed : AppBskyEmbedVideo . View } ) {
20
+ const { _} = useLingui ( )
20
21
const t = useTheme ( )
21
- const { activeSource, setActiveSource, player} = useActiveVideoNative ( )
22
+ const { activeSource, activeViewId, setActiveSource, player} =
23
+ useActiveVideoNative ( )
24
+ const viewId = useId ( )
25
+
22
26
const [ isFullscreen , setIsFullscreen ] = React . useState ( false )
23
- const isActive = embed . playlist === activeSource
24
- const { _} = useLingui ( )
27
+ const isActive = embed . playlist === activeSource && activeViewId === viewId
25
28
26
29
const [ key , setKey ] = useState ( 0 )
27
30
const renderError = useCallback (
@@ -34,7 +37,7 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
34
37
35
38
const onChangeStatus = ( isVisible : boolean ) => {
36
39
if ( isVisible ) {
37
- setActiveSource ( embed . playlist )
40
+ setActiveSource ( embed . playlist , viewId )
38
41
if ( ! player . playing ) {
39
42
player . play ( )
40
43
}
@@ -88,7 +91,7 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
88
91
< Button
89
92
style = { [ a . absolute , a . inset_0 ] }
90
93
onPress = { ( ) => {
91
- setActiveSource ( embed . playlist )
94
+ setActiveSource ( embed . playlist , viewId )
92
95
} }
93
96
label = { _ ( msg `Play video` ) }
94
97
color = "secondary" >
0 commit comments