React Native

react-native-video 사용법 (에러주의)

고줭 2022. 4. 12. 20:36

react-native-video

 

GitHub - react-native-video/react-native-video: A <Video /> component for react-native

A <Video /> component for react-native. Contribute to react-native-video/react-native-video development by creating an account on GitHub.

github.com

 

import {View, StyleSheet} from 'react-native';
import React from 'react';
import Video from 'react-native-video';

const SecondPage = () => {
  return (
    <View style={styles.container}>
      <Video
        source={{
          uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
        }}
        style={styles.backgroundVideo}
        fullscreen={true}
        resizeMode={'contain'}
        repeat={true}
        controls={true}
      />
    </View>
  );
};

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'white',
  },
  backgroundVideo: {
    position: 'absolute',
    top: 0,
    left: 0,
    bottom: 0,
    right: 0,
  },
});

export default SecondPage;
render error null is not an object (evaluating 'RCTVideoInstance.Constants')

비디오를 테스트하기위해 react-native-video 라이브러리를 설치하고 실행하려는데 위와 같은 에러가 나왔다.

검색해보니 깃헙의 이슈에도 나와같은 증상인 사람들이 여럿잇으나 하라는대로 해도 되지 않았는데 결국 해결은 함

allprojects {
    repositories {
    	...
    	jcenter()
    }
}

android/build.gradle에 jcenter()을 추가하니까 됐당 왜인지는 모름... 재생은 잘됨