From 21e9a511cbff9ed3a0d29107940751f788a8558a Mon Sep 17 00:00:00 2001 From: Michal Orzechowski Date: Mon, 22 Jul 2019 22:35:08 +0200 Subject: [PATCH] Detach player for play audio in background and fix 2nd play on iOS --- .../Platforms/Ios/Video/PlayerViewController.cs | 14 ++++++++++++++ MediaManager/Platforms/Ios/Video/VideoView.cs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 MediaManager/Platforms/Ios/Video/PlayerViewController.cs diff --git a/MediaManager/Platforms/Ios/Video/PlayerViewController.cs b/MediaManager/Platforms/Ios/Video/PlayerViewController.cs new file mode 100644 index 00000000..c372552b --- /dev/null +++ b/MediaManager/Platforms/Ios/Video/PlayerViewController.cs @@ -0,0 +1,14 @@ +using AVKit; + +namespace MediaManager.Platforms.Ios.Video +{ + public class PlayerViewController : AVPlayerViewController + { + public override void ViewWillDisappear(bool animated) + { + base.ViewWillDisappear(animated); + + Player = null; + } + } +} diff --git a/MediaManager/Platforms/Ios/Video/VideoView.cs b/MediaManager/Platforms/Ios/Video/VideoView.cs index 76207d8f..586883ef 100644 --- a/MediaManager/Platforms/Ios/Video/VideoView.cs +++ b/MediaManager/Platforms/Ios/Video/VideoView.cs @@ -21,7 +21,7 @@ public AVPlayerViewController PlayerViewController { if(_playerViewController == null) { - PlayerViewController = new AVPlayerViewController(); + PlayerViewController = new PlayerViewController(); } return _playerViewController; }