I have used react-native-youtube-iframe to play youtube videos in my react native app. I want to disable long-press on youtube videos.
I have used react-native-youtube-iframe to play youtube videos in my react native app. I want to disable long-press on youtube videos.
From GitHub documentation, I solved by using.
Wrap the YoutubePlayer in a View that has pointerEvents="none" to disable app touch-events to the player.
Then react-native's Pressable API or any of the touchables to intercept presses.
<Pressable
onPress={() => {
// handle or ignore
}}
onLongPress={() => {
// handle or ignore
}}>
<View pointerEvents="none">
<YoutubePlayer (...) />
</View>
</Pressable>
Source: https://lonelycpp.github.io/react-native-youtube-iframe/remove-context-share
Another Way is using onContextMenu={(e) => e.preventDefault():
<div onContextMenu={(e) => e.preventDefault()}>
<YoutubePlayer (...) />
</div>