question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Video in scrollview

See original GitHub issue

Describe the bug If the video is in the scrollview when scrolling, if you hit the video and it occupies almost the entire width, this window appears.

To Reproduce render multiple videos in scrollview

Expected behavior When scrolling, the player should not respond in any way.

Screenshots photo_2021-06-07_14-27-19

Smartphone:

  • Device: Redmi note 8pro
  • OS: Android 10
  • react-native-youtube-iframe: 2.1.0
  • react-native-webview : 10.10.2

Other information: The library component is wrapped in a view. Tried changing pointerEvent when scrolling. Nothing comes out. This is very inconvenient to use. In normal mode, it works well without the scrollview.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
lander854commented, Nov 19, 2021

this will fix this issue:

`export const YoutubePlayerScreen = ({ videoId }) => { const [playing, setPlaying] = useState(false);

const togglePlaying = useCallback(() => {
    setPlaying((prev) => !prev);
}, []);

return (
    <Pressable
        onPress={() => {
            togglePlaying();
        }}
    >
        <View
            pointerEvents={playing ? undefined : 'none'}
            style={{ width: '100%', height: 300 }}
        >
            <YoutubePlayer
                height={400}
                play={playing}
                videoId={videoId}
                webViewProps={{
                    androidLayerType: 'hardware',
                }}
            />
        </View>
    </Pressable>
);

};`

3reactions
josegiufridacommented, Dec 31, 2021

@lander854 solution’s works fine!

But it does not allow to use other buttons correctly (volume, full screen mode) because when pressing them the pressable activates and pauses the video. Or also, sometimes, when trying to pause the video, it plays again.

I solved it doing (it works perfectly on Scrollview or Flatlist):

const [playing, setPlaying] = useState(false);

return(
  <Pressable
	  onPress={() => {
              if (!playing) {
                  setPlaying(true);
              }
	  }}>
	  <View pointerEvents={playing ? undefined : 'none'}>
              <YoutubePlayer
	          height={400}
	          play={playing}
	          videoId={videoId}
	          webViewProps={{
		      androidLayerType: 'hardware',
	          }}
	          onChangeState={event => {
                      if (event === 'paused') {
                          setPlaying(false);
                      }
	          }}
              />
	  </View>
  </Pressable>
);

Thanks @lander854! I was looking for a long time for a solution to this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android::VideoView inside a ScrollView - Stack Overflow
How can I scroll the VideoView correctly with the scrolling of all other elements in the scrollView? android · video · scroll ·...
Read more >
[VIDEO] ScrollView Example with Grid Views - Kodika.io Forum
Following some questions on a different thread, I am uploading this video to explain how to use a ScrollView and inside have Grid...
Read more >
ScrollView & Flexbox (Yes, that works!) - React Native - O'Reilly
Get React Native - The Practical Guide now with the O'Reilly learning platform. O'Reilly members experience live online training, plus books, videos, ...
Read more >
How to make a sticky video on scroll like in Youtube app ?
How to move a video from a place to another. ... <ScrollView contentContainerStyle={styles.container} scrollEventThrottle={16} >
Read more >
ScrollView – displaying a list of videos | Kivy - Packt Subscription
ScrollView – displaying a list of videos. In this section, we will display the results of a search performed on the TED video...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found