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.
Asked
Active
Viewed 1,288 times
4
-
facing same issue. anyone knows how to do this? – Mahesh Gawhane Sep 23 '21 at 13:23
-
@MaheshGawhane, `onContextMenu={(e) => e.preventDefault()}` is working? – Mani Dec 02 '21 at 16:18
1 Answers
0
From GitHub documentation, I solved by using.
Removing context menu on long-press:
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>

Mani
- 280
- 1
- 10
-
Using this we can't touch Youtube players, play/pause. If we give buttons for play/pause then what about Fullscreen mode. Is there any function or event to change video to Fullscreen mode using button? – Mahesh Gawhane Nov 10 '21 at 15:28
-
Can you please Try Disabling context menu on whole screen: (see 170 up votes answer in) https://stackoverflow.com/a/28748222/15932042 (It is temporary fix, didn't tested) I saw few comments (including yours) in GitHub, I didn't found exact solution. – Mani Nov 11 '21 at 09:49
-
-