mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-06-06 03:56:53 +00:00
fix(ios): store view as week reference in HybridVideoViewViewManager
This commit is contained in:
@@ -9,23 +9,31 @@ import Foundation
|
|||||||
import NitroModules
|
import NitroModules
|
||||||
|
|
||||||
class HybridVideoViewViewManager: HybridVideoViewViewManagerSpec {
|
class HybridVideoViewViewManager: HybridVideoViewViewManagerSpec {
|
||||||
|
weak var view: VideoComponentView?
|
||||||
|
|
||||||
var player: (any HybridVideoPlayerSpec)? {
|
var player: (any HybridVideoPlayerSpec)? {
|
||||||
get {
|
get {
|
||||||
view.player
|
guard let view = view else {
|
||||||
|
print("RN Video: VideoComponentView is no longer available. It is likely that the view was deallocated.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return view.player
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
guard let view = view else {
|
||||||
|
print("RN Video: VideoComponentView is no longer available. It is likely that the view was deallocated.")
|
||||||
|
return
|
||||||
|
}
|
||||||
view.player = newValue
|
view.player = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let view: VideoComponentView
|
|
||||||
|
|
||||||
init(nitroId: Double) throws {
|
init(nitroId: Double) throws {
|
||||||
guard let view = VideoComponentView.globalViewsMap.object(forKey: NSNumber(value: nitroId)) else {
|
guard let view = VideoComponentView.globalViewsMap.object(forKey: NSNumber(value: nitroId)) else {
|
||||||
throw RuntimeError.error(withMessage: "No view found for \(nitroId)")
|
throw RuntimeError.error(withMessage: "No view found for \(nitroId)")
|
||||||
}
|
}
|
||||||
|
|
||||||
self.view = view
|
self.view = view
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize HybridContext
|
// Initialize HybridContext
|
||||||
|
|||||||
Reference in New Issue
Block a user