简体   繁体   中英

How to dispose CrossMediaManager properly?

I'm playing an HLS content on CrossMediaManager. When users press back, I'm trying to dispose the player, but the player is still playing, I can see it's running on notification drawer and I can listen to video. Here is the code I've tried.

protected override void OnDisappearing()
{
    base.OnDisappearing();
    CrossMediaManager.Current.Dispose();
    VideoPlayer.Dispose();
}

VideoPlayer is the Reference name of the VideoView.

Please put following code in your navigated page. When you back to mainpage, this plugin will be closed.

protected override void OnDisappearing()
        {
            base.OnDisappearing();
            var player = CrossMediaManager.Current.MediaPlayer;
             player.Stop();
        }
    }

Here is running GIF.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM