react-native-audio-session
Advanced tools
Comparing version 0.0.3 to 0.0.4
15
index.js
@@ -37,8 +37,8 @@ import {NativeModules, Platform} from 'react-native' | ||
const create = () => { | ||
const noAndroid = () => { | ||
return new Promise((resolve, reject) => { | ||
resolve('AudioSession is not supported on Android.') | ||
resolve("AudioSession is not supported on Android.") | ||
}) | ||
} | ||
const currentCategory = () => { | ||
@@ -61,3 +61,3 @@ if (IS_IOS) { | ||
const keys = Object.keys(AudioOptions) | ||
const key = keys.length > event - 1 ? keys[event - 1] : null | ||
const key = keys.length > event - 1 ? keys[event - 1]: null | ||
resolve(AudioOptions[key]) | ||
@@ -83,2 +83,10 @@ }) | ||
const setActive = active => { | ||
if (IS_IOS) { | ||
return RNAudioSession.setActive(active) | ||
} else { | ||
return noAndroid() | ||
} | ||
} | ||
const setCategory = (category, options) => { | ||
@@ -112,2 +120,3 @@ if (IS_IOS) { | ||
currentMode, | ||
setActive, | ||
setCategory, | ||
@@ -114,0 +123,0 @@ setMode, |
{ | ||
"name": "react-native-audio-session", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "React Native module for handling the AVAudioSession instance on iOS.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ # react-native-audio-session | ||
A React Native module for handling category, category options and mode on the `AVAudioSession` sharedInstance on iOS. | ||
A React Native module for handling category, category options and mode on the [`AVAudioSession`](https://developer.apple.com/documentation/avfoundation/avaudiosession?language=objc) sharedInstance on iOS. | ||
@@ -21,2 +21,7 @@ ## Getting started | ||
// Set AVAudioSession active | ||
AudioSession.setActive(true) | ||
.then(() => { console.log('Success!') }) | ||
.catch(error => { console.log('Error!') }) | ||
// Set AVAudioSession category | ||
@@ -65,8 +70,9 @@ AudioSession.setCategory(AudioCategories.Playback) | ||
|---|---|---|---| | ||
|setCategory|`AudioCategories`, `AudioOptions` (nullable)|`Promise`|Set the current AVAudioSession category.| | ||
|setMode|`AudioModes`|`Promise`|Set the current AVAudioSession mode.| | ||
|setCategoryAndMode|`AudioCategories`, `AudioModes`, `AudioOptions` (nullable)|`Promise`|Set the current AVAudioSession category and mode.| | ||
|currentCategory|-|`Promise`|Get the current AVAudioSession category.| | ||
|currentOptions|-|`Promise`|Get the current AVAudioSession options.| | ||
|currentMode|-|`Promise`|Get the current AVAudioSession mode.| | ||
|setActive|`Bool`|`Promise`|Set the current AVAudioSession as active [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616627-setactive?language=objc).| | ||
|setCategory|`AudioCategories`, `AudioOptions` (nullable)|`Promise`|Set the current AVAudioSession category [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616442-setcategory?language=objc).| | ||
|setMode|`AudioModes`|`Promise`|Set the current AVAudioSession mode [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616614-setmode?language=objc).| | ||
|setCategoryAndMode|`AudioCategories`, `AudioModes`, `AudioOptions` (nullable)|`Promise`|Set the current AVAudioSession category and mode [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1771734-setcategory?language=objc).| | ||
|currentCategory|-|`Promise`|Get the current AVAudioSession category [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616615-category?language=objc).| | ||
|currentOptions|-|`Promise`|Get the current AVAudioSession options [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616503-categoryoptions?language=objc).| | ||
|currentMode|-|`Promise`|Get the current AVAudioSession mode [(Reference)](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616508-mode?language=objc).| | ||
@@ -73,0 +79,0 @@ ### Objects |
Sorry, the diff of this file is not supported yet
26545
110
131