Play local song and spotify song in the same android player service
<p>I have an Android service that can play local song (I followed this tuto: <a href="https://code.tutsplus.com/tutorials/create-a-music-player-on-android-song-playback--mobile-22778" rel="nofollow noreferrer">https://code.tutsplus.com/tutorials/create-a-music-player-on-android-song-playback--mobile-22778</a>)
I can control the player using a MediaController (made with this tuto:
<a href="https://code.tutsplus.com/tutorials/create-a-music-player-on-android-user-controls--mobile-22787" rel="nofollow noreferrer">https://code.tutsplus.com/tutorials/create-a-music-player-on-android-user-controls--mobile-22787</a>)</p>

<p>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.</p>

<p>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:</p>

<pre><code>String url = "http://........"; // Spotify URL here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare(); 
mediaPlayer.start();
</code></pre>

<p>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 ?</p>

<p>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</p>