-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
35 lines (26 loc) · 995 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { NativeModules,NativeEventEmitter,Platform } from 'react-native';
import { DeviceEventEmitter } from 'react-native'
const ANDROIDMAXVALUE = 15;
const { RNVolume } = NativeModules;
export default {
getVolume : (callback) => {
// iOS
RNVolume.getVolume(callback);
},
setVolume: (value,onVolumeChangeNotification) => {
onVolumeChangeNotification = (typeof onVolumeChangeNotification == "undefined") ? true : false;
if(Platform.OS == 'ios'){
RNVolume.setVolume(parseFloat(value),onVolumeChangeNotification);
}
else if (Platform.OS == 'android'){
RNVolume.setVolume(parseFloat(value * ANDROIDMAXVALUE),onVolumeChangeNotification);
}
//iOS
},
onVolumeChange: (callback) => {
// iOS
RNVolume.acivateListner();
const VolumeListener = new NativeEventEmitter(NativeModules.RNVolume)
VolumeListener.addListener('onVolumeChange', callback)
},
} ;