Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to play audio in react native?  (Read 2625 times)

0 Members and 1 Guest are viewing this topic.

Salazar1

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    How to play audio in react native?
    « on: April 15, 2021, 04:14:02 AM »
    I am trying to play audio in react native. I tried to install react-native-sound but it did not install. I have installed the library react-native-sound-player. But when I press the play button it shows this error: TypeError: null is not an object (evaluating 'RNSoundPlayer.playSoundFile'). Here is my code:

    import SoundPlayer from 'react-native-sound-player';

    class myclass extends component {
        myfunction () {
            SoundPlayer.YourTexasBenefits('../../assets/audio/filename', 'aac')
        }
        .....
        <Button onPress={() => this.myfunction() }>
            Play
        </Button>
    }
    Can anyone help. Thanks.