Skip to content

Commit

Permalink
feat(casting): fix tvOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandkakonyi committed Sep 22, 2023
1 parent 65cee12 commit 07943df
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,16 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-BitmovinPlayerReactNativeExample/Pods-BitmovinPlayerReactNativeExample-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core-iOS/AccessibilityResources.bundle",
"${PODS_ROOT}/google-cast-sdk/GoogleCastSDK-ios-4.8.0_static/GoogleCast.framework/GoogleCastCoreResources.bundle",
"${PODS_ROOT}/google-cast-sdk/GoogleCastSDK-ios-4.8.0_static/GoogleCast.framework/GoogleCastUIResources.bundle",
"${PODS_ROOT}/google-cast-sdk/GoogleCastSDK-ios-4.8.0_static/GoogleCast.framework/MaterialDialogs.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleCastCoreResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleCastUIResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialDialogs.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
8 changes: 8 additions & 0 deletions ios/BitmovinCastManagerModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BitmovinCastManagerModule: NSObject, RCTBridgeModule {
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock
) {
#if os(iOS)
bridge.uiManager.addUIBlock { _, _ in
if let config = config {
guard let options = RCTConvert.castManagerOptions(config) else {
Expand All @@ -42,6 +43,7 @@ class BitmovinCastManagerModule: NSObject, RCTBridgeModule {
resolve(nil)
}
}
#endif
}

/**
Expand All @@ -55,7 +57,11 @@ class BitmovinCastManagerModule: NSObject, RCTBridgeModule {
rejecter reject: @escaping RCTPromiseRejectBlock
) {
bridge.uiManager.addUIBlock { _, _ in
#if os(iOS)
resolve(BitmovinCastManager.isInitialized())
#else
resolve(false)
#endif
}
}

Expand All @@ -68,8 +74,10 @@ class BitmovinCastManagerModule: NSObject, RCTBridgeModule {
_ message: String,
messageNamespace: String?
) {
#if os(iOS)
bridge.uiManager.addUIBlock { _, _ in
BitmovinCastManager.sharedInstance().sendMessage(message, withNamespace: messageNamespace)
}
#endif
}
}
2 changes: 2 additions & 0 deletions ios/Event+JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ extension CastStartedEvent {
}
}

#if os(iOS)
extension CastWaitingForDeviceEvent {
func toJSON() -> [AnyHashable: Any] {
[
Expand All @@ -360,3 +361,4 @@ extension CastWaitingForDeviceEvent {
]
}
}
#endif
6 changes: 4 additions & 2 deletions ios/PlayerModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ class PlayerModule: NSObject, RCTBridgeModule {
else {
return
}

#if os(iOS)
self?.setupRemoteControlConfig(playerConfig.remoteControlConfig)
#endif
self?.players[nativeId] = PlayerFactory.create(playerConfig: playerConfig)
}
}
Expand All @@ -67,8 +68,9 @@ class PlayerModule: NSObject, RCTBridgeModule {
else {
return
}

#if os(iOS)
self?.setupRemoteControlConfig(playerConfig.remoteControlConfig)
#endif
let defaultMetadata = RCTConvert.analyticsDefaultMetadataFromAnalyticsConfig(analyticsConfigJson)
self?.players[nativeId] = PlayerFactory.create(
playerConfig: playerConfig,
Expand Down
4 changes: 4 additions & 0 deletions ios/RCTConvert+BitmovinPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ extension RCTConvert {
if let adaptationConfig = RCTConvert.adaptationConfig(json["adaptationConfig"]) {
playerConfig.adaptationConfig = adaptationConfig
}
#if os(iOS)
if let remoteControlConfig = RCTConvert.remoteControlConfig(json["remoteControlConfig"]) {
playerConfig.remoteControlConfig = remoteControlConfig
}
#endif
return playerConfig
}

Expand Down Expand Up @@ -983,6 +985,7 @@ extension RCTConvert {
return remoteControlConfig
}

#if os(iOS)
/**
Utility method to instantiate a `BitmovinCastManagerOptions` from a JS object.
- Parameter json: JS object
Expand Down Expand Up @@ -1029,4 +1032,5 @@ extension RCTConvert {
)
)
}
#endif
}
3 changes: 2 additions & 1 deletion ios/RNPlayerView+PlayerListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ extension RNPlayerView: PlayerListener {
onVideoPlaybackQualityChanged?(event.toJSON())
}

#if os(iOS)
func onCastAvailable(_ event: CastAvailableEvent, player: Player) {
onCastAvailable?(event.toJSON())
}
Expand Down Expand Up @@ -200,8 +201,8 @@ extension RNPlayerView: PlayerListener {
func onCastTimeUpdated(_ event: CastTimeUpdatedEvent, player: Player) {
onCastTimeUpdated?(event.toJSON())
}

func onCastWaitingForDevice(_ event: CastWaitingForDeviceEvent, player: Player) {
onCastWaitingForDevice?(event.toJSON())
}
#endif
}
4 changes: 4 additions & 0 deletions ios/SourceModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ class SourceModule: NSObject, RCTBridgeModule {
return
}
self?.sources[nativeId] = SourceFactory.create(from: sourceConfig, sourceMetadata: sourceMetadata)
#if os(iOS)
if let remoteConfig = RCTConvert.sourceRemoteControlConfig(sourceRemoteControlConfig){
self?.castSourceConfigs[nativeId] = remoteConfig.castSourceConfig
}
#endif
}
}

Expand Down Expand Up @@ -114,9 +116,11 @@ class SourceModule: NSObject, RCTBridgeModule {
return
}
self?.sources[nativeId] = SourceFactory.create(from: sourceConfig)
#if os(iOS)
if let remoteConfig = RCTConvert.sourceRemoteControlConfig(sourceRemoteControlConfig) {
self?.castSourceConfigs[nativeId] = remoteConfig.castSourceConfig
}
#endif
}
}

Expand Down

0 comments on commit 07943df

Please sign in to comment.