React-native-track-player: File system playing

Created on 11 Oct 2017  路  6Comments  路  Source: react-native-kit/react-native-track-player

hi
i placed an mp3 file in music directory storage/emulated/0/Music/music.mp3 and use file:// prefix for load this but it doesn't work (shows in notificationbar but not playing)
code:

await TrackPlayer.add({
      id: 'track',
      url: 'file://storage/emulated/0/Music/music.mp3',
      title: 'Despacito gg',
      artist: 'Luis Fonsi Feat. Daddy Yankee',
      artwork: 'http://images-eu.ssl-images-amazon.com/images/I/61JH2ggghmL._AC_US160_.jpg'
});
TrackPlayer.play();

whats wrong?

Android Question

All 6 comments

You're on Android, right?

@Guichaguri yes

@msabaeian Just tested here, and it works for me.
Try which three slashes, like so: file:///storage/emulated/0/Music/music.mp3

@Guichaguri im trying with three slashes and it doesnt work:

`await TrackPlayer.add([{
            id: "1",
            url: "file:///storage/emulated/0/Downloads/music/Yummy.mp3",
            title: "Yummy",
            artist: "Justin Bieber"
        }]);

        TrackPlayer.play();`

Yes local mp3 not playing with /// or with this //. Did anyone found solution?

@ajoykarmakar yes, if you are using it in Android X, allow permissions first, read external and edit external storage then add in AndroidManifest in application this: android:requestLegacyExternalStorage="true"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amed picture amed  路  4Comments

fabiocosta88 picture fabiocosta88  路  3Comments

sagargheewala picture sagargheewala  路  3Comments

simenJohnsen picture simenJohnsen  路  3Comments

RiccardoNL picture RiccardoNL  路  3Comments