How to play an mp3 file on the Internet?

Following is my code and error message, please help.

import React from 'react';
import {StyleSheet, Text, View, Button} from 'react-native';
import { Asset, Audio, Font, Video } from 'expo';

export default class App extends React.Component {
    onPressLearnMore = () => {
        console.log("this is a test");
        const soundObject = new Expo.Audio.Sound();
        try {
            await soundObject.loadAsync(require(''));
            await soundObject.playAsync();
            // Your sound is playing!
        } catch (error) {
            // An error occurred!

    render() {
        return (
            <View style={styles.container}>
                <Button title="Facebook" color="blue" onPress={this.onPressLearnMore}/>

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',

Hey @vincentwordtoday,

As the error message indicates, await is a reserved word only to be used in async functions. You’ll need to change your function from onPressLearnMore = () => {} to onPressLearnMore = async () => {}



It works now, thank you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.