Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

MediaPlayer Issue _mediaPlayer.Prepared += (sender, args) => {

$
0
0

I have an Issue in Android version(8.0 and above),in all other versions it's working fine,i have posted my code please check and help me in this case thank you

public void Play(string pathToAudioFile)
{
if (_mediaPlayer != null)
{
_mediaPlayer.Completion -= MediaPlayer_Completion;
_mediaPlayer.Stop();
}

        if (pathToAudioFile != null)
        {
            if (_mediaPlayer == null)
            {
                _mediaPlayer = new MediaPlayer();

                _mediaPlayer.Prepared += (sender, args) =>
                {
                    _mediaPlayer.Start();
                    _mediaPlayer.Completion += MediaPlayer_Completion;
                };**//it's not firing in oreo **
            }

            _mediaPlayer.Reset();
            //_mediaPlayer.SetVolume (1.0f, 1.0f);

            _mediaPlayer.SetDataSource(pathToAudioFile);
            _mediaPlayer.Start();
            _mediaPlayer.PrepareAsync();
        }
    }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>