Xamarin Android App not streaming online radio stream

Home - Xamarin Android App not streaming online radio stream

Ikrar Ilyas asked 3 years ago

So I’m trying to make a Android app for an online radio and no matter how much I use the guides on Xamarin, it’s not streaming.
My code: http://pastebin.com/K20RX8Yk The coding environment I am using is Xamarin.
Android and I am coding in the Xamarin Studio. I’ve been using the Android emu running API 16. I have already tried different path files but sadly that hasn’t fixed it.

1 Answers
Avianto Staff answered 3 years ago

I would advice to use the MediaPlayer to stream audio on Android, as it is much easier to use then AudioTrack. Potentially AudioTrack could have better performance but you need to do quite some stuff yourself to get it working correctly.
Here is a blog post with example how to use MediaPlayer on Xamarin Android:http://blog.xamarin.com/background-audio-streaming-with-xamarin.android/
A quick example out of that is:

private const string Mp3 = @";stream.mp3";
private MediaPlayer player;

private void IntializePlayer()
            player = new MediaPlayer();

            //Tell our player to sream music

private async void Play()
            if (player == null) {

            try {
                await player.SetDataSourceAsync(ApplicationContext, Android.Net.Uri.Parse(Mp3));
            catch (Exception ex) {
                //unable to start playback log error
                Console.WriteLine("Unable to start playback: " + ex);
Your Answer