react-native-airplay-module 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/ios/AirplayModule.h +0 -7
- package/ios/AirplayModule.mm +38 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-airplay-module.podspec +1 -1
- package/src/index.tsx +13 -16
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# react-native-airplay-module
|
|
2
2
|
|
|
3
|
-
React Native
|
|
3
|
+
React Native AirPlay Module
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,14 +8,31 @@ React Native Airplay module
|
|
|
8
8
|
npm install react-native-airplay-module
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
```sh
|
|
12
|
+
yarn add react-native-airplay-module
|
|
13
|
+
```
|
|
14
|
+
|
|
11
15
|
## Usage
|
|
12
16
|
|
|
13
17
|
```js
|
|
14
|
-
import
|
|
18
|
+
import AirPlay from 'react-native-airplay-module'
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
AirPlay.startScan()
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
AirPlay.AirPlayListener.addListener('deviceConnected', ({ devices }) => {
|
|
24
|
+
console.log(devices)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return () => {
|
|
28
|
+
AirPlay.disconnect()
|
|
29
|
+
}
|
|
30
|
+
}, [])
|
|
31
|
+
|
|
32
|
+
const openMenu = () => {
|
|
33
|
+
AirPlay.openMenu()
|
|
34
|
+
}
|
|
17
35
|
|
|
18
|
-
const result = await multiply(3, 7);
|
|
19
36
|
```
|
|
20
37
|
|
|
21
38
|
## Contributing
|
|
@@ -25,7 +42,3 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
|
|
|
25
42
|
## License
|
|
26
43
|
|
|
27
44
|
MIT
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
package/ios/AirplayModule.h
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
#import <React/RCTEventEmitter.h>
|
|
2
|
-
|
|
3
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
-
#import "RNAirplayModuleSpec.h"
|
|
5
|
-
|
|
6
|
-
@interface AirplayModule : RCTEventEmitter <NativeAirplayModuleSpec>
|
|
7
|
-
#else
|
|
8
2
|
#import <React/RCTBridgeModule.h>
|
|
9
3
|
|
|
10
4
|
@interface AirplayModule : RCTEventEmitter <RCTBridgeModule>
|
|
11
|
-
#endif
|
|
12
5
|
|
|
13
6
|
@end
|
package/ios/AirplayModule.mm
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
#import <AVFoundation/AVFoundation.h>
|
|
3
3
|
#import <AudioToolbox/AudioToolbox.h>
|
|
4
4
|
#import <AVKit/AVKit.h>
|
|
5
|
+
#import <React/RCTLog.h>
|
|
6
|
+
#import <React/RCTUtils.h>
|
|
7
|
+
|
|
8
|
+
@interface AirplayModule () <AVRoutePickerViewDelegate>
|
|
9
|
+
@property(nonatomic, strong) AVRoutePickerView *routePickerView;
|
|
10
|
+
@end
|
|
5
11
|
|
|
6
12
|
@implementation AirplayModule
|
|
7
13
|
@synthesize bridge = _bridge;
|
|
@@ -31,17 +37,47 @@ RCT_EXPORT_METHOD(disconnect) {
|
|
|
31
37
|
RCT_EXPORT_METHOD(openMenu)
|
|
32
38
|
{
|
|
33
39
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
34
|
-
|
|
40
|
+
if (self.routePickerView.window != nil) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
UIViewController *presenter = RCTPresentedViewController();
|
|
45
|
+
if (presenter.viewIfLoaded.window == nil) {
|
|
46
|
+
RCTLogWarn(@"AirPlay route picker requires a visible presenting view.");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Give AVKit an explicit window/presenter and keep its anchor alive until
|
|
51
|
+
// dismissal instead of relying on an unattached, temporary picker.
|
|
52
|
+
AVRoutePickerView *routePickerView =
|
|
53
|
+
[[AVRoutePickerView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
|
|
54
|
+
self.routePickerView = routePickerView;
|
|
55
|
+
routePickerView.delegate = self;
|
|
56
|
+
[presenter.view addSubview:routePickerView];
|
|
57
|
+
[routePickerView layoutIfNeeded];
|
|
58
|
+
|
|
35
59
|
for (UIView *subview in routePickerView.subviews) {
|
|
36
60
|
if ([subview isKindOfClass:[UIButton class]]) {
|
|
37
61
|
UIButton *button = (UIButton *)subview;
|
|
38
62
|
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
|
|
39
|
-
|
|
63
|
+
return;
|
|
40
64
|
}
|
|
41
65
|
}
|
|
66
|
+
|
|
67
|
+
RCTLogWarn(@"AirPlay route picker did not create its route button.");
|
|
68
|
+
[routePickerView removeFromSuperview];
|
|
69
|
+
self.routePickerView = nil;
|
|
42
70
|
});
|
|
43
71
|
}
|
|
44
72
|
|
|
73
|
+
- (void)routePickerViewDidEndPresentingRoutes:(AVRoutePickerView *)routePickerView
|
|
74
|
+
{
|
|
75
|
+
[routePickerView removeFromSuperview];
|
|
76
|
+
if (self.routePickerView == routePickerView) {
|
|
77
|
+
self.routePickerView = nil;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
45
81
|
- (void)routeChanged:(NSNotification *)sender {
|
|
46
82
|
[self sendInformations];
|
|
47
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","AirplayModule","NativeModules","AirPlayListener","NativeEventEmitter","startScan","Platform","OS","disconnect","openMenu","_default","exports","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAAGC,0BAAa,CAACD,aAAa;AAEjD,MAAME,eAAe,GAAG,IAAIC,+BAAkB,CAACH,aAAa,CAAC;AAE7D,MAAMI,SAAS,GAAG,SAAAA,CAAA,EAAY;EAC5B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","AirplayModule","NativeModules","AirPlayListener","NativeEventEmitter","startScan","Platform","OS","disconnect","openMenu","_default","exports","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAAGC,0BAAa,CAACD,aAAa;AAEjD,MAAME,eAAe,GAAG,IAAIC,+BAAkB,CAACH,aAAa,CAAC;AAE7D,MAAMI,SAAS,GAAG,SAAAA,CAAA,EAAY;EAC5B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACI,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAMG,UAAU,GAAG,SAAAA,CAAA,EAAY;EAC7B,IAAIF,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACO,UAAU,CAAC,CAAC;AACnC,CAAC;AAED,MAAMC,QAAQ,GAAG,SAAAA,CAAA,EAAY;EAC3B,IAAIH,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACQ,QAAQ,CAAC,CAAC;AACjC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa;EACbT,eAAe;EACfE,SAAS;EACTG,UAAU;EACVC;AACF,CAAC","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","AirplayModule","AirPlayListener","startScan","OS","disconnect","openMenu"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAMC,aAAa,GAAGH,aAAa,CAACG,aAAa;AAEjD,MAAMC,eAAe,GAAG,IAAIH,kBAAkB,CAACE,aAAa,CAAC;AAE7D,MAAME,SAAS,GAAG,SAAAA,CAAA,EAAY;EAC5B,IAAIH,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","AirplayModule","AirPlayListener","startScan","OS","disconnect","openMenu"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAMC,aAAa,GAAGH,aAAa,CAACG,aAAa;AAEjD,MAAMC,eAAe,GAAG,IAAIH,kBAAkB,CAACE,aAAa,CAAC;AAE7D,MAAME,SAAS,GAAG,SAAAA,CAAA,EAAY;EAC5B,IAAIH,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACE,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAME,UAAU,GAAG,SAAAA,CAAA,EAAY;EAC7B,IAAIL,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACI,UAAU,CAAC,CAAC;AACnC,CAAC;AAED,MAAMC,QAAQ,GAAG,SAAAA,CAAA,EAAY;EAC3B,IAAIN,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACK,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,eAAe;EACbJ,eAAe;EACfC,SAAS;EACTE,UAAU;EACVC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAY,MAAM,cAAc,CAAC;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAY,MAAM,cAAc,CAAC;;;;;;;AAqB3E,wBAKE"}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
14
|
s.platforms = { :ios => min_ios_version_supported }
|
|
15
|
-
s.source = { :git => "https://github.com/Spicy-Sparks/react-native-airplay-module.git", :tag => "#{s.version}" }
|
|
15
|
+
s.source = { :git => "https://github.com/Spicy-Sparks/react-native-airplay-module.git", :tag => "v#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm}"
|
|
18
18
|
|
package/src/index.tsx
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
const AirplayModule = NativeModules.AirplayModule
|
|
3
|
+
const AirplayModule = NativeModules.AirplayModule;
|
|
4
4
|
|
|
5
|
-
const AirPlayListener = new NativeEventEmitter(AirplayModule)
|
|
5
|
+
const AirPlayListener = new NativeEventEmitter(AirplayModule);
|
|
6
6
|
|
|
7
7
|
const startScan = function () {
|
|
8
|
-
if (Platform.OS !== 'ios' || !AirplayModule)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
if (Platform.OS !== 'ios' || !AirplayModule) return;
|
|
9
|
+
return AirplayModule.startScan();
|
|
10
|
+
};
|
|
12
11
|
|
|
13
12
|
const disconnect = function () {
|
|
14
|
-
if (Platform.OS !== 'ios' || !AirplayModule)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
if (Platform.OS !== 'ios' || !AirplayModule) return;
|
|
14
|
+
return AirplayModule.disconnect();
|
|
15
|
+
};
|
|
18
16
|
|
|
19
17
|
const openMenu = function () {
|
|
20
|
-
if (Platform.OS !== 'ios' || !AirplayModule)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
18
|
+
if (Platform.OS !== 'ios' || !AirplayModule) return;
|
|
19
|
+
return AirplayModule.openMenu();
|
|
20
|
+
};
|
|
24
21
|
|
|
25
22
|
export default {
|
|
26
23
|
AirPlayListener,
|
|
27
24
|
startScan,
|
|
28
25
|
disconnect,
|
|
29
|
-
openMenu
|
|
30
|
-
}
|
|
26
|
+
openMenu,
|
|
27
|
+
};
|