Hi,
I am trying to load a remote ogg file onto my app, but it doesn’t work. It does work with local mp3 files.
I couldn’t find which audio files are supported and I suspect this might be the issue.
And if we are at it, Is there a simple player containing a progress bar, play / pause functions for React Native using Expo (managed)?
Thanks…
I am attaching my code which is similar to the expo audio example:
import * as React from 'react';
import {
View,
StyleSheet,
Button,
} from 'react-native';
import { Audio } from 'expo-av';
const SAMPLE_OGG_FILE =
'Link to file';
export default function Player() {
const [sound, setSound] = React.useState();
async function playSound() {
console.log('Loading Sound');
try {
// const { sound } = await Audio.Sound.createAsync(
// { uri: SAMPLE_OGG_FILE },
// { shouldPlay: true },
// );
const { sound } = await Audio.Sound.createAsync(require('test.ogg'));
setSound(sound);
console.log('Playing Sound');
await sound.playAsync();
} catch (error) {
console.error(error);
}
}
React.useEffect(() => {
return sound
? () => {
console.log('Unloading Sound');
sound.unloadAsync();
}
: undefined;
}, [sound]);
return (
<View style={styles.container}>
<Button title="Play Sound" onPress={playSound} />
</View>
);
}
const styles = StyleSheet.create({});