@capgo/capacitor-video-player 8.1.17 → 8.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ import java.util.Map;
38
38
  )
39
39
  public class VideoPlayerPlugin extends Plugin {
40
40
 
41
- private final String pluginVersion = "8.1.17";
41
+ private final String pluginVersion = "8.1.18";
42
42
 
43
43
  // Permission alias constants
44
44
  private static final String PERMISSION_DENIED_ERROR = "Unable to access media videos, user denied permission request";
@@ -28,6 +28,7 @@ class FullscreenVideoPlayer: NSObject {
28
28
  private var fairplayContentKeySpcUrl: String?
29
29
  private var contentKeySession: AVContentKeySession?
30
30
  private var castController: VideoPlayerCastController?
31
+ private weak var presentingViewController: UIViewController?
31
32
  private var subtitleUrl: String?
32
33
  private var subtitleLanguage: String?
33
34
 
@@ -202,6 +203,9 @@ class FullscreenVideoPlayer: NSObject {
202
203
  playerViewController?.player = player
203
204
  playerViewController?.showsPlaybackControls = showControls
204
205
  playerViewController?.allowsPictureInPicturePlayback = pipEnabled
206
+ if pipEnabled {
207
+ playerViewController?.delegate = self
208
+ }
205
209
 
206
210
  setupChromecast()
207
211
  setupObservers()
@@ -300,6 +304,7 @@ class FullscreenVideoPlayer: NSObject {
300
304
  return
301
305
  }
302
306
 
307
+ presentingViewController = viewController
303
308
  viewController.present(playerVC, animated: true) {
304
309
  self.play()
305
310
  completion()
@@ -458,6 +463,36 @@ class FullscreenVideoPlayer: NSObject {
458
463
  }
459
464
  }
460
465
 
466
+ // MARK: - AVPlayerViewControllerDelegate (Picture in Picture)
467
+
468
+ extension FullscreenVideoPlayer: AVPlayerViewControllerDelegate {
469
+ func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(
470
+ _ playerViewController: AVPlayerViewController
471
+ ) -> Bool {
472
+ false
473
+ }
474
+
475
+ func playerViewController(
476
+ _ playerViewController: AVPlayerViewController,
477
+ restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void
478
+ ) {
479
+ guard let presentingViewController else {
480
+ completionHandler(false)
481
+ return
482
+ }
483
+
484
+ if playerViewController.presentingViewController == nil {
485
+ DispatchQueue.main.async {
486
+ presentingViewController.present(playerViewController, animated: false) {
487
+ completionHandler(true)
488
+ }
489
+ }
490
+ } else {
491
+ completionHandler(true)
492
+ }
493
+ }
494
+ }
495
+
461
496
  // MARK: - AVContentKeySessionDelegate (FairPlay DRM)
462
497
 
463
498
  extension FullscreenVideoPlayer: AVContentKeySessionDelegate {
@@ -8,7 +8,7 @@ import AVKit
8
8
  */
9
9
  @objc(VideoPlayerPlugin)
10
10
  public class VideoPlayerPlugin: CAPPlugin, CAPBridgedPlugin {
11
- private let pluginVersion: String = "8.1.17"
11
+ private let pluginVersion: String = "8.1.18"
12
12
  public let identifier = "VideoPlayerPlugin"
13
13
  public let jsName = "VideoPlayer"
14
14
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-video-player",
3
- "version": "8.1.17",
3
+ "version": "8.1.18",
4
4
  "description": "Capacitor plugin to play video in native player",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",