Skip to content

Latest commit

History

141 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

react-airplay

npmNPM Downloads

Airplay bridge for React Native.

Installation

yarn add react-airplay
npx pod-install

Usage

import{AirplayButton,showRoutePicker,useAirplayConnectivity,useExternalPlaybackAvailability,useAvAudioSessionRoutes,}from"react-airplay";import{Button,Text,View}from"react-native";exportfunctionApp(){constisAirplayConnected=useAirplayConnectivity();constisExternalPlaybackAvailable=useExternalPlaybackAvailability();constroutes=useAvAudioSessionRoutes();return(<View>{isExternalPlaybackAvailable&&(<><AirplayButtonprioritizesVideoDevicestintColor="red"activeTintColor="blue"style={{width: 24,height: 24,}}/><Buttontitle="Custom Button"onPress={()=>showRoutePicker({prioritizesVideoDevices: true})}/></>)}{routes.length>0&&(<Text>
Currently playing on{" "}{routes.map((route)=>route.portName).join(", ")}</Text>)}</View>);}

Note

Enabling route detection increase power consumption, as per Apple documentation. So be sure to un-mount the component when not in use, if that's not possible (e.g. when component is part of a react-navigation screen) the enabled option parameter can be used:

import{useIsFocused}from"@react-navigation/native";import{useExternalPlaybackAvailability}from"react-airplay";constisScreenFocused=useIsFocused();constisExternalPlaybackAvailable=useExternalPlaybackAvailability({enabled: isScreenFocused,});

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

Airplay bridge for React Native

Topics

Resources

Code of conduct

Contributing

Stars

44 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages