@bluebillywig/react-native-bb-player 8.42.14 → 8.44.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.
@@ -1,6 +1,42 @@
1
1
  import Foundation
2
2
  import React
3
3
 
4
+ /**
5
+ * Global registry for BBPlayerView instances.
6
+ * This is needed because the bridge.uiManager.view(forReactTag:) doesn't work
7
+ * with the New Architecture (Fabric). Views register themselves when created.
8
+ */
9
+ class BBPlayerViewRegistry: NSObject {
10
+ static let shared = BBPlayerViewRegistry()
11
+
12
+ private var views: [Int: BBPlayerView] = [:]
13
+ private let lock = NSLock()
14
+
15
+ private override init() {
16
+ super.init()
17
+ }
18
+
19
+ func register(_ view: BBPlayerView, tag: Int) {
20
+ lock.lock()
21
+ defer { lock.unlock() }
22
+ views[tag] = view
23
+ NSLog("BBPlayerViewRegistry: Registered view with tag %d (total: %d)", tag, views.count)
24
+ }
25
+
26
+ func unregister(tag: Int) {
27
+ lock.lock()
28
+ defer { lock.unlock() }
29
+ views.removeValue(forKey: tag)
30
+ NSLog("BBPlayerViewRegistry: Unregistered view with tag %d (total: %d)", tag, views.count)
31
+ }
32
+
33
+ func getView(tag: Int) -> BBPlayerView? {
34
+ lock.lock()
35
+ defer { lock.unlock() }
36
+ return views[tag]
37
+ }
38
+ }
39
+
4
40
  /**
5
41
  * Native Module for BBPlayer commands.
6
42
  * This module looks up BBPlayerView instances by their React tag and dispatches commands to them.
@@ -21,11 +57,20 @@ class BBPlayerModule: NSObject {
21
57
  // MARK: - Helper to get view by tag
22
58
 
23
59
  private func getView(_ reactTag: NSNumber) -> BBPlayerView? {
24
- guard let bridge = self.bridge else {
25
- NSLog("BBPlayerModule: Bridge is nil")
26
- return nil
60
+ // First try the view registry (works with both old and new architecture)
61
+ if let view = BBPlayerViewRegistry.shared.getView(tag: reactTag.intValue) {
62
+ return view
27
63
  }
28
- return bridge.uiManager.view(forReactTag: reactTag) as? BBPlayerView
64
+
65
+ // Fallback to bridge.uiManager for old architecture
66
+ if let bridge = self.bridge {
67
+ if let view = bridge.uiManager.view(forReactTag: reactTag) as? BBPlayerView {
68
+ return view
69
+ }
70
+ }
71
+
72
+ NSLog("BBPlayerModule: Could not find view with tag %@", reactTag)
73
+ return nil
29
74
  }
30
75
 
31
76
  // MARK: - Commands
@@ -151,10 +196,15 @@ class BBPlayerModule: NSObject {
151
196
  }
152
197
 
153
198
  @objc func loadWithJsonUrl(_ viewTag: NSNumber, jsonUrl: String?, autoPlay: Bool) {
199
+ NSLog("BBPlayerModule.loadWithJsonUrl called - viewTag: %@, jsonUrl: %@, autoPlay: %d", viewTag, jsonUrl ?? "nil", autoPlay)
154
200
  DispatchQueue.main.async {
155
- // Load new JSON URL - update the jsonUrl property and re-setup
156
- if let view = self.getView(viewTag), let url = jsonUrl {
157
- view.jsonUrl = url
201
+ let view = self.getView(viewTag)
202
+ NSLog("BBPlayerModule.loadWithJsonUrl - view found: %@", view != nil ? "YES" : "NO")
203
+ if let view = view, let url = jsonUrl {
204
+ NSLog("BBPlayerModule.loadWithJsonUrl - calling view.loadWithJsonUrl with url: %@", url)
205
+ view.loadWithJsonUrl(url, autoPlay: autoPlay)
206
+ } else {
207
+ NSLog("BBPlayerModule.loadWithJsonUrl - FAILED: view=%@, url=%@", view != nil ? "found" : "nil", jsonUrl ?? "nil")
158
208
  }
159
209
  }
160
210
  }
@@ -212,7 +262,7 @@ class BBPlayerModule: NSObject {
212
262
 
213
263
  @objc func getClipData(_ viewTag: NSNumber, resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) {
214
264
  DispatchQueue.main.async {
215
- let clipData = self.getView(viewTag)?.adMediaClip()
265
+ let clipData = self.getView(viewTag)?.clipData()
216
266
  resolver(clipData)
217
267
  }
218
268
  }