A React Native module that allows you to use the native Media Player Framework Reference to play movies
- Run
npm install git+https://github.com/ImprontaAdvance/react-native-media-player.git --save
- Open your project in XCode, right click on
Libraries
and clickAdd Files to "Your Project Name"
- Add
libRTCMediaPlayer.a
toBuild Phases -> Link Binary With Libraries
.
- Whenever you want to use it within React code now you can: `var { VideoPlayer } = require('react-native-media-player');
// Render it when you want to open video player fullscreen
<VideoPlayer src={this.state.videoOpened} onEnd={() => this.closeVideo()} />
render() {
var video;
if(this.state.video)
video = <VideoPlayer src={this.state.video} onEnd={() => this.setState({video: false)} />;
return (
<View>
<TouchableHighlight onPress={() => this.setState({video: 'video.mp4'})}>
<Text>Click to open video</Text>
</TouchableHighlight>
{video}
</View>
);
}
- Improve example
- Support iPhone resolution
I'm not iOS developer, so feel free to send pull requests for fix, coding style and improvements.
A special thanks to brentvatne and his react-native-video.