Skip to content

Commit 713c874

Browse files
committed
Update README for 1.1.0
* add ringtone/ringback/busytone support * fix and refine forceSpeakerphoneOn * some audio routing bug fixes
1 parent 63fcc67 commit 713c874

File tree

1 file changed

+76
-5
lines changed

1 file changed

+76
-5
lines changed

README.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Handling media-routes/sensors/events during a audio/video chat on React Native
55
The purpose of this module is to handle actions/events during a phone call (audio/video) on `react-native`, ex:
66
* manage devices events like wired-headset plugged, proximity sensors and expose to javascript.
77
* automatically route audio to proper device based on events and platform API.
8-
* ( not implemented yet ) toggle flash light on/off, force microphone mute
8+
* toggle speaker or microphone on/off, toggle flash light on/off (not implemented yes)
9+
* play ringtone/ringback/dtmftone
10+
11+
basically, it is a telecommunication module which handle most of requirements when making/receiving/talking to a call.
912

1013
This module is desinged to work with [react-native-webrtc](https://github.com/oney/react-native-webrtc)
1114
you can find demo here: https://github.com/oney/RCTWebRTCDemo
@@ -21,6 +24,21 @@ you can find demo here: https://github.com/oney/RCTWebRTCDemo
2124
After install, you can use `rnpm` (`npm install rnpm -g`) to link android.
2225
use `rnpm link react-native-incall-manager` to link or manually if you like.
2326

27+
**optional sound files on android**
28+
if you want to use bundled ringtone/ringback/busytone sound instead of system sound
29+
30+
put files in `android/app/src/main/res/raw`
31+
and rename file correspond to sound type:
32+
33+
```
34+
incallmanager_busytone.mp3
35+
incallmanager_ringback.mp3
36+
incallmanager_ringback.mp3
37+
```
38+
39+
on android, as long as your file extension supported by android, this module will load it.
40+
41+
2442
===================================================
2543

2644
####ios:
@@ -41,6 +59,21 @@ before that, you should add this project manually:
4159
1. click your `project's xcodeproject root`, go to `build setting` and search `Objective-C Bridging Header`
4260
2. set you header location, the default path is: `ReactNativeProjectRoot/ios/`, in this case, you should set `../node_modules/react-native-incall-manager/ios/RNInCallManager/RNInCallManager-Bridging-Header.h`
4361

62+
**optional sound files on android**
63+
if you want to use bundled ringtone/ringback/busytone sound instead of system sound
64+
65+
1. add files into your_project directory under your project's xcodeproject root. ( or drag into it as described above. )
66+
2. check `copy file if needed`
67+
3. make sure filename correspond to sound type:
68+
69+
```
70+
incallmanager_busytone.mp3
71+
incallmanager_ringback.mp3
72+
incallmanager_ringback.mp3
73+
```
74+
75+
on ios, we only support mp3 files currently.
76+
4477
## Usage:
4578

4679
This module implement a basic handle logic automatically, just:
@@ -59,8 +92,44 @@ InCallManager.stop();
5992
// ... it will also remote event listeners ...
6093
```
6194

95+
if you want to use ringback:
96+
97+
```javascript
98+
// ringback is basically for OUTGOING call. and is part of start().
99+
100+
InCallManager.start({media: 'audio', ringback: '_BUNDLE_'}); // or _DEFAULT_ or _DTMF_
101+
//when callee answered, you MUST stop ringback explicitly:
102+
InCallManager.stopRingback();
103+
```
104+
105+
if you want to use busytone:
106+
107+
```javascript
108+
// busytone is basically for OUTGOING call. and is part of stop()
109+
// If the call failed or callee are busing,
110+
// you may want to stop the call and play busytone
111+
InCallManager.stop({busytone: '_DTMF_'}); // or _BUNDLE_ or _DEFAULT_
112+
```
113+
114+
if you want to use ringtone:
115+
116+
```javascript
117+
// ringtone is basically for INCOMING call. it's independent to start() and stop()
118+
// if you receiving an incoming call, before user pick up,
119+
// you may want to play ringtone to notify user.
120+
InCallManager.startRingtone('_BUNDLE_'); // or _DEFAULT_ or system filename with extension
121+
122+
// when user pickup
123+
InCallManager.stopRingtone();
124+
InCallManager.start();
125+
126+
// or user hangup
127+
InCallManager.stopRingtone();
128+
InCallManager.stop();
129+
130+
```
62131

63-
and interact with events if you want:
132+
also can interact with events if you want:
64133
see API section.
65134

66135
```javascript
@@ -80,10 +149,12 @@ DeviceEventEmitter.addListener('Proximity', function (data) {
80149
* audio will enable proximity sensor which is disabled by default if media=video
81150
* when proximity detect user closed to screen, turn off screen to avoid accident touch and route voice to earpiece.
82151
* when newly external device plugged, such as wired-headset, route audio to external device.
152+
* optional play ringback
83153

84154
**on stop:**
85155

86156
* set KeepScreenOn flag = false, remote event listeners, restore original user settings.
157+
* optional play busytone
87158

88159
## Custom Behavior:
89160

@@ -97,13 +168,13 @@ note: ios only supports `auto` currently.
97168

98169
| Method | android | ios | description |
99170
| :--- | :---: | :---: | :--- |
100-
| start(`{media: ?string, auto: ?boolean}`) | :smile: | :smile: | start incall manager.</br>default: `{media:'audio', auto: true}` |
101-
| stop() | :smile: | :smile: | stop incall manager |
171+
| start(`{media: ?string, auto: ?boolean, ringback: ?string}`) | :smile: | :smile: | start incall manager.</br> ringback accept non-empty string or it won't play</br>default: `{media:'audio', auto: true, ringback: ''}` |
172+
| stop(`{busytone: ?string}`) | :smile: | :smile: | stop incall manager</br> busytone accept non-empty string or it won't play</br> default: `{busytone: ''}` |
102173
| turnScreenOn() | :smile: | :rage: | force turn screen on |
103174
| turnScreenOff() | :smile: | :rage: | force turn screen off |
104175
| setKeepScreenOn(`enable: ?boolean`) | :smile: | :smile: | set KeepScreenOn flag = true or false</br>default: false |
105176
| setSpeakerphoneOn(`enable: ?boolean`) | :smile: | :rage: | toggle speaker ON/OFF once. but not force</br>default: false |
106-
| setForceSpeakerphoneOn(`enable: ?boolean`) | :smile: | :smile: | if set to true, will ignore all logic and force audio route to speaker</br>default: false |
177+
| setForceSpeakerphoneOn(`flag: ?boolean`) | :smile: | :smile: | true -> force speaker on</br> false -> force speaker off</br> null -> use default behavior according to media type</br>default: null |
107178
| setMicrophoneMute(`enable: ?boolean`) | :smile: | :rage: | mute/unmute micophone</br>default: false |
108179

109180
**Events**

0 commit comments

Comments
 (0)