Xamarin Audio player streaming not working in Galaxy S8/S9/S10

Hi,

fairly new to xamarin forms and in desperate need for help, facing an issue for the past 3 days:

Please google :xamarin-audio-players-not-working-in-galaxy-s8 and the stack overflow question should be at the top.

Im struggling to stream a shoutcast radio stream (HE-AAC @ 56 kbps, 22.05 kHz) with a samsung galaxy S8/S9/S10

The audio player plays the Radio stream no problem in the emulator, but when debugging with the above devices the stream does not play. I get an unknown media error when debugging - subscribing to the players error event.

Ive looked into LibVLCSHarp nuget package but I cant find examples on streaming audio in the above format.

Desperately looking for help.

Tagged:

Best Answer

  • jasonLeeXamarinjasonLeeXamarin ✭✭ ✭✭
    Accepted Answer

    I found a nuget package: LibVLCSharp.Forms

    in the Main application created a class:

    using LibVLCSharp.Shared;

    public class RadioStream
    {
    readonly LibVLC _libVLC;
    readonly MediaPlayer _mp;

        public RadioStream()
        {
            if (DesignMode.IsDesignModeEnabled) return;
    
            Core.Initialize();
    
            _libVLC = new LibVLC();
    
            _mp = new MediaPlayer(_libVLC);
        }
    
        public void Init()
        {
            _mp.Media = new Media(_libVLC, "http://url/stream", FromType.FromLocation);
    
            _mp.Media.AddOption(":no-video");
    
        }
    
    
        public void Play(bool play)
        {
            if (play)
                _mp.Play();
            else _mp.Pause();
        }
    
        public bool isPlaying()
        {
            if (_mp.IsPlaying == false)
                return false;
            else
                return true;
        }
    
    }
    

    And its working!

    In a while loop I check the isPlaying() that allows me to set the status of the stream and display accordingly.

    Its simple at the moment, and stops playing when the internet state changes. But the above is working for simple playback.

Answers

  • jasonLeeXamarinjasonLeeXamarin ✭✭ Member ✭✭
    Accepted Answer

    I found a nuget package: LibVLCSharp.Forms

    in the Main application created a class:

    using LibVLCSharp.Shared;

    public class RadioStream
    {
    readonly LibVLC _libVLC;
    readonly MediaPlayer _mp;

        public RadioStream()
        {
            if (DesignMode.IsDesignModeEnabled) return;
    
            Core.Initialize();
    
            _libVLC = new LibVLC();
    
            _mp = new MediaPlayer(_libVLC);
        }
    
        public void Init()
        {
            _mp.Media = new Media(_libVLC, "http://url/stream", FromType.FromLocation);
    
            _mp.Media.AddOption(":no-video");
    
        }
    
    
        public void Play(bool play)
        {
            if (play)
                _mp.Play();
            else _mp.Pause();
        }
    
        public bool isPlaying()
        {
            if (_mp.IsPlaying == false)
                return false;
            else
                return true;
        }
    
    }
    

    And its working!

    In a while loop I check the isPlaying() that allows me to set the status of the stream and display accordingly.

    Its simple at the moment, and stops playing when the internet state changes. But the above is working for simple playback.

Sign In or Register to comment.