kadiks / react-native-itunes

iTunes module for React Native
MIT License
62 stars 39 forks source link

[Play Music using other Library] How do i get path to the music file? #7

Closed themakerman closed 7 years ago

themakerman commented 7 years ago

Hi Kadiks,

Everything's working fine and i am able to search for music files on my device. To maintain cross platform ability and code sharing between android/iOS versions i have to use a different library to play sound. However when i queried iTunes.getTracks() function to get all the tracks i was unable to see any path attribute which would let me play music through other library by just passing that attribute.

Can you help me out with this? Rest everything worked super fine. Thanks.

kadiks commented 7 years ago

getTracks method has one optional object parameter with the fields key that can hold an array of specific fields.

Here is an example: https://github.com/kadiks/react-native-itunes/blob/master/examples.md#get-all-tracks-and-extract-only-genre-and-title

In your case, the field you want is the assetUrl. If you want more fields, here is the list: https://developer.apple.com/documentation/mediaplayer/mpmediaitem

Finally, you will only see the assetUrl of file that you actually own.