If you want to play continue playing media, start a Service and control the MediaPlayer instance from there. You need to embed the MediaPlayer in a MediaBrowserServiceCompat service and have it interact with a MediaBrowserCompat in another activity.
MediaPlayer player = new MediaPlayer();
player.SetAudioStreamType(Stream.Music);
player.Prepared += (sender, args) => player.Start();
await player.SetDataSourceAsync(ApplicationContext, Android.Net.Uri.Parse(Mp3));
player.PrepareAsync();
But this is to play music in background, I get a System.IO.Stream from another device and would like to play it directly into the setDataSource. Something like this
12-20 15:55:51.429 W/dalvikvm(32750): Unable to resolve superclass of Lmd5c539bdc79f76d0c80e6cd44011eba829/StreamMediaDataSource; (388)
12-20 15:55:51.429 W/dalvikvm(32750): Link of class 'Lmd5c539bdc79f76d0c80e6cd44011eba829/StreamMediaDataSource;' failed
Answers
If you want to play continue playing media, start a Service and control the
MediaPlayer
instance from there. You need to embed theMediaPlayer
in aMediaBrowserServiceCompat
service and have it interact with aMediaBrowserCompat
in another activity.Tutorials:
https://developer.android.com/guide/topics/media/mediaplayer#mpandservices
https://devblogs.microsoft.com/xamarin/background-audio-streaming-with-xamarin-android/
But this is to play music in background, I get a System.IO.Stream from another device and would like to play it directly into the setDataSource. Something like this
I tried reading with MediaDataSource class like this
But this returns the