There is a library on github (audio player) that plays music on the device. Is it possible to remake this player so that it builds the same list of objects - (there is already ready JSON , parsing data from it to the list, and playing these objects through the ExoPlayer player in your application).

Github library: X-Music-Player-Pro

The question itself is: How, what and where should I change in this library so that the application does not take the music from the device, but loads the "station list" from this very JSON file .. In general, replace this very place in the code where the music device is taken away.

PS: in my application, the JSON file is in the / assets folder, parsed from there, created as an appropriate list. That is, you just need to change the code in the library of this player, so that you take the necessary data instead of music from the device. Thank you in advance if you show where you need to start, and what to change.

  • Maybe parse your JSON, slip the URL & AUDIO_STREAM into the MediPlayer. in lib service will have to adjust. Just how to answer your question? Rewrite for you? There is anything mb. - Shwarz Andrei pm
  • I can not understand in which class the music is parsed from the device into the application. - Anton
  • In the Service, find MediaService, that the type of that, I glanced briefly, like everything is done there. - Shwarz Andrei
  • Yes, it is possible. But as for this player - hammer. There is a lot of work on the file system, reading / processing tracks. It may slip a link to the stream, instead of the file, you will succeed, but everything else will break. Without serious interference with the code, nothing will come of it. - Profesor08

1 answer 1

The library is strongly tied to the ContentProvider and the structure of the system service providing information about media resources MediaStore.Audio.Media (On the one hand, it’s very good).

In order not to edit the sources much, you can do the following:

1) Create your ContentProvider, which will duplicate the functionality of the MediaStore.Audio.Media service (clone, with the same tables and field names).

For tables and field names, you can find it here: https://developer.android.com/reference/android/provider/MediaStore.Audio.html

2) After in the X-Music-Player-Pro library all calls of the type: new CursorLoader(getContext(), musicUri , null, selection, null, order); replace the musicUri parameter by specifying the path to your created ContentProvider (clone of the MediaStore.Audio.Media *** service).

3) As a result, you can safely modify the playlist.