Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29599

react-native-video example throws "TypeError:undefined" error

$
0
0

I'm very new with react native. I'm trying to make an app that has a youtube video embeded.I'm trying the example of this repo but it crashes on my project.

here is my full code. Crashes are comented where they are thrown. I dont understand what I'm doing wrong.

I'm using webstorm and I'm pretty sure that i've installed the package and linked it using thoose commands:

npm install --save react-native-video

react-native link react-native-video

import React from 'react';import {  SafeAreaView,  StyleSheet,  ScrollView,  View,  Text,  StatusBar,} from 'react-native';import {  Header,  LearnMoreLinks,  Colors,  DebugInstructions,  ReloadInstructions,} from 'react-native/Libraries/NewAppScreen';import Video from 'react-native-video';const App: () => React$Node = () => {  return (<><StatusBar barStyle="dark-content" /><SafeAreaView><ScrollView          contentInsetAdjustmentBehavior="automatic"          style={styles.scrollView}><View style={styles.body}><View><Video source={{uri: "https://www.youtube.com/watch?v=83mkGuGLNZg"}}                 ref={(ref) => {                   this.player = ref //Crash with TypeError:undefined is not an object                 }}                                      // Store reference                 onBuffer={this.onBuffer}                //Crash with TypeError:undefined is not an object                 onError={this.videoError}               //Crash with TypeError:undefined is not an object                 style={styles.backgroundVideo}              /></View></View></ScrollView></SafeAreaView></>  );};const styles = StyleSheet.create({  scrollView: {    backgroundColor: Colors.lighter,  },  engine: {    position: 'absolute',    right: 0,  },  body: {    backgroundColor: Colors.white,  },  sectionContainer: {    marginTop: 32,    paddingHorizontal: 24,  },  sectionTitle: {    fontSize: 24,    fontWeight: '600',    color: Colors.black,  },  sectionDescription: {    marginTop: 8,    fontSize: 18,    fontWeight: '400',    color: Colors.dark,  },  highlight: {    fontWeight: '700',  },  footer: {    color: Colors.dark,    fontSize: 12,    fontWeight: '600',    padding: 4,    paddingRight: 12,    textAlign: 'right',  },  backgroundVideo: {    position: 'absolute',    top: 0,    left: 0,    bottom: 0,    right: 0,  },});export default App;

Viewing all articles
Browse latest Browse all 29599

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>