Skip to content

Commit 4a4c8b3

Browse files
John QuallsAaron Alaniz
John Qualls
and
Aaron Alaniz
authored
Add Readme, Changelog, and License (#7)
* Initial readme commit * Add '.' and change android min studio version to 3.6+ * First draft of the Getting Started section * Add changelog * Add getting started section to changelog [skip ci] Co-authored-by: Aaron Alaniz <[email protected]>
1 parent feb565d commit 4a4c8b3

File tree

4 files changed

+134
-4
lines changed

4 files changed

+134
-4
lines changed

CHANGELOG.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Change Log
2+
3+
### 0.1.0
4+
5+
This release marks the first iteration of the AudioSwitch library: an Android audio management library for real-time communication apps.
6+
7+
This initial release comes with the following features:
8+
9+
- Manage [audio focus](https://developer.android.com/guide/topics/media-apps/audio-focus) for typical VoIP and Video conferencing use cases.
10+
- Manage audio input and output devices.
11+
- Detect changes in available audio devices
12+
- Enumerate audio devices
13+
- Select an audio device
14+
15+
## Getting Started
16+
17+
To get started using this library, follow the steps below.
18+
19+
### AudioDeviceSelector Setup
20+
Instantiate an instance of the [AudioDeviceSelector](audioswitch/src/main/java/com/twilio/audioswitch/selection/AudioDeviceSelector.kt) class, passing a reference to the application context.
21+
22+
```
23+
val audioDeviceSelector = AudioDeviceSelector(applicationContext)
24+
```
25+
26+
### Listen for Devices
27+
To begin listening for live audio device changes, call the start function and pass a lambda that will receive [AudioDevices](audioswitch/src/main/java/com/twilio/audioswitch/selection/AudioDevice.kt) when they become available.
28+
29+
```
30+
audioDeviceSelector.start { audioDevices, selectedDevice ->
31+
// TODO update UI with audio devices
32+
}
33+
```
34+
You can also retrieve the available and selected audio devices manually at any time by calling the following properties:
35+
```
36+
val devices: List<AudioDevice> = audioDeviceSelector.availableAudioDevices
37+
val selectedDevice: AudioDevice? = audioDeviceSelector.selectedAudioDevice
38+
```
39+
**Note:** Don't forget to stop listening for audio devices when no longer needed in order to prevent a memory leak.
40+
```
41+
audioDeviceSelector.stop()
42+
```
43+
44+
### Select a Device
45+
Before activating an AudioDevice, it needs to be selected first.
46+
```
47+
devices.find { it is AudioDevice.Speakerphone }?.let { audioDeviceSelector.selectDevice(it) }
48+
```
49+
If no device is selected, then the library will automatically select a device based on the following priority: `BluetoothHeadset -> WiredHeadset -> Earpiece -> Speakerphone`.
50+
51+
### Activate a Device
52+
Activating a device acquires audio focus with [voice communication usage](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_VOICE_COMMUNICATION) and begins routing audio input/output to the selected device.
53+
```
54+
audioDeviceSelector.activate()
55+
```
56+
Make sure to revert back to the prior audio state when it makes sense to do so in your app.
57+
```
58+
audioDeviceSelector.deactivate()
59+
```
60+
**Note:** The `stop()` function will call `deactivate()` before closing AudioDeviceSelector resources.

LICENSE renamed to LICENSE.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
181+
boilerplate notice, with the fields enclosed by brackets "{}"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2020 Twilio, inc.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

+72-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
1-
# audioswitch
2-
An Android audio management library for building real-time communication apps.
1+
# AudioSwitch
2+
3+
[![CircleCI](https://circleci.com/gh/twilio/audioswitch.svg?style=svg)](https://circleci.com/gh/twilio/audioswitch)
4+
5+
An Android audio management library for real-time communication apps.
6+
7+
![video-app-screenshots](images/audioswitch-logo.png)
8+
9+
## Features
10+
11+
- [x] Manage [audio focus](https://developer.android.com/guide/topics/media-apps/audio-focus) for typical VoIP and Video conferencing use cases.
12+
- [x] Manage audio input and output devices.
13+
- [x] Detect changes in available audio devices
14+
- [x] Enumerate audio devices
15+
- [x] Select an audio device
16+
17+
## Requirements
18+
19+
Android Studio Version | Android API Version Min
20+
------------ | -------------
21+
3.6+ | 16
22+
23+
## Getting Started
24+
25+
To get started using this library, follow the steps below.
26+
27+
### AudioDeviceSelector Setup
28+
Instantiate an instance of the [AudioDeviceSelector](audioswitch/src/main/java/com/twilio/audioswitch/selection/AudioDeviceSelector.kt) class, passing a reference to the application context.
29+
30+
```
31+
val audioDeviceSelector = AudioDeviceSelector(applicationContext)
32+
```
33+
34+
### Listen for Devices
35+
To begin listening for live audio device changes, call the start function and pass a lambda that will receive [AudioDevices](audioswitch/src/main/java/com/twilio/audioswitch/selection/AudioDevice.kt) when they become available.
36+
37+
```
38+
audioDeviceSelector.start { audioDevices, selectedDevice ->
39+
// TODO update UI with audio devices
40+
}
41+
```
42+
You can also retrieve the available and selected audio devices manually at any time by calling the following properties:
43+
```
44+
val devices: List<AudioDevice> = audioDeviceSelector.availableAudioDevices
45+
val selectedDevice: AudioDevice? = audioDeviceSelector.selectedAudioDevice
46+
```
47+
**Note:** Don't forget to stop listening for audio devices when no longer needed in order to prevent a memory leak.
48+
```
49+
audioDeviceSelector.stop()
50+
```
51+
52+
### Select a Device
53+
Before activating an AudioDevice, it needs to be selected first.
54+
```
55+
devices.find { it is AudioDevice.Speakerphone }?.let { audioDeviceSelector.selectDevice(it) }
56+
```
57+
If no device is selected, then the library will automatically select a device based on the following priority: `BluetoothHeadset -> WiredHeadset -> Earpiece -> Speakerphone`.
58+
59+
### Activate a Device
60+
Activating a device acquires audio focus with [voice communication usage](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_VOICE_COMMUNICATION) and begins routing audio input/output to the selected device.
61+
```
62+
audioDeviceSelector.activate()
63+
```
64+
Make sure to revert back to the prior audio state when it makes sense to do so in your app.
65+
```
66+
audioDeviceSelector.deactivate()
67+
```
68+
**Note:** The `stop()` function will call `deactivate()` before closing AudioDeviceSelector resources.
69+
70+
## License
71+
72+
Apache 2.0 license. See [LICENSE.txt](LICENSE.txt) for details.

images/audioswitch-logo.png

9.41 KB
Loading

0 commit comments

Comments
 (0)