File tree 5 files changed +33
-22
lines changed 5 files changed +33
-22
lines changed Original file line number Diff line number Diff line change 1
1
# react-native-airplay-cast
2
2
3
- Stream audio or video to AirPlay-enabled devices.
3
+ Stream audio or video to AirPlay-enabled devices with a customizable AirPlay button .
4
4
5
5
## Installation
6
6
@@ -13,9 +13,11 @@ npm install react-native-airplay-cast
13
13
``` js
14
14
import { AirPlayButton } from " react-native-airplay-cast" ;
15
15
16
- // ...
17
-
18
- < AirPlayButton style= {{ width: 30 , height: 30 }} / >
16
+ < AirPlayButton
17
+ activeTintColor= " blue"
18
+ tintColor= " black"
19
+ style= {{ width: 30 , height: 30 }}
20
+ / >
19
21
```
20
22
21
23
## Contributing
Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ import { AirPlayButton } from 'react-native-airplay-cast';
5
5
export default function App ( ) {
6
6
return (
7
7
< View style = { styles . container } >
8
- < AirPlayButton />
8
+ < AirPlayButton
9
+ activeTintColor = "blue"
10
+ tintColor = "black"
11
+ style = { styles . button }
12
+ />
9
13
</ View >
10
14
) ;
11
15
}
@@ -16,4 +20,8 @@ const styles = StyleSheet.create({
16
20
alignItems : 'center' ,
17
21
justifyContent : 'center' ,
18
22
} ,
23
+ button : {
24
+ width : 30 ,
25
+ height : 30 ,
26
+ } ,
19
27
} ) ;
Original file line number Diff line number Diff line change 1
1
#import < React/RCTViewManager.h>
2
2
#import < Foundation/Foundation.h>
3
- #import < AVFoundation/AVFoundation.h>
4
- #import < MediaPlayer/MediaPlayer.h>
3
+ #import < AVKit/AVRoutePickerView.h>
5
4
6
5
@interface RNAirPlayButtonManager : RCTViewManager
7
6
@end
@@ -12,17 +11,11 @@ @implementation RNAirPlayButtonManager
12
11
13
12
- (UIView *)view
14
13
{
15
- if (@available (iOS 11.0 , *)) {
16
- AVRoutePickerView *airplayButton = [[AVRoutePickerView alloc ] init ];
17
- airplayButton.activeTintColor = [UIColor blueColor ];
18
- airplayButton.tintColor = [UIColor whiteColor ];
19
- return airplayButton;
20
- } else {
21
- // If you still support previous iOS versions, you can use MPVolumeView
22
- MPVolumeView *airplayButton = [[MPVolumeView alloc ] init ];
23
- airplayButton.showsVolumeSlider = NO ;
24
- return airplayButton;
25
- }
14
+ AVRoutePickerView *airPlayButton = [[AVRoutePickerView alloc ] init ];
15
+ return airPlayButton;
26
16
}
27
17
18
+ RCT_EXPORT_VIEW_PROPERTY (activeTintColor, UIColor);
19
+ RCT_EXPORT_VIEW_PROPERTY (tintColor, UIColor);
20
+
28
21
@end
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-native-airplay-cast" ,
3
- "version" : " 0.1 .0" ,
4
- "description" : " Stream audio or video to AirPlay-enabled devices" ,
3
+ "version" : " 1.0 .0" ,
4
+ "description" : " Stream audio or video to AirPlay-enabled devices with a customizable AirPlay button " ,
5
5
"main" : " lib/commonjs/index" ,
6
6
"module" : " lib/module/index" ,
7
7
"types" : " lib/typescript/src/index.d.ts" ,
Original file line number Diff line number Diff line change 1
- import { requireNativeComponent } from 'react-native' ;
1
+ import { requireNativeComponent , ViewProps } from 'react-native' ;
2
2
3
3
// type AirPlayCastType = {
4
4
// };
5
5
6
6
// const { AirPlayCast } = NativeModules;
7
7
8
- export const AirPlayButton = requireNativeComponent ( 'RNAirPlayButton' ) ;
8
+ type AirPlayButtonProps = ViewProps & {
9
+ activeTintColor ?: string ;
10
+ tintColor ?: string ;
11
+ style ?: React . CSSProperties ;
12
+ } ;
13
+
14
+ export const AirPlayButton = requireNativeComponent < AirPlayButtonProps > (
15
+ 'RNAirPlayButton'
16
+ ) ;
9
17
10
18
// export default AirPlayCast as AirPlayCastType;
You can’t perform that action at this time.
0 commit comments