Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async play () {
const status = await askAsyncPermissions(Permissions.AUDIO_RECORDING)
if (status !== 'granted') {
const res = {errMsg: `Permissions denied!`}
return Promise.reject(res)
}
const soundStatus = await this.soundObject.getStatusAsync()
try {
if (soundStatus.isLoaded === false && (soundStatus as any).isPlaying === undefined) {
// First load
await this._firstPlay()
} else {
await this.soundObject.playAsync()
}
// TODO
export const requestAudioPermission = async () => {
let chargeForward = true
const {Permissions} = require('react-native-unimodules')
let {status} = await Permissions.getAsync(Permissions.AUDIO_RECORDING)
if (status === Permissions.PermissionStatus.UNDETERMINED) {
if (isIOS) {
const askRes = await Permissions.askAsync(Permissions.AUDIO_RECORDING)
status = askRes.status
} else {
const askRes = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO)
switch (askRes) {
case 'never_ask_again':
case 'denied':
status = Permissions.PermissionStatus.DENIED
}
}
chargeForward = false
}
if (status === Permissions.PermissionStatus.DENIED) {
throw new Error('Please allow Keybase to access the microphone in the phone settings.')
}
return chargeForward
}
export const requestAudioPermission = async () => {
let chargeForward = true
const {Permissions} = require('react-native-unimodules')
let {status} = await Permissions.getAsync(Permissions.AUDIO_RECORDING)
if (status === Permissions.PermissionStatus.UNDETERMINED) {
if (isIOS) {
const askRes = await Permissions.askAsync(Permissions.AUDIO_RECORDING)
status = askRes.status
} else {
const askRes = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO)
switch (askRes) {
case 'never_ask_again':
case 'denied':
status = Permissions.PermissionStatus.DENIED
}
}
chargeForward = false
}
if (status === Permissions.PermissionStatus.DENIED) {
throw new Error('Please allow Keybase to access the microphone in the phone settings.')
async start (opts = {}) {
const status = await askAsyncPermissions(Permissions.AUDIO_RECORDING)
if (status !== 'granted') {
const res = {errMsg: `Permissions denied!`}
return Promise.reject(res)
}
const {
duration = 60000,
sampleRate = 8000,
numberOfChannels = 2,
encodeBitRate = 48000,
format = 'aac',
frameSize,
audioSource = 'auto'
}: any = opts
let options = {
android: Object.assign({}, RecorderManager.RecordingOptions.android, {sampleRate, numberOfChannels, bitRate: encodeBitRate}),