Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Latest commit

 

History

History
65 lines (43 loc) · 1.46 KB

README.md

File metadata and controls

65 lines (43 loc) · 1.46 KB

react-native-airplay-btn

AirPlay library for iOS

Project moved

This project is now located at https://github.com/gazedash/react-native-airplay-ios

Installation with Automatic Linking

npm i react-native-airplay-btn --save
react-native link

How to create listeners

import { AirPlayListener } from react-native-airplay-btn

this.airPlayConnected = AirPlayListener.addListener('deviceConnected', ({ devices }) => this.setState({
    devices,
})); --> returns a boolean


// Remove Listener in componentWillUnmount
this.deviceConnected.remove();

Devices is an array of objects that contains information about currently connected audio output(s):

[{deviceName: "Some Bluetooth Headphones Model", portType: "BluetoothA2DPOutput"}]
// or
[{deviceName: "Speakers", portType:"Speakers"}]
// or
[{deviceName: "Andrey’s Apple TV", portType: "AirPlay"}]

Probably it could just be an object, but internally AVAudioSessionRouteDescription returns array, so there might be a case when there is more than one device connected at the time.

Methods

  AirPlay.startScan();
  
  AirPlay.disconnect();

Create AirPlay Button

import { AirPlayButton } from 'react-native-airplay-btn';

<Button style={{ height: 30, width: 30, justifyContent: 'center', alignItems:'center' }} />

Note: The AirPlay Button does not show in the simulator

Author

Original author of the library:

Nadia Dillon

Modifications:

Andrey Efremov (gazedash)