react-native-theoplayer 8.7.0 → 8.8.0

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [8.8.0] - 24-11-19
9
+
10
+ ### Added
11
+
12
+ - Added `HomeIndicatorViewController` to iOS, which can be used as an alternative `rootViewController` for the native App. It will automatically show/hide the home indicator when transitioning from/to fullscreen presentationMode.
13
+
14
+ ### Changed
15
+
16
+ - Simplified the `viewController` reparenting mechanism on iOS that is applied when changing the presentationMode to/from fullscreen.
17
+ - The `MediaPlaybackService` on Android is never restarted if a MediaButton event is received after the app was closed.
18
+ - Added a consumer R8 config file on Android, telling R8 not to throw errors or warnings because of classes that are expected to be missing.
19
+
8
20
  ## [8.7.0] - 24-11-05
9
21
 
10
22
  ### Fixed
@@ -66,6 +66,8 @@ android {
66
66
  buildConfigField "boolean", "EXTENSION_ADS", "${enabledAds}"
67
67
  buildConfigField "boolean", "EXTENSION_CAST", "${enabledCast}"
68
68
  buildConfigField "boolean", "EXTENSION_MEDIASESSION", "${enabledMediaSession}"
69
+
70
+ consumerProguardFiles 'proguard-rules.pro'
69
71
  }
70
72
 
71
73
  buildTypes {
@@ -0,0 +1,3 @@
1
+ # Do no warn if any of the API classes we resolve with compileOnly are missing because the feature
2
+ # is disabled: it is expected.
3
+ -dontwarn com.theoplayer.android.api.**
@@ -239,7 +239,8 @@ class ReactTHEOplayerContext private constructor(
239
239
  // Create and initialize the media session
240
240
  val mediaSession = MediaSessionCompat(reactContext, TAG)
241
241
 
242
- // Do not let MediaButtons restart the player when the app is not visible
242
+ // Do not let MediaButtons restart the player when media session is not active.
243
+ // https://developer.android.com/media/legacy/media-buttons#restarting-inactive-mediasessions
243
244
  mediaSession.setMediaButtonReceiver(null)
244
245
 
245
246
  // Create a MediaSessionConnector and attach the THEOplayer instance.
@@ -152,6 +152,10 @@ class MediaPlaybackService : Service() {
152
152
 
153
153
  // Set mediaSession active
154
154
  setActive(BuildConfig.EXTENSION_MEDIASESSION)
155
+
156
+ // Do not let MediaButtons restart the player when media session is not active.
157
+ // https://developer.android.com/media/legacy/media-buttons#restarting-inactive-mediasessions
158
+ mediaSession.setMediaButtonReceiver(null)
155
159
  }
156
160
  }
157
161
 
@@ -9,6 +9,7 @@ public class THEOplayerRCTView: UIView {
9
9
  public private(set) var player: THEOplayer?
10
10
  public private(set) var mainEventHandler: THEOplayerRCTMainEventHandler
11
11
  public private(set) var broadcastEventHandler: THEOplayerRCTBroadcastEventHandler
12
+ let theoPlayerViewController = UIViewController()
12
13
  var textTrackEventHandler: THEOplayerRCTTextTrackEventHandler
13
14
  var mediaTrackEventHandler: THEOplayerRCTMediaTrackEventHandler
14
15
  var metadataTrackEventHandler: THEOplayerRCTSideloadedMetadataTrackEventHandler
@@ -76,6 +77,14 @@ public class THEOplayerRCTView: UIView {
76
77
  if let player = self.player {
77
78
  player.frame = self.frame
78
79
  player.autoresizingMask = [.flexibleBottomMargin, .flexibleHeight, .flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin, .flexibleWidth]
80
+
81
+ // wrap theoPlayerViewController around the view
82
+ if theoPlayerViewController.parent == nil,
83
+ let parentViewController = self.findViewController() {
84
+ parentViewController.addChild(self.theoPlayerViewController)
85
+ self.theoPlayerViewController.didMove(toParent: parentViewController)
86
+ self.theoPlayerViewController.view = self
87
+ }
79
88
  }
80
89
  }
81
90
 
@@ -14,7 +14,6 @@ public class THEOplayerRCTPresentationModeManager {
14
14
 
15
15
  private var containerView: UIView? // view containing the playerView and it's siblings (e.g. UI)
16
16
  private var inlineParentView: UIView? // target view for inline representation
17
- private var movingChildVCs: [UIViewController] = [] // list of playerView's child VCs that need to be reparented while moving the playerView
18
17
 
19
18
  // MARK: Events
20
19
  var onNativePresentationModeChange: RCTDirectEventBlock?
@@ -39,35 +38,21 @@ public class THEOplayerRCTPresentationModeManager {
39
38
 
40
39
  // MARK: - logic
41
40
 
42
- private func storeMovingVCs(for view: UIView) {
43
- if let viewController = view.findViewController() {
44
- viewController.children.forEach { childVC in
45
- self.movingChildVCs.append(childVC)
46
- }
47
- }
48
- }
49
-
50
- private func clearMovingVCs() {
51
- self.movingChildVCs = []
52
- }
53
-
54
- private func moveView(_ movingView: UIView, to targetView: UIView, with movingViewControllers: [UIViewController]) {
55
- // detach the moving viewControllers from their parent
56
- movingViewControllers.forEach { movedVC in
57
- movedVC.removeFromParent()
58
- }
41
+ private func moveView(_ movingView: UIView, to targetView: UIView) {
42
+ guard let theoPlayerViewController = (self.view as? THEOplayerRCTView)?.theoPlayerViewController else { return }
43
+
44
+ // detach the viewController from its parent
45
+ theoPlayerViewController.removeFromParent()
59
46
 
60
47
  // move the actual view
61
48
  movingView.removeFromSuperview()
62
49
  targetView.addSubview(movingView)
63
50
  targetView.bringSubviewToFront(movingView)
64
51
 
65
- // attach the moving viewControllers to their new parent
52
+ // attach the viewController to its new parent
66
53
  if let targetViewController = targetView.findViewController() {
67
- movingViewControllers.forEach { movedVC in
68
- targetViewController.addChild(movedVC)
69
- movedVC.didMove(toParent: targetViewController)
70
- }
54
+ targetViewController.addChild(theoPlayerViewController)
55
+ theoPlayerViewController.didMove(toParent: targetViewController)
71
56
  }
72
57
  }
73
58
 
@@ -75,19 +60,32 @@ public class THEOplayerRCTPresentationModeManager {
75
60
  self.containerView = self.view?.findParentViewOfType(RCTView.self)
76
61
  self.inlineParentView = self.containerView?.findParentViewOfType(RCTView.self)
77
62
 
63
+ // move the player
78
64
  if let containerView = self.containerView,
79
65
  let fullscreenParentView = self.view?.findParentViewOfType(RCTRootContentView.self) {
80
- self.storeMovingVCs(for: containerView)
81
- self.moveView(containerView, to: fullscreenParentView, with: self.movingChildVCs)
66
+ self.moveView(containerView, to: fullscreenParentView)
67
+
68
+ // start hiding home indicator
69
+ if let customRootViewController = fullscreenParentView.findViewController() as? HomeIndicatorViewController {
70
+ customRootViewController.prefersAutoHidden = true
71
+ customRootViewController.setNeedsUpdateOfHomeIndicatorAutoHidden()
72
+ }
82
73
  }
83
74
  self.rnInlineMode = .fullscreen
84
75
  }
85
76
 
86
77
  private func exitFullscreen() {
78
+ // stop hiding home indicator
79
+ if let fullscreenParentView = self.view?.findParentViewOfType(RCTRootContentView.self),
80
+ let customRootViewController = fullscreenParentView.findViewController() as? HomeIndicatorViewController {
81
+ customRootViewController.prefersAutoHidden = false
82
+ customRootViewController.setNeedsUpdateOfHomeIndicatorAutoHidden()
83
+ }
84
+
85
+ // move the player
87
86
  if let containerView = self.containerView,
88
87
  let inlineParentView = self.inlineParentView {
89
- self.moveView(containerView, to: inlineParentView, with: self.movingChildVCs)
90
- self.clearMovingVCs()
88
+ self.moveView(containerView, to: inlineParentView)
91
89
  }
92
90
  self.rnInlineMode = .inline
93
91
  }
@@ -0,0 +1,14 @@
1
+ // HomeIndicatorViewController.swift
2
+
3
+ import UIKit
4
+
5
+ @objc
6
+ public class HomeIndicatorViewController: UIViewController {
7
+ public var prefersAutoHidden = false
8
+
9
+ public override var prefersHomeIndicatorAutoHidden: Bool {
10
+ get {
11
+ return self.prefersAutoHidden
12
+ }
13
+ }
14
+ }
@@ -1 +1 @@
1
- {"version":"8.7.0","buildDate":"2024-11-05T13:50:34.649Z"}
1
+ {"version":"8.8.0","buildDate":"2024-11-19T15:05:29.967Z"}
@@ -1 +1 @@
1
- {"version":"8.7.0","buildDate":"2024-11-05T13:50:34.649Z"}
1
+ {"version":"8.8.0","buildDate":"2024-11-19T15:05:29.967Z"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-theoplayer",
3
- "version": "8.7.0",
3
+ "version": "8.8.0",
4
4
  "description": "A THEOplayer video component for react-native.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -25,7 +25,7 @@ Pod::Spec.new do |s|
25
25
  s.platforms = { :ios => "13.4", :tvos => "13.4" }
26
26
  s.source = { :git => "https://www.theoplayer.com/.git", :tag => "#{s.version}" }
27
27
 
28
- s.source_files = 'ios/*.{h,m,swift}', 'ios/ads/*.swift', 'ios/casting/*.swift', 'ios/contentprotection/*.swift', 'ios/pip/*.swift', 'ios/backgroundAudio/*.swift', 'ios/cache/*.swift', 'ios/sideloadedMetadata/*.swift', 'ios/eventBroadcasting/*.swift' , 'ios/ui/*.swift', 'ios/presentationMode/*.swift'
28
+ s.source_files = 'ios/*.{h,m,swift}', 'ios/ads/*.swift', 'ios/casting/*.swift', 'ios/contentprotection/*.swift', 'ios/pip/*.swift', 'ios/backgroundAudio/*.swift', 'ios/cache/*.swift', 'ios/sideloadedMetadata/*.swift', 'ios/eventBroadcasting/*.swift' , 'ios/ui/*.swift', 'ios/presentationMode/*.swift', 'ios/viewController/*.swift'
29
29
  s.resources = ['ios/*.css']
30
30
 
31
31
  # ReactNative Dependency
package/src/manifest.json CHANGED
@@ -1 +1 @@
1
- {"version":"8.7.0","buildDate":"2024-11-05T13:50:34.649Z"}
1
+ {"version":"8.8.0","buildDate":"2024-11-19T15:05:29.967Z"}