Created
January 29, 2020 06:04
-
-
Save gergardiol/1585769db5941aad708189eae1e9a50c to your computer and use it in GitHub Desktop.
Airplay react native integration library - full code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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