Skip to content

Instantly share code, notes, and snippets.

@gergardiol
Created January 29, 2020 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gergardiol/1585769db5941aad708189eae1e9a50c to your computer and use it in GitHub Desktop.
Save gergardiol/1585769db5941aad708189eae1e9a50c to your computer and use it in GitHub Desktop.
Airplay react native integration library - full code
import React from 'react';
import { Platform, View } from 'react-native';
import { AirPlayButton } from 'react-native-airplay-btn';
import Video from 'react-native-video';
const styles = {
backgroundVideo: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
};
class MyAirplayApp extends React.Component {
render() {
return (
<View>
{Platform.OS === 'ios' && <AirPlayButton style={{ height: 30, width: 30 }} />}
<Video
ref={ref => {
this.player = ref; // Store the player reference
}}
poster="video_poster.png" // An image to display while the video is loading, string with a URL for the poster
source={{ uri: 'background' }} // Can be a URL or a local file.
onBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo} // Video background styles
/>
</View>
);
}
}
export default MyAirplayApp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment