-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <aalaniz@twilio.com>
- Loading branch information
John Qualls
and
Aaron Alaniz
authored
Apr 28, 2020
1 parent
feb565d
commit 4a4c8b3
Showing
4 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Change Log | ||
|
||
### 0.1.0 | ||
|
||
This release marks the first iteration of the AudioSwitch library: an Android audio management library for real-time communication apps. | ||
|
||
This initial release comes with the following features: | ||
|
||
- Manage [audio focus](https://developer.android.com/guide/topics/media-apps/audio-focus) for typical VoIP and Video conferencing use cases. | ||
- Manage audio input and output devices. | ||
- Detect changes in available audio devices | ||
- Enumerate audio devices | ||
- Select an audio device | ||
|
||
## Getting Started | ||
|
||
To get started using this library, follow the steps below. | ||
|
||
### AudioDeviceSelector Setup | ||
Instantiate an instance of the [AudioDeviceSelector](audioswitch/src/main/java/com/twilio/audioswitch/selection/AudioDeviceSelector.kt) class, passing a reference to the application context. | ||
|
||
``` | ||
val audioDeviceSelector = AudioDeviceSelector(applicationContext) | ||
``` | ||
|
||
### Listen for Devices | ||
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. | ||
|
||
``` | ||
audioDeviceSelector.start { audioDevices, selectedDevice -> | ||
// TODO update UI with audio devices | ||
} | ||
``` | ||
You can also retrieve the available and selected audio devices manually at any time by calling the following properties: | ||
``` | ||
val devices: List<AudioDevice> = audioDeviceSelector.availableAudioDevices | ||
val selectedDevice: AudioDevice? = audioDeviceSelector.selectedAudioDevice | ||
``` | ||
**Note:** Don't forget to stop listening for audio devices when no longer needed in order to prevent a memory leak. | ||
``` | ||
audioDeviceSelector.stop() | ||
``` | ||
|
||
### Select a Device | ||
Before activating an AudioDevice, it needs to be selected first. | ||
``` | ||
devices.find { it is AudioDevice.Speakerphone }?.let { audioDeviceSelector.selectDevice(it) } | ||
``` | ||
If no device is selected, then the library will automatically select a device based on the following priority: `BluetoothHeadset -> WiredHeadset -> Earpiece -> Speakerphone`. | ||
|
||
### Activate a Device | ||
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. | ||
``` | ||
audioDeviceSelector.activate() | ||
``` | ||
Make sure to revert back to the prior audio state when it makes sense to do so in your app. | ||
``` | ||
audioDeviceSelector.deactivate() | ||
``` | ||
**Note:** The `stop()` function will call `deactivate()` before closing AudioDeviceSelector resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,72 @@ | ||
# audioswitch | ||
An Android audio management library for building real-time communication apps. | ||
# AudioSwitch | ||
|
||
[![CircleCI](https://circleci.com/gh/twilio/audioswitch.svg?style=svg)](https://circleci.com/gh/twilio/audioswitch) | ||
|
||
An Android audio management library for real-time communication apps. | ||
|
||
![video-app-screenshots](images/audioswitch-logo.png) | ||
|
||
## Features | ||
|
||
- [x] Manage [audio focus](https://developer.android.com/guide/topics/media-apps/audio-focus) for typical VoIP and Video conferencing use cases. | ||
- [x] Manage audio input and output devices. | ||
- [x] Detect changes in available audio devices | ||
- [x] Enumerate audio devices | ||
- [x] Select an audio device | ||
|
||
## Requirements | ||
|
||
Android Studio Version | Android API Version Min | ||
------------ | ------------- | ||
3.6+ | 16 | ||
|
||
## Getting Started | ||
|
||
To get started using this library, follow the steps below. | ||
|
||
### AudioDeviceSelector Setup | ||
Instantiate an instance of the [AudioDeviceSelector](audioswitch/src/main/java/com/twilio/audioswitch/selection/AudioDeviceSelector.kt) class, passing a reference to the application context. | ||
|
||
``` | ||
val audioDeviceSelector = AudioDeviceSelector(applicationContext) | ||
``` | ||
|
||
### Listen for Devices | ||
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. | ||
|
||
``` | ||
audioDeviceSelector.start { audioDevices, selectedDevice -> | ||
// TODO update UI with audio devices | ||
} | ||
``` | ||
You can also retrieve the available and selected audio devices manually at any time by calling the following properties: | ||
``` | ||
val devices: List<AudioDevice> = audioDeviceSelector.availableAudioDevices | ||
val selectedDevice: AudioDevice? = audioDeviceSelector.selectedAudioDevice | ||
``` | ||
**Note:** Don't forget to stop listening for audio devices when no longer needed in order to prevent a memory leak. | ||
``` | ||
audioDeviceSelector.stop() | ||
``` | ||
|
||
### Select a Device | ||
Before activating an AudioDevice, it needs to be selected first. | ||
``` | ||
devices.find { it is AudioDevice.Speakerphone }?.let { audioDeviceSelector.selectDevice(it) } | ||
``` | ||
If no device is selected, then the library will automatically select a device based on the following priority: `BluetoothHeadset -> WiredHeadset -> Earpiece -> Speakerphone`. | ||
|
||
### Activate a Device | ||
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. | ||
``` | ||
audioDeviceSelector.activate() | ||
``` | ||
Make sure to revert back to the prior audio state when it makes sense to do so in your app. | ||
``` | ||
audioDeviceSelector.deactivate() | ||
``` | ||
**Note:** The `stop()` function will call `deactivate()` before closing AudioDeviceSelector resources. | ||
|
||
## License | ||
|
||
Apache 2.0 license. See [LICENSE.txt](LICENSE.txt) for details. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.