I have an Android service that can play local song (I followed this tuto: https://code.tutsplus.com/tutorials/create-a-music-player-on-android-song-playback--mobile-22778) I can control the player using a MediaController (made with this tuto: https://code.tutsplus.com/tutorials/create-a-music-player-on-android-user-controls--mobile-22787)
I want to be able to play local song and Spotify song too without changing my controller and if possible using the same service. The purpose is to be able to have a waiting list that can contain local track or spotify track and the service should be able to read both.
I have the Spotify SDK and I'm able to read a song with the player that spotify offer in his SDK, but is there a way to get a streaming URL for a song and the play it with the local player using:
String url = "http://........"; // Spotify URL here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
mediaPlayer.start();
So the controller is synchronized even if it's a Spotify song or a local one ? If I can't get the streaming link, is there a way to use the Android MusicController with the Spotify MusicPlayer ?
Note: Every user that used the App is connected with its Spotify Account. I use fragement so the Controller is create once and then it's the same I can access the service everywhere