From 742ddb318345688bfdcd6616616f63143c38abb4 Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Thu, 8 May 2025 17:13:39 +0200 Subject: [PATCH] feat: events callbacks & external subtitles (#9) --- bun.lock | 2 +- example/ios/Podfile.lock | 4 +- .../VideoExample.xcodeproj/project.pbxproj | 18 +- example/src/App.tsx | 85 +++- .../activities/FullscreenVideoViewActivity.kt | 1 + .../core/player/DataSourceFactoryUtils.kt | 10 +- .../com/video/core/player/MediaItemUtils.kt | 62 +++ .../com/video/core/player/MediaSourceUtils.kt | 43 +- .../player/OnAudioFocusChangedListener.kt | 27 ++ .../recivers/AudioBecomingNoisyReceiver.kt | 38 ++ .../video/core/utils/VideoInformationUtils.kt | 3 +- .../video/core/utils/VideoOrientationUtils.kt | 2 + .../hybrids/videoplayer/HybridVideoPlayer.kt | 265 ++++++++++- .../HybridVideoPlayerEventEmitter.kt | 39 ++ .../HybridVideoPlayerSource.kt | 11 +- .../HybridVideoPlayerSourceFactory.kt | 7 +- .../HybridVideoViewViewManager.kt | 43 +- .../src/main/java/com/video/view/VideoView.kt | 23 +- .../Extensions/AVAssetTrack+orientation.swift | 5 + .../AVPlayerItem+externalSubtitles.swift | 55 +++ .../AVPlayerItem+getBufferedDurration.swift | 34 ++ .../ios/core/VideoPlayerObserver.swift | 182 ++++++- .../HybridVideoPlayer+Events.swift | 148 ++++++ .../VideoPlayer/HybridVideoPlayer.swift | 146 ++++-- .../HybridVideoPlayerEventEmitter.swift | 47 ++ .../HybridVideoPlayerSource.swift | 63 ++- .../HybridVideoPlayerSourceFactory.swift | 7 +- .../HybridVideoViewViewManager.swift | 22 +- .../ios/view/VideoComponentView.swift | 18 +- .../ios/view/VideoComponentViewObserver.swift | 142 ++++++ .../ReactNativeVideo+autolinking.cmake | 2 + .../android/ReactNativeVideoOnLoad.cpp | 24 + .../generated/android/c++/JBandwidthData.hpp | 61 +++ .../android/c++/JExternalSubtitle.hpp | 57 +++ .../generated/android/c++/JFunc_void.hpp | 74 +++ .../android/c++/JFunc_void_BandwidthData.hpp | 77 +++ .../android/c++/JFunc_void_TimedMetadata.hpp | 80 ++++ .../c++/JFunc_void_VideoPlayerStatus.hpp | 76 +++ .../generated/android/c++/JFunc_void_bool.hpp | 74 +++ .../android/c++/JFunc_void_double.hpp | 74 +++ .../android/c++/JFunc_void_onLoadData.hpp | 78 +++ .../c++/JFunc_void_onLoadStartData.hpp | 82 ++++ .../JFunc_void_onPlaybackStateChangeData.hpp | 76 +++ .../android/c++/JFunc_void_onProgressData.hpp | 76 +++ .../JFunc_void_std__vector_std__string_.hpp | 93 ++++ .../JHybridVideoPlayerEventEmitterSpec.cpp | 419 ++++++++++++++++ .../JHybridVideoPlayerEventEmitterSpec.hpp | 97 ++++ .../JHybridVideoPlayerSourceFactorySpec.cpp | 16 + .../JHybridVideoPlayerSourceFactorySpec.hpp | 1 + .../c++/JHybridVideoPlayerSourceSpec.cpp | 16 + .../c++/JHybridVideoPlayerSourceSpec.hpp | 1 + .../android/c++/JHybridVideoPlayerSpec.cpp | 18 + .../android/c++/JHybridVideoPlayerSpec.hpp | 2 + .../c++/JHybridVideoViewViewManagerSpec.cpp | 111 +++++ .../c++/JHybridVideoViewViewManagerSpec.hpp | 12 + .../android/c++/JNativeVideoConfig.hpp | 96 ++++ .../generated/android/c++/JSourceType.hpp | 59 +++ .../generated/android/c++/JTimedMetadata.hpp | 73 +++ .../android/c++/JTimedMetadataObject.hpp | 57 +++ .../android/c++/JVideoOrientation.hpp | 3 + .../android/c++/JVideoPlayerStatus.hpp | 65 +++ .../generated/android/c++/JonLoadData.hpp | 70 +++ .../android/c++/JonLoadStartData.hpp | 62 +++ .../c++/JonPlaybackStateChangeData.hpp | 57 +++ .../generated/android/c++/JonProgressData.hpp | 57 +++ .../com/margelo/nitro/video/BandwidthData.kt | 28 ++ .../margelo/nitro/video/ExternalSubtitle.kt | 27 ++ .../com/margelo/nitro/video/Func_void.kt | 80 ++++ .../nitro/video/Func_void_BandwidthData.kt | 80 ++++ .../nitro/video/Func_void_TimedMetadata.kt | 80 ++++ .../video/Func_void_VideoPlayerStatus.kt | 80 ++++ .../com/margelo/nitro/video/Func_void_bool.kt | 80 ++++ .../margelo/nitro/video/Func_void_double.kt | 80 ++++ .../nitro/video/Func_void_onLoadData.kt | 80 ++++ .../nitro/video/Func_void_onLoadStartData.kt | 80 ++++ .../Func_void_onPlaybackStateChangeData.kt | 80 ++++ .../nitro/video/Func_void_onProgressData.kt | 80 ++++ .../Func_void_std__vector_std__string_.kt | 80 ++++ .../HybridVideoPlayerEventEmitterSpec.kt | 300 ++++++++++++ .../HybridVideoPlayerSourceFactorySpec.kt | 4 + .../video/HybridVideoPlayerSourceSpec.kt | 4 + .../nitro/video/HybridVideoPlayerSpec.kt | 8 + .../video/HybridVideoViewViewManagerSpec.kt | 84 ++++ .../margelo/nitro/video/NativeVideoConfig.kt | 28 ++ .../com/margelo/nitro/video/SourceType.kt | 25 + .../com/margelo/nitro/video/TimedMetadata.kt | 26 + .../nitro/video/TimedMetadataObject.kt | 27 ++ .../margelo/nitro/video/VideoOrientation.kt | 1 + .../margelo/nitro/video/VideoPlayerStatus.kt | 27 ++ .../com/margelo/nitro/video/onLoadData.kt | 30 ++ .../margelo/nitro/video/onLoadStartData.kt | 27 ++ .../nitro/video/onPlaybackStateChangeData.kt | 27 ++ .../com/margelo/nitro/video/onProgressData.kt | 27 ++ .../ios/ReactNativeVideo-Swift-Cxx-Bridge.cpp | 97 ++++ .../ios/ReactNativeVideo-Swift-Cxx-Bridge.hpp | 379 +++++++++++++++ .../ReactNativeVideo-Swift-Cxx-Umbrella.hpp | 41 ++ ...HybridVideoPlayerEventEmitterSpecSwift.cpp | 11 + ...HybridVideoPlayerEventEmitterSpecSwift.hpp | 225 +++++++++ ...ybridVideoPlayerSourceFactorySpecSwift.hpp | 17 + .../c++/HybridVideoPlayerSourceSpecSwift.hpp | 13 + .../ios/c++/HybridVideoPlayerSpecSwift.hpp | 14 + .../HybridVideoViewViewManagerSpecSwift.hpp | 43 ++ .../generated/ios/swift/BandwidthData.swift | 81 ++++ .../ios/swift/ExternalSubtitle.swift | 46 ++ .../ios/swift/Func_void_BandwidthData.swift | 46 ++ .../ios/swift/Func_void_TimedMetadata.swift | 46 ++ .../swift/Func_void_VideoPlayerStatus.swift | 46 ++ .../generated/ios/swift/Func_void_bool.swift | 46 ++ .../ios/swift/Func_void_double.swift | 46 ++ .../ios/swift/Func_void_onLoadData.swift | 46 ++ .../ios/swift/Func_void_onLoadStartData.swift | 46 ++ .../Func_void_onPlaybackStateChangeData.swift | 46 ++ .../ios/swift/Func_void_onProgressData.swift | 46 ++ .../Func_void_std__vector_std__string_.swift | 46 ++ .../HybridVideoPlayerEventEmitterSpec.swift | 65 +++ ...ybridVideoPlayerEventEmitterSpec_cxx.swift | 450 ++++++++++++++++++ .../HybridVideoPlayerSourceFactorySpec.swift | 1 + ...bridVideoPlayerSourceFactorySpec_cxx.swift | 15 + .../swift/HybridVideoPlayerSourceSpec.swift | 1 + .../HybridVideoPlayerSourceSpec_cxx.swift | 7 + .../ios/swift/HybridVideoPlayerSpec.swift | 2 + .../ios/swift/HybridVideoPlayerSpec_cxx.swift | 17 + .../HybridVideoViewViewManagerSpec.swift | 6 + .../HybridVideoViewViewManagerSpec_cxx.swift | 186 ++++++++ .../ios/swift/NativeVideoConfig.swift | 125 +++++ .../generated/ios/swift/SourceType.swift | 40 ++ .../generated/ios/swift/TimedMetadata.swift | 47 ++ .../ios/swift/TimedMetadataObject.swift | 46 ++ .../ios/swift/VideoOrientation.swift | 4 + .../ios/swift/VideoPlayerStatus.swift | 48 ++ .../generated/ios/swift/onLoadData.swift | 79 +++ .../generated/ios/swift/onLoadStartData.swift | 56 +++ .../ios/swift/onPlaybackStateChangeData.swift | 46 ++ .../generated/ios/swift/onProgressData.swift | 46 ++ .../generated/shared/c++/BandwidthData.hpp | 77 +++ .../generated/shared/c++/ExternalSubtitle.hpp | 73 +++ .../c++/HybridVideoPlayerEventEmitterSpec.cpp | 56 +++ .../c++/HybridVideoPlayerEventEmitterSpec.hpp | 119 +++++ .../HybridVideoPlayerSourceFactorySpec.cpp | 1 + .../HybridVideoPlayerSourceFactorySpec.hpp | 4 + .../c++/HybridVideoPlayerSourceSpec.cpp | 1 + .../c++/HybridVideoPlayerSourceSpec.hpp | 4 + .../shared/c++/HybridVideoPlayerSpec.cpp | 2 + .../shared/c++/HybridVideoPlayerSpec.hpp | 8 + .../c++/HybridVideoViewViewManagerSpec.cpp | 12 + .../c++/HybridVideoViewViewManagerSpec.hpp | 13 + .../shared/c++/NativeVideoConfig.hpp | 82 ++++ .../generated/shared/c++/SourceType.hpp | 78 +++ .../generated/shared/c++/TimedMetadata.hpp | 71 +++ .../shared/c++/TimedMetadataObject.hpp | 73 +++ .../generated/shared/c++/VideoOrientation.hpp | 6 +- .../shared/c++/VideoPlayerStatus.hpp | 86 ++++ .../generated/shared/c++/onLoadData.hpp | 86 ++++ .../generated/shared/c++/onLoadStartData.hpp | 78 +++ .../shared/c++/onPlaybackStateChangeData.hpp | 73 +++ .../generated/shared/c++/onProgressData.hpp | 73 +++ packages/react-native-video/package.json | 2 +- packages/react-native-video/src/VideoView.tsx | 47 +- .../src/core/VideoPlayer.ts | 16 +- .../src/core/VideoPlayerEvents.ts | 211 ++++++++ .../src/core/types/Events.ts | 205 ++++++++ .../src/core/types/VideoConfig.ts | 34 ++ .../src/core/types/VideoInformation.ts | 8 +- .../src/core/types/VideoOrientation.ts | 8 + .../src/core/types/VideoPlayerBase.ts | 10 + .../src/core/types/VideoPlayerSourceBase.ts | 6 + .../src/core/types/VideoPlayerStatus.ts | 8 + .../src/core/utils/sourceFactory.ts | 23 +- packages/react-native-video/src/index.tsx | 2 + .../src/spec/nitro/VideoPlayer.nitro.ts | 5 + .../nitro/VideoPlayerEventEmitter.nitro.ts | 13 + .../src/spec/nitro/VideoPlayerSource.nitro.ts | 2 + .../spec/nitro/VideoViewViewManager.nitro.ts | 4 +- packages/react-native-video/tsconfig.json | 1 + 174 files changed, 9673 insertions(+), 150 deletions(-) create mode 100644 packages/react-native-video/android/src/main/java/com/video/core/player/MediaItemUtils.kt create mode 100644 packages/react-native-video/android/src/main/java/com/video/core/player/OnAudioFocusChangedListener.kt create mode 100644 packages/react-native-video/android/src/main/java/com/video/core/recivers/AudioBecomingNoisyReceiver.kt create mode 100644 packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayereventemitter/HybridVideoPlayerEventEmitter.kt create mode 100644 packages/react-native-video/ios/core/Extensions/AVPlayerItem+externalSubtitles.swift create mode 100644 packages/react-native-video/ios/core/Extensions/AVPlayerItem+getBufferedDurration.swift create mode 100644 packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer+Events.swift create mode 100644 packages/react-native-video/ios/hybrids/VideoPlayerEmitter/HybridVideoPlayerEventEmitter.swift create mode 100644 packages/react-native-video/ios/view/VideoComponentViewObserver.swift create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JBandwidthData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JExternalSubtitle.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_BandwidthData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_TimedMetadata.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_VideoPlayerStatus.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_bool.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_double.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadStartData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onPlaybackStateChangeData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onProgressData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.cpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JNativeVideoConfig.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JSourceType.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadata.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadataObject.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JVideoPlayerStatus.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JonLoadData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JonLoadStartData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JonPlaybackStateChangeData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/c++/JonProgressData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/BandwidthData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/ExternalSubtitle.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_BandwidthData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_TimedMetadata.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_VideoPlayerStatus.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_bool.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_double.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadStartData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onPlaybackStateChangeData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onProgressData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_std__vector_std__string_.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerEventEmitterSpec.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/NativeVideoConfig.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/SourceType.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadata.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadataObject.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoPlayerStatus.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadStartData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onPlaybackStateChangeData.kt create mode 100644 packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onProgressData.kt create mode 100644 packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.cpp create mode 100644 packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.hpp create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/BandwidthData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/ExternalSubtitle.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_BandwidthData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_TimedMetadata.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_VideoPlayerStatus.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_bool.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_double.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadStartData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onPlaybackStateChangeData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onProgressData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec_cxx.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/NativeVideoConfig.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/SourceType.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadata.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadataObject.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/VideoPlayerStatus.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/onLoadData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/onLoadStartData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/onPlaybackStateChangeData.swift create mode 100644 packages/react-native-video/nitrogen/generated/ios/swift/onProgressData.swift create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/BandwidthData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/ExternalSubtitle.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.cpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/NativeVideoConfig.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/SourceType.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadata.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadataObject.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/VideoPlayerStatus.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/onLoadData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/onLoadStartData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/onPlaybackStateChangeData.hpp create mode 100644 packages/react-native-video/nitrogen/generated/shared/c++/onProgressData.hpp create mode 100644 packages/react-native-video/src/core/VideoPlayerEvents.ts create mode 100644 packages/react-native-video/src/core/types/Events.ts create mode 100644 packages/react-native-video/src/core/types/VideoOrientation.ts create mode 100644 packages/react-native-video/src/core/types/VideoPlayerStatus.ts create mode 100644 packages/react-native-video/src/spec/nitro/VideoPlayerEventEmitter.nitro.ts diff --git a/bun.lock b/bun.lock index d3b92632..01fa2ebd 100644 --- a/bun.lock +++ b/bun.lock @@ -56,7 +56,7 @@ }, "packages/react-native-video": { "name": "react-native-video", - "version": "7.0.0-dev.0", + "version": "7.0.0-dev.2", "devDependencies": { "@react-native/eslint-config": "^0.77.0", "@types/react": "^18.2.44", diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 9a275054..10c2eefb 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1565,7 +1565,7 @@ PODS: - React-logger (= 0.77.2) - React-perflogger (= 0.77.2) - React-utils (= 0.77.2) - - ReactNativeVideo (7.0.0-dev.0): + - ReactNativeVideo (7.0.0-dev.2): - DoubleConversion - glog - hermes-engine @@ -1876,7 +1876,7 @@ SPEC CHECKSUMS: ReactAppDependencyProvider: f334cebc0beed0a72490492e978007082c03d533 ReactCodegen: 474fbb3e4bb0f1ee6c255d1955db76e13d509269 ReactCommon: 7763e59534d58e15f8f22121cdfe319040e08888 - ReactNativeVideo: c92ba584a9c0b63a1ea48b990775d3773e58766e + ReactNativeVideo: 9fd7de1e0856a9d7843c3df42d33f610fd62caf1 SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 Yoga: 31a098f74c16780569aebd614a0f37a907de0189 diff --git a/example/ios/VideoExample.xcodeproj/project.pbxproj b/example/ios/VideoExample.xcodeproj/project.pbxproj index b4ac8a62..1ee7d060 100644 --- a/example/ios/VideoExample.xcodeproj/project.pbxproj +++ b/example/ios/VideoExample.xcodeproj/project.pbxproj @@ -263,14 +263,10 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-VideoExample/Pods-VideoExample-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-VideoExample/Pods-VideoExample-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-VideoExample/Pods-VideoExample-frameworks.sh\"\n"; @@ -306,14 +302,10 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-VideoExample/Pods-VideoExample-resources-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-VideoExample/Pods-VideoExample-resources-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-VideoExample/Pods-VideoExample-resources.sh\"\n"; @@ -527,7 +519,10 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native"; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; @@ -596,7 +591,10 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = true; diff --git a/example/src/App.tsx b/example/src/App.tsx index 849fd52c..ea1c294e 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -14,6 +14,9 @@ import { createSource, useVideoPlayer, VideoView, + type onLoadData, + type onProgressData, + type VideoPlayerStatus, type VideoViewRef, } from 'react-native-video'; @@ -33,10 +36,71 @@ const VideoDemo = () => { const [loop, setLoop] = React.useState(false); const [showNativeControls, setShowNativeControls] = React.useState(false); + // For demo: log last event + const [lastEvent, setLastEvent] = React.useState(''); + + // View event handlers + const handleFullscreenChange = React.useCallback((fullscreen: boolean) => { + setLastEvent( + 'View: onFullscreenChange ' + (fullscreen ? 'entered' : 'exited') + ); + console.log('Fullscreen:', fullscreen); + }, []); + + const handlePictureInPictureChange = React.useCallback( + (pipEnabled: boolean) => { + setLastEvent( + 'View: onPictureInPictureChange ' + (pipEnabled ? 'entered' : 'exited') + ); + console.log('PictureInPicture:', pipEnabled); + }, + [] + ); + + const handlePlayerEnd = React.useCallback(() => { + setLastEvent('Player: onEnd'); + console.log('Video has ended'); + }, []); + + const handlePlayerLoad = React.useCallback((data: onLoadData) => { + setLastEvent('Player: onLoad'); + console.log('Video loaded', data); + }, []); + + const handlePlayerBuffer = React.useCallback((buffering: boolean) => { + setLastEvent('Player: onBuffer ' + buffering); + console.log('Buffering:', buffering); + }, []); + + const handlePlayerProgress = React.useCallback((data: onProgressData) => { + setProgress(data.currentTime); + }, []); + + const handlePlayerStatusChange = React.useCallback( + (status: VideoPlayerStatus) => { + setLastEvent('Player: onStatusChange ' + status); + console.log('Status:', status); + }, + [] + ); + + // Setup player and events const player = useVideoPlayer( - 'https://www.w3schools.com/html/mov_bbb.mp4', + { + uri: 'https://www.w3schools.com/html/movie.mp4', + externalSubtitles: [ + { + uri: 'https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt', + label: 'External', + }, + ], + }, (_player) => { - //_player.loop = loop; + _player.onEnd = handlePlayerEnd; + _player.onLoad = handlePlayerLoad; + _player.onBuffer = handlePlayerBuffer; + _player.onProgress = handlePlayerProgress; + _player.onStatusChange = handlePlayerStatusChange; } ); @@ -60,14 +124,6 @@ const VideoDemo = () => { // Progress state const [progress, setProgress] = React.useState(0); - React.useEffect(() => { - const interval = setInterval(() => { - setProgress( - show ? (isNaN(player.currentTime) ? 0 : player.currentTime) : 0 - ); - }, 300); - return () => clearInterval(interval); - }, [player, show]); // Handlers const handleSeek = (val: number) => { @@ -89,6 +145,8 @@ const VideoDemo = () => { controls={showNativeControls} pictureInPicture={true} autoEnterPictureInPicture={true} + onFullscreenChange={handleFullscreenChange} + onPictureInPictureChange={handlePictureInPictureChange} /> ) : ( @@ -117,6 +175,13 @@ const VideoDemo = () => { + {/* Event log */} + + + Last event: {lastEvent} + + + {/* Controls */} player.seekTo(0)} /> diff --git a/packages/react-native-video/android/src/main/java/com/video/core/activities/FullscreenVideoViewActivity.kt b/packages/react-native-video/android/src/main/java/com/video/core/activities/FullscreenVideoViewActivity.kt index e5c7d872..6c0ec012 100644 --- a/packages/react-native-video/android/src/main/java/com/video/core/activities/FullscreenVideoViewActivity.kt +++ b/packages/react-native-video/android/src/main/java/com/video/core/activities/FullscreenVideoViewActivity.kt @@ -80,6 +80,7 @@ class FullscreenVideoViewActivity : Activity() { override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) setupFullScreenButton() + playerView.setShowSubtitleButton(true) hideSystemUI() } diff --git a/packages/react-native-video/android/src/main/java/com/video/core/player/DataSourceFactoryUtils.kt b/packages/react-native-video/android/src/main/java/com/video/core/player/DataSourceFactoryUtils.kt index e9f1cb8e..986a39d6 100644 --- a/packages/react-native-video/android/src/main/java/com/video/core/player/DataSourceFactoryUtils.kt +++ b/packages/react-native-video/android/src/main/java/com/video/core/player/DataSourceFactoryUtils.kt @@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReactContext import com.facebook.react.modules.network.CookieJarContainer import com.facebook.react.modules.network.ForwardingCookieHandler import com.facebook.react.modules.network.OkHttpClientProvider +import com.margelo.nitro.video.HybridVideoPlayerSource import com.margelo.nitro.video.HybridVideoPlayerSourceSpec import okhttp3.JavaNetCookieJar @@ -32,14 +33,13 @@ fun buildHttpDataSourceFactory(context: Context, source: HybridVideoPlayerSource val factory = OkHttpDataSource.Factory(client) - // TODO: Apply Header here, once we add headers to source - val dummyHeaders: Map? = mapOf() + val headers: Map? = source.config.headers - if (dummyHeaders != null) { - factory.setDefaultRequestProperties(dummyHeaders) + if (headers != null) { + factory.setDefaultRequestProperties(headers) } - if (dummyHeaders == null || !dummyHeaders.containsKey("User-Agent")) { + if (headers == null || !headers.containsKey("User-Agent")) { factory.setUserAgent(getUserAgent(context)) } diff --git a/packages/react-native-video/android/src/main/java/com/video/core/player/MediaItemUtils.kt b/packages/react-native-video/android/src/main/java/com/video/core/player/MediaItemUtils.kt new file mode 100644 index 00000000..0f1483b9 --- /dev/null +++ b/packages/react-native-video/android/src/main/java/com/video/core/player/MediaItemUtils.kt @@ -0,0 +1,62 @@ +package com.video.core.player + +import android.util.Log +import android.webkit.MimeTypeMap +import androidx.annotation.OptIn +import androidx.core.net.toUri +import androidx.media3.common.MediaItem +import androidx.media3.common.C +import androidx.media3.common.MimeTypes +import androidx.media3.common.util.UnstableApi +import com.margelo.nitro.video.NativeVideoConfig +import com.video.core.SourceError + +private const val TAG = "MediaItemUtils" + +@OptIn(UnstableApi::class) +fun createMediaItemFromVideoConfig( + config: NativeVideoConfig +): MediaItem { + val mediaItemBuilder = MediaItem.Builder() + + mediaItemBuilder.setUri(config.uri) + + val mediaItem = mediaItemBuilder.build() + return mediaItem +} + +fun getSubtitlesConfiguration( + config: NativeVideoConfig, +): List { + val subtitlesConfiguration: MutableList = mutableListOf() + + if (config.externalSubtitles != null) { + for (subtitle in config.externalSubtitles) { + val ext = MimeTypeMap.getFileExtensionFromUrl(subtitle.uri) + + val mimeType = when (ext?.lowercase()) { + "srt" -> MimeTypes.APPLICATION_SUBRIP + "vtt" -> MimeTypes.TEXT_VTT + "ssa", "ass" -> MimeTypes.TEXT_SSA + else -> { + Log.e(TAG, "Unsupported subtitle extension '$ext' for URI: ${subtitle.uri}. Skipping this subtitle.") + continue + } + } + + try { + val subtitleConfig = MediaItem.SubtitleConfiguration.Builder(subtitle.uri.toUri()) + .setId("external-subtitle-${subtitle.uri}") + .setMimeType(mimeType) + .setSelectionFlags(C.SELECTION_FLAG_DEFAULT or C.SELECTION_FLAG_AUTOSELECT) + .setRoleFlags(C.ROLE_FLAG_SUBTITLE) + .setLabel(subtitle.label) + .build() + subtitlesConfiguration.add(subtitleConfig) + } catch (e: Exception) { + Log.e(TAG, "Error creating SubtitleConfiguration for URI ${subtitle.uri}: ${e.message}", e) + } + } + } + return subtitlesConfiguration +} diff --git a/packages/react-native-video/android/src/main/java/com/video/core/player/MediaSourceUtils.kt b/packages/react-native-video/android/src/main/java/com/video/core/player/MediaSourceUtils.kt index 14e822f8..991ea68b 100644 --- a/packages/react-native-video/android/src/main/java/com/video/core/player/MediaSourceUtils.kt +++ b/packages/react-native-video/android/src/main/java/com/video/core/player/MediaSourceUtils.kt @@ -13,6 +13,8 @@ import androidx.media3.common.util.UnstableApi import androidx.media3.exoplayer.dash.DashMediaSource import androidx.media3.exoplayer.hls.HlsMediaSource import androidx.media3.exoplayer.source.DefaultMediaSourceFactory +import androidx.media3.exoplayer.source.MergingMediaSource +import com.margelo.nitro.video.HybridVideoPlayerSource import com.video.core.SourceError @OptIn(UnstableApi::class) @@ -24,32 +26,43 @@ fun buildMediaSource(context: Context, source: HybridVideoPlayerSourceSpec, medi // 1. Remove query params from uri to avoid getting false extension // 2. Get extension from uri val type = Util.inferContentType(uri) + val dataSourceFactory = buildBaseDataSourceFactory(context, source) - return when(type) { + if (!source.config.externalSubtitles.isNullOrEmpty()) { + return buildExternalSubtitlesMediaSource(context, source) + } + + return when (type) { C.CONTENT_TYPE_DASH -> { - val mediaSourceFactory = DashMediaSource.Factory(buildBaseDataSourceFactory(context, source)) - return mediaSourceFactory.createMediaSource(mediaItem) + DashMediaSource.Factory(dataSourceFactory) + .createMediaSource(mediaItem) } - C.CONTENT_TYPE_HLS -> { - val mediaSourceFactory = HlsMediaSource.Factory(buildBaseDataSourceFactory(context, source)) - return mediaSourceFactory.createMediaSource(mediaItem) + HlsMediaSource.Factory(dataSourceFactory) + .createMediaSource(mediaItem) } - C.CONTENT_TYPE_OTHER -> { - return when (uri.scheme) { - else -> { - val mediaSourceFactory = DefaultMediaSourceFactory(context) - .setDataSourceFactory(buildBaseDataSourceFactory(context, source)) - return mediaSourceFactory.createMediaSource(mediaItem) - } - } + DefaultMediaSourceFactory(context) + .setDataSourceFactory(dataSourceFactory) + .createMediaSource(mediaItem) } - else -> { throw SourceError.UnsupportedContentType(source.uri) } } } +@OptIn(UnstableApi::class) +fun buildExternalSubtitlesMediaSource(context: Context, source: HybridVideoPlayerSourceSpec): MediaSource { + val dataSourceFactory = buildBaseDataSourceFactory(context, source) + val mediaItem = MediaItem.Builder() + .setUri(source.uri.toUri()) + .setSubtitleConfigurations(getSubtitlesConfiguration(source.config)) + .build() + + return DefaultMediaSourceFactory(context) + .setDataSourceFactory(dataSourceFactory) + .createMediaSource(mediaItem) +} + diff --git a/packages/react-native-video/android/src/main/java/com/video/core/player/OnAudioFocusChangedListener.kt b/packages/react-native-video/android/src/main/java/com/video/core/player/OnAudioFocusChangedListener.kt new file mode 100644 index 00000000..0677e240 --- /dev/null +++ b/packages/react-native-video/android/src/main/java/com/video/core/player/OnAudioFocusChangedListener.kt @@ -0,0 +1,27 @@ +package com.video.core.player + +import android.content.IntentFilter +import android.media.AudioManager +import androidx.core.content.ContextCompat +import com.margelo.nitro.video.HybridVideoPlayerEventEmitterSpec + +// TODO: We should make VideoFocusManager that will track focus globally for now lets just do simple listener +class OnAudioFocusChangedListener : AudioManager.OnAudioFocusChangeListener { + private var eventEmitter: HybridVideoPlayerEventEmitterSpec? = null + + override fun onAudioFocusChange(focusChange: Int) { + when (focusChange) { + AudioManager.AUDIOFOCUS_GAIN -> eventEmitter?.onAudioFocusChange(true) + AudioManager.AUDIOFOCUS_LOSS -> eventEmitter?.onAudioFocusChange(false) + AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> eventEmitter?.onAudioFocusChange(false) + } + } + + fun setEventEmitter(eventEmitter: HybridVideoPlayerEventEmitterSpec) { + this.eventEmitter = eventEmitter + } + + fun removeEventEmitter() { + this.eventEmitter = null + } +} diff --git a/packages/react-native-video/android/src/main/java/com/video/core/recivers/AudioBecomingNoisyReceiver.kt b/packages/react-native-video/android/src/main/java/com/video/core/recivers/AudioBecomingNoisyReceiver.kt new file mode 100644 index 00000000..704550c0 --- /dev/null +++ b/packages/react-native-video/android/src/main/java/com/video/core/recivers/AudioBecomingNoisyReceiver.kt @@ -0,0 +1,38 @@ +package com.video.core.recivers + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.media.AudioManager +import androidx.core.content.ContextCompat +import com.margelo.nitro.NitroModules +import com.margelo.nitro.video.HybridVideoPlayerEventEmitterSpec +import com.video.core.LibraryError + +class AudioBecomingNoisyReceiver() : BroadcastReceiver() { + private var eventEmitter: HybridVideoPlayerEventEmitterSpec? = null + + override fun onReceive(context: Context?, intent: Intent?) { + if (intent?.action == AudioManager.ACTION_AUDIO_BECOMING_NOISY) { + eventEmitter?.onAudioBecomingNoisy() + } + } + + fun setEventEmitter(eventEmitter: HybridVideoPlayerEventEmitterSpec) { + val context = NitroModules.applicationContext ?: throw LibraryError.ApplicationContextNotFound + + this.eventEmitter = eventEmitter + val intentFilter = IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY) + ContextCompat.registerReceiver( + context.applicationContext, + this, + intentFilter, + ContextCompat.RECEIVER_NOT_EXPORTED + ) + } + + fun removeEventEmitter() { + this.eventEmitter = null + } +} diff --git a/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoInformationUtils.kt b/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoInformationUtils.kt index 32570113..d2bc5131 100644 --- a/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoInformationUtils.kt +++ b/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoInformationUtils.kt @@ -6,6 +6,7 @@ import android.net.Uri import android.os.Build import android.webkit.URLUtil import com.margelo.nitro.video.VideoInformation +import androidx.core.net.toUri object VideoInformationUtils { fun fromUri(uri: String, headers: Map = emptyMap()): VideoInformation { @@ -13,7 +14,7 @@ object VideoInformationUtils { when { URLUtil.isFileUrl(uri) -> { - retriever.setDataSource(Uri.parse(uri).path) + retriever.setDataSource(uri.toUri().path) } else -> { retriever.setDataSource(uri, headers) diff --git a/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoOrientationUtils.kt b/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoOrientationUtils.kt index a77ec6b8..49679f31 100644 --- a/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoOrientationUtils.kt +++ b/packages/react-native-video/android/src/main/java/com/video/core/utils/VideoOrientationUtils.kt @@ -6,6 +6,8 @@ object VideoOrientationUtils { fun fromWHR(width: Int?, height: Int?, rotation: Int?): VideoOrientation { if (width == 0 || height == 0 || height == null || width == null) return VideoOrientation.UNKNOWN + if (width == height) return VideoOrientation.SQUARE + // Check if video is portrait or landscape using natural size val isNaturalSizePortrait = height > width diff --git a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayer/HybridVideoPlayer.kt b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayer/HybridVideoPlayer.kt index 4310dfa4..a9de93fd 100644 --- a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayer/HybridVideoPlayer.kt +++ b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayer/HybridVideoPlayer.kt @@ -1,13 +1,25 @@ package com.margelo.nitro.video +import android.os.Handler import android.os.Looper -import android.view.SurfaceView +import android.util.Log import androidx.media3.common.C +import androidx.media3.common.Metadata +import androidx.media3.common.PlaybackException +import androidx.media3.common.PlaybackParameters import androidx.media3.common.Player +import androidx.media3.common.TrackSelectionOverride +import androidx.media3.common.Tracks +import androidx.media3.common.text.CueGroup import androidx.media3.common.util.UnstableApi import androidx.media3.exoplayer.DefaultLoadControl import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.analytics.AnalyticsListener +import androidx.media3.exoplayer.trackselection.DefaultTrackSelector import androidx.media3.exoplayer.upstream.DefaultAllocator +import androidx.media3.extractor.metadata.emsg.EventMessage +import androidx.media3.extractor.metadata.id3.Id3Frame +import androidx.media3.extractor.metadata.id3.TextInformationFrame import androidx.media3.ui.PlayerView import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.NitroModules @@ -16,22 +28,54 @@ import com.video.core.LibraryError import com.video.core.PlayerError import com.video.core.VideoManager import com.video.core.activities.FullscreenVideoViewActivity +import com.video.core.player.OnAudioFocusChangedListener +import com.video.core.recivers.AudioBecomingNoisyReceiver import com.video.core.utils.Threading.runOnMainThread import com.video.core.utils.Threading.runOnMainThreadSync +import com.video.core.utils.VideoOrientationUtils import com.video.view.VideoView import java.lang.ref.WeakReference import kotlin.math.max -import kotlin.math.min @UnstableApi @DoNotStrip class HybridVideoPlayer() : HybridVideoPlayerSpec() { override lateinit var source: HybridVideoPlayerSourceSpec + override var eventEmitter = HybridVideoPlayerEventEmitter() + set(value) { + if (field != value) { + audioFocusChangedListener.setEventEmitter(value) + audioBecomingNoisyReceiver.setEventEmitter(value) + } + field = value + } + private var allocator: DefaultAllocator? = null private var player: ExoPlayer? = null private var currentPlayerView: WeakReference? = null + // Time updates + private val progressHandler = Handler(Looper.getMainLooper()) + private var progressRunnable: Runnable? = null + + // Listeners + private val audioFocusChangedListener = OnAudioFocusChangedListener() + private val audioBecomingNoisyReceiver = AudioBecomingNoisyReceiver() + + private companion object { + const val PROGRESS_UPDATE_INTERVAL_MS = 250L + private const val TAG = "HybridVideoPlayer" + } + + override var status: VideoPlayerStatus = VideoPlayerStatus.IDLE + set(value) { + if (field != value) { + eventEmitter.onStatusChange(value) + } + field = value + } + var playerPointer: ExoPlayer get() { if (player == null) { @@ -111,6 +155,7 @@ class HybridVideoPlayer() : HybridVideoPlayerSpec() { } val hybridSource = source as? HybridVideoPlayerSource ?: throw PlayerError.InvalidSource + val appContext = NitroModules.applicationContext!! // Initialize the allocator allocator = DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE) @@ -133,7 +178,15 @@ class HybridVideoPlayer() : HybridVideoPlayerSpec() { .setLooper(Looper.getMainLooper()) .build() + playerPointer.addListener(playerListener) + playerPointer.addAnalyticsListener(analyticsListener) playerPointer.setMediaSource(hybridSource.mediaSource) + + // Emit onLoadStart + val sourceType = if (hybridSource.uri.startsWith("http")) SourceType.NETWORK else SourceType.LOCAL + eventEmitter.onLoadStart(onLoadStartData(sourceType = sourceType, source = hybridSource)) + status = VideoPlayerStatus.LOADING + startProgressUpdates() } constructor(source: HybridVideoPlayerSource) : this() { @@ -194,8 +247,16 @@ class HybridVideoPlayer() : HybridVideoPlayerSpec() { private fun release() { VideoManager.unregisterPlayer(this) + stopProgressUpdates() runOnMainThread { - playerPointer.release() + player?.removeListener(playerListener) + player?.removeAnalyticsListener(analyticsListener) + player?.release() // Release player + player = null // Nullify the player + + // Clean Listeners + audioFocusChangedListener.removeEventEmitter() + audioBecomingNoisyReceiver.removeEventEmitter() } } @@ -223,4 +284,202 @@ class HybridVideoPlayer() : HybridVideoPlayerSpec() { override val memorySize: Long get() = (if (allocator == null) 0 else allocator!!.totalBytesAllocated).toLong() + + private fun startProgressUpdates() { + stopProgressUpdates() // Ensure no multiple runnables + progressRunnable = object : Runnable { + override fun run() { + if (playerPointer.playbackState != Player.STATE_IDLE && playerPointer.playbackState != Player.STATE_ENDED) { + val currentTimeSeconds = playerPointer.currentPosition / 1000.0 + val bufferedDurationSeconds = playerPointer.bufferedPosition / 1000.0 + // bufferDuration is the time from current time that is buffered. + val playableDurationFromNow = max(0.0, bufferedDurationSeconds - currentTimeSeconds) + + eventEmitter.onProgress( + onProgressData( + currentTime = currentTimeSeconds, + bufferDuration = playableDurationFromNow + ) + ) + progressHandler.postDelayed(this, PROGRESS_UPDATE_INTERVAL_MS) + } + } + } + progressHandler.post(progressRunnable ?: return) + } + + private fun stopProgressUpdates() { + progressRunnable?.let { progressHandler.removeCallbacks(it) } + progressRunnable = null + } + + private val analyticsListener = object: AnalyticsListener { + override fun onBandwidthEstimate( + eventTime: AnalyticsListener.EventTime, + totalLoadTimeMs: Int, + totalBytesLoaded: Long, + bitrateEstimate: Long + ) { + val videoFormat = playerPointer.videoFormat + eventEmitter.onBandwidthUpdate( + BandwidthData( + bitrate = bitrateEstimate.toDouble(), + width = if (videoFormat != null) videoFormat.width.toDouble() else null, + height = if (videoFormat != null) videoFormat.height.toDouble() else null + ) + ) + } + } + + private val playerListener = object : Player.Listener { + override fun onPlaybackStateChanged(playbackState: Int) { + val isPlayingUpdate = playerPointer.isPlaying + val isBufferingUpdate = playbackState == Player.STATE_BUFFERING + + eventEmitter.onPlaybackStateChange( + onPlaybackStateChangeData( + isPlaying = isPlayingUpdate, + isBuffering = isBufferingUpdate + ) + ) + + when (playbackState) { + Player.STATE_IDLE -> { + status = VideoPlayerStatus.IDLE + eventEmitter.onBuffer(false) + } + Player.STATE_BUFFERING -> { + status = VideoPlayerStatus.LOADING + eventEmitter.onBuffer(true) + } + Player.STATE_READY -> { + status = VideoPlayerStatus.READYTOPLAY + eventEmitter.onBuffer(false) + + val videoFormat = playerPointer.videoFormat + val currentTracks = playerPointer.currentTracks + + val trackVideo = currentTracks.groups.find { group -> group.type == C.TRACK_TYPE_VIDEO && group.isSelected } + ?.getTrackFormat(0) + + + val width = trackVideo?.width ?: videoFormat?.width ?: 0 + val height = trackVideo?.height ?: videoFormat?.height ?: 0 + + + eventEmitter.onLoad( + onLoadData( + currentTime = playerPointer.currentPosition / 1000.0, + duration = if (playerPointer.duration == C.TIME_UNSET) Double.NaN else playerPointer.duration / 1000.0, + width = width.toDouble(), + height = height.toDouble(), + orientation = VideoOrientationUtils.fromWHR(width, height, videoFormat?.rotationDegrees) + ) + ) + // If player becomes ready and is set to play, start progress updates + if (playerPointer.playWhenReady) { + startProgressUpdates() + } + + eventEmitter.onReadyToDisplay() + } + Player.STATE_ENDED -> { + status = VideoPlayerStatus.IDLE // Or a specific 'COMPLETED' status if you add one + eventEmitter.onEnd() + eventEmitter.onBuffer(false) + stopProgressUpdates() + } + } + } + + override fun onIsPlayingChanged(isPlaying: Boolean) { + eventEmitter.onPlaybackStateChange( + onPlaybackStateChangeData( + isPlaying = isPlaying, + isBuffering = playerPointer.playbackState == Player.STATE_BUFFERING + ) + ) + if (isPlaying) { + startProgressUpdates() + } else { + if (playerPointer.playbackState == Player.STATE_ENDED || playerPointer.playbackState == Player.STATE_IDLE) { + stopProgressUpdates() + } + } + } + + override fun onPlayerError(error: PlaybackException) { + status = VideoPlayerStatus.ERROR + stopProgressUpdates() + } + + override fun onPositionDiscontinuity( + oldPosition: Player.PositionInfo, + newPosition: Player.PositionInfo, + reason: Int + ) { + if (reason == Player.DISCONTINUITY_REASON_SEEK || reason == Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT) { + eventEmitter.onSeek(newPosition.positionMs / 1000.0) + } + // Update progress immediately after a discontinuity if needed by your logic + val currentTimeSeconds = newPosition.positionMs / 1000.0 + val bufferedDurationSeconds = playerPointer.bufferedPosition / 1000.0 + eventEmitter.onProgress( + onProgressData( + currentTime = currentTimeSeconds, + bufferDuration = max(0.0, bufferedDurationSeconds - currentTimeSeconds) + ) + ) + } + + override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters) { + eventEmitter.onPlaybackRateChange(playbackParameters.speed.toDouble()) + } + + override fun onVolumeChanged(volume: Float) { + // We get here device volume changes, and if + // player is not muted we will sync it + if (!muted) { + this@HybridVideoPlayer.volume = volume.toDouble() + } + + eventEmitter.onVolumeChange(volume.toDouble()) + } + + override fun onCues(cueGroup: CueGroup) { + val texts = cueGroup.cues.mapNotNull { it.text?.toString() } + if (texts.isNotEmpty()) { + eventEmitter.onTextTrackDataChanged(texts.toTypedArray()) + } + } + + override fun onMetadata(metadata: Metadata) { + val timedMetadataObjects = mutableListOf() + for (i in 0 until metadata.length()) { + val entry = metadata.get(i) + + when (entry) { + is Id3Frame -> { + var value = "" + + if (entry is TextInformationFrame) { + value = entry.values.first() + } + + timedMetadataObjects.add(TimedMetadataObject(entry.id, value)) + } + is EventMessage -> + timedMetadataObjects.add(TimedMetadataObject(entry.schemeIdUri, entry.value)) + else -> Log.d(TAG, "Unknown metadata: $entry") + } + } + if (timedMetadataObjects.isNotEmpty()) { + eventEmitter.onTimedMetadata(TimedMetadata(metadata = timedMetadataObjects.toTypedArray())) + } + } + + override fun onTracksChanged(tracks: Tracks) { + super.onTracksChanged(tracks) + } + } } diff --git a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayereventemitter/HybridVideoPlayerEventEmitter.kt b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayereventemitter/HybridVideoPlayerEventEmitter.kt new file mode 100644 index 00000000..7c8bf46f --- /dev/null +++ b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayereventemitter/HybridVideoPlayerEventEmitter.kt @@ -0,0 +1,39 @@ +package com.margelo.nitro.video + +class HybridVideoPlayerEventEmitter(): HybridVideoPlayerEventEmitterSpec() { + override var onAudioBecomingNoisy: () -> Unit = {} + + override var onAudioFocusChange: (Boolean) -> Unit = {} + + override var onBandwidthUpdate: (BandwidthData) -> Unit = {} + + override var onBuffer: (Boolean) -> Unit = {} + + override var onControlsVisibleChange: (Boolean) -> Unit = {} + + override var onEnd: () -> Unit = {} + + override var onExternalPlaybackChange: (Boolean) -> Unit = {} + + override var onLoad: (onLoadData) -> Unit = {} + + override var onLoadStart: (onLoadStartData) -> Unit = {} + + override var onPlaybackStateChange: (onPlaybackStateChangeData) -> Unit = {} + + override var onPlaybackRateChange: (Double) -> Unit = {} + + override var onProgress: (onProgressData) -> Unit = {} + + override var onReadyToDisplay: () -> Unit = {} + + override var onSeek: (Double) -> Unit = {} + + override var onTimedMetadata: (TimedMetadata) -> Unit = {} + + override var onTextTrackDataChanged: (Array) -> Unit = {} + + override var onVolumeChange: (Double) -> Unit = {} + + override var onStatusChange: (VideoPlayerStatus) -> Unit = {} +} diff --git a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSource.kt b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSource.kt index 28cf6821..7f1dd410 100644 --- a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSource.kt +++ b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSource.kt @@ -8,18 +8,21 @@ import com.margelo.nitro.NitroModules import com.margelo.nitro.core.Promise import com.video.core.LibraryError import com.video.core.player.buildMediaSource +import com.video.core.player.createMediaItemFromVideoConfig import com.video.core.utils.VideoInformationUtils @DoNotStrip class HybridVideoPlayerSource(): HybridVideoPlayerSourceSpec() { override lateinit var uri: String + override lateinit var config: NativeVideoConfig private lateinit var mediaItem: MediaItem lateinit var mediaSource: MediaSource - constructor(uri: String) : this() { - this.uri = uri - this.mediaItem = MediaItem.fromUri(uri) + constructor(config: NativeVideoConfig) : this() { + this.uri = config.uri + this.config = config + this.mediaItem = createMediaItemFromVideoConfig(config) NitroModules.applicationContext?.let { this.mediaSource = buildMediaSource(it, this, mediaItem) @@ -30,7 +33,7 @@ class HybridVideoPlayerSource(): HybridVideoPlayerSourceSpec() { override fun getAssetInformationAsync(): Promise { return Promise.async { - return@async VideoInformationUtils.fromUri(uri) + return@async VideoInformationUtils.fromUri(uri, config.headers ?: emptyMap()) } } diff --git a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSourceFactory.kt b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSourceFactory.kt index 115caf32..25f924df 100644 --- a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSourceFactory.kt +++ b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayersource/HybridVideoPlayerSourceFactory.kt @@ -5,7 +5,12 @@ import com.facebook.proguard.annotations.DoNotStrip @DoNotStrip class HybridVideoPlayerSourceFactory: HybridVideoPlayerSourceFactorySpec() { override fun fromUri(uri: String): HybridVideoPlayerSourceSpec { - return HybridVideoPlayerSource(uri) + val config = NativeVideoConfig(uri, null, null) + return HybridVideoPlayerSource(config) + } + + override fun fromVideoConfig(config: NativeVideoConfig): HybridVideoPlayerSourceSpec { + return HybridVideoPlayerSource(config) } override val memorySize: Long diff --git a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoviewviewmanager/HybridVideoViewViewManager.kt b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoviewviewmanager/HybridVideoViewViewManager.kt index c1d50d58..5ffc73a8 100644 --- a/packages/react-native-video/android/src/main/java/com/video/hybrids/videoviewviewmanager/HybridVideoViewViewManager.kt +++ b/packages/react-native-video/android/src/main/java/com/video/hybrids/videoviewviewmanager/HybridVideoViewViewManager.kt @@ -12,7 +12,7 @@ import com.video.core.utils.Threading @DoNotStrip @OptIn(UnstableApi::class) -class HybridVideoViewViewManager(nitroId: Int): HybridVideoViewViewManagerSpec() { +class HybridVideoViewViewManager(nitroId: Int): HybridVideoViewViewManagerSpec(), VideoViewEvents { private var videoView = VideoManager.getVideoViewWeakReferenceByNitroId(nitroId) ?: throw VideoViewError.ViewNotFound(nitroId) @@ -68,6 +68,47 @@ class HybridVideoViewViewManager(nitroId: Int): HybridVideoViewViewManagerSpec() videoView.get()?.useController = value } + // View callbacks + override var onPictureInPictureChange: ((Boolean) -> Unit)? + set(value) { + field = value + videoView.get()?.events?.onPictureInPictureChange = value + } + override var onFullscreenChange: ((Boolean) -> Unit)? + set(value) { + field = value + videoView.get()?.events?.onFullscreenChange = value + } + override var willEnterFullscreen: (() -> Unit)? + set(value) { + field = value + videoView.get()?.events?.willEnterFullscreen = value + } + override var willExitFullscreen: (() -> Unit)? + set(value) { + field = value + videoView.get()?.events?.willExitFullscreen = value + } + override var willEnterPictureInPicture: (() -> Unit)? + set(value) { + field = value + videoView.get()?.events?.willEnterPictureInPicture = value + } + override var willExitPictureInPicture: (() -> Unit)? + set(value) { + field = value + videoView.get()?.events?.willExitPictureInPicture = value + } + override val memorySize: Long get() = 0 } + +interface VideoViewEvents { + var onPictureInPictureChange: ((Boolean) -> Unit)? + var onFullscreenChange: ((Boolean) -> Unit)? + var willEnterFullscreen: (() -> Unit)? + var willExitFullscreen: (() -> Unit)? + var willEnterPictureInPicture: (() -> Unit)? + var willExitPictureInPicture: (() -> Unit)? +} diff --git a/packages/react-native-video/android/src/main/java/com/video/view/VideoView.kt b/packages/react-native-video/android/src/main/java/com/video/view/VideoView.kt index 4ac5ab42..7223bdce 100644 --- a/packages/react-native-video/android/src/main/java/com/video/view/VideoView.kt +++ b/packages/react-native-video/android/src/main/java/com/video/view/VideoView.kt @@ -18,6 +18,7 @@ import androidx.media3.ui.PlayerView import com.facebook.react.bridge.ReactApplicationContext import com.margelo.nitro.NitroModules import com.margelo.nitro.video.HybridVideoPlayer +import com.margelo.nitro.video.VideoViewEvents import com.video.core.LibraryError import com.video.core.VideoManager import com.video.core.VideoViewError @@ -79,14 +80,32 @@ class VideoView @JvmOverloads constructor( var pictureInPictureEnabled: Boolean = false + var events = object : VideoViewEvents { + override var onPictureInPictureChange: ((Boolean) -> Unit)? = {} + override var onFullscreenChange: ((Boolean) -> Unit)? = {} + override var willEnterFullscreen: (() -> Unit)? = {} + override var willExitFullscreen: (() -> Unit)? = {} + override var willEnterPictureInPicture: (() -> Unit)? = {} + override var willExitPictureInPicture: (() -> Unit)? = {} + } + var onNitroIdChange: ((Int?) -> Unit)? = null var playerView = PlayerView(context).apply { layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) setShutterBackgroundColor(Color.TRANSPARENT) + setShowSubtitleButton(true) useController = false } var isInFullscreen: Boolean = false + set(value) { + field = value + events.onFullscreenChange?.let { it(value) } + } var isInPictureInPicture: Boolean = false + set(value) { + field = value + events.onPictureInPictureChange?.let { it(value) } + } private var rootContentViews: List = listOf() private var pictureInPictureHelperTag: String? = null @@ -229,6 +248,8 @@ class VideoView @JvmOverloads constructor( val currentActivity = applicationContent.currentActivity ?: return + events.willEnterPictureInPicture?.let { it() } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val params = createPictureInPictureParams(this) currentActivity.enterPictureInPictureMode(params) @@ -244,7 +265,7 @@ class VideoView @JvmOverloads constructor( if (!isInPictureInPicture || isInFullscreen) { return } - + events.willExitPictureInPicture?.let { it() } restoreRootContentViews() isInPictureInPicture = false } diff --git a/packages/react-native-video/ios/core/Extensions/AVAssetTrack+orientation.swift b/packages/react-native-video/ios/core/Extensions/AVAssetTrack+orientation.swift index c0ad1cbe..959eba51 100644 --- a/packages/react-native-video/ios/core/Extensions/AVAssetTrack+orientation.swift +++ b/packages/react-native-video/ios/core/Extensions/AVAssetTrack+orientation.swift @@ -12,6 +12,11 @@ extension AVAssetTrack { let transform = preferredTransform let size = naturalSize.applying(transform) + // Check if video is square + if size.width == size.height { + return .square + } + // Check if video is portrait or landscape let isNaturalSizePortrait = size.width < size.height diff --git a/packages/react-native-video/ios/core/Extensions/AVPlayerItem+externalSubtitles.swift b/packages/react-native-video/ios/core/Extensions/AVPlayerItem+externalSubtitles.swift new file mode 100644 index 00000000..7d8e209d --- /dev/null +++ b/packages/react-native-video/ios/core/Extensions/AVPlayerItem+externalSubtitles.swift @@ -0,0 +1,55 @@ +// +// AVPlayerItem+externalSubtitles.swift +// ReactNativeVideo +// +// Created by Krzysztof Moch on 08/05/2025. +// + +import Foundation +import AVFoundation + +extension AVPlayerItem { + static func withExternalSubtitles(for asset: AVURLAsset, config: NativeVideoConfig) async throws -> AVPlayerItem { + let subtitlesAssets = config.externalSubtitles?.map { subtitle in + let url = URL(string: subtitle.uri) + return AVURLAsset(url: url!) + } + + do { + let mainVideoTracks = asset.tracks(withMediaType: .video) + let mainAudioTracks = asset.tracks(withMediaType: .audio) + let textTracks = subtitlesAssets?.flatMap { $0.tracks(withMediaType: .text) } ?? [] + + guard let videoTrack = mainVideoTracks.first(where: { $0.mediaType == .video }), + let audioTrack = mainAudioTracks.first(where: { $0.mediaType == .audio }) + else { + print("Could not find required tracks.") + // TODO: Create Error for this case + throw PlayerError.invalidSource.error() + } + + let composition = AVMutableComposition() + + // Add video track + if let compositionVideoTrack = composition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid) { + try compositionVideoTrack.insertTimeRange(CMTimeRange(start: .zero, duration: videoTrack.timeRange.duration), of: videoTrack, at: .zero) + } + + // Add audio track + if let compositionAudioTrack = composition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid) { + try compositionAudioTrack.insertTimeRange(CMTimeRange(start: .zero, duration: audioTrack.timeRange.duration), of: audioTrack, at: .zero) + } + + for textTrack in textTracks { + // Add subtitle track + if let compositionTextTrack = composition.addMutableTrack(withMediaType: .text, preferredTrackID: kCMPersistentTrackID_Invalid) { + try compositionTextTrack.insertTimeRange(CMTimeRange(start: .zero, duration: textTrack.timeRange.duration), of: textTrack, at: .zero) + + compositionTextTrack.languageCode = textTrack.languageCode + } + } + + return AVPlayerItem(asset: composition) + } + } +} diff --git a/packages/react-native-video/ios/core/Extensions/AVPlayerItem+getBufferedDurration.swift b/packages/react-native-video/ios/core/Extensions/AVPlayerItem+getBufferedDurration.swift new file mode 100644 index 00000000..b6e7a5b2 --- /dev/null +++ b/packages/react-native-video/ios/core/Extensions/AVPlayerItem+getBufferedDurration.swift @@ -0,0 +1,34 @@ +// +// AVPlayerItem+getBufferedPosition.swift +// ReactNativeVideo +// +// Created by Krzysztof Moch on 06/05/2025. +// + +import Foundation +import AVFoundation + +extension AVPlayerItem { + + // Duration that can be played using only the buffer (seconds) + func getbufferDuration() -> Double { + var effectiveTimeRange: CMTimeRange? + + for value in loadedTimeRanges { + let timeRange: CMTimeRange = value.timeRangeValue + if CMTimeRangeContainsTime(timeRange, time: currentTime()) { + effectiveTimeRange = timeRange + break + } + } + + if let effectiveTimeRange { + let playableDuration: Float64 = CMTimeGetSeconds(CMTimeRangeGetEnd(effectiveTimeRange)) + if playableDuration > 0 { + return playableDuration + } + } + + return 0 + } +} diff --git a/packages/react-native-video/ios/core/VideoPlayerObserver.swift b/packages/react-native-video/ios/core/VideoPlayerObserver.swift index 7ba26b44..94ca61a0 100644 --- a/packages/react-native-video/ios/core/VideoPlayerObserver.swift +++ b/packages/react-native-video/ios/core/VideoPlayerObserver.swift @@ -11,14 +11,38 @@ import AVFoundation protocol VideoPlayerObserverDelegate: AnyObject { func onPlayedToEnd(player: AVPlayer) func onPlayerItemChange(player: AVPlayer, playerItem: AVPlayerItem?) + func onTextTrackDataChanged(texts: [NSAttributedString]) + func onTimedMetadataChanged(timedMetadata: [AVMetadataItem]) + func onRateChanged(rate: Float) + func onPlaybackBufferEmpty() + func onPlaybackLikelyToKeepUp() + func onVolumeChanged(volume: Float) + func onExternalPlaybackActiveChanged(isActive: Bool) + func onTimeControlStatusChanged(status: AVPlayer.TimeControlStatus) + func onPlayerStatusChanged(status: AVPlayer.Status) + func onPlayerItemStatusChanged(status: AVPlayerItem.Status) + func onBandwidthUpdate(bitrate: Double) + func onProgressUpdate(currentTime: Double, bufferDuration: Double) } extension VideoPlayerObserverDelegate { func onPlayedToEnd(player: AVPlayer) {} func onPlayerItemChange(player: AVPlayer, playerItem: AVPlayerItem?) {} + func onTextTrackDataChanged(texts: [NSAttributedString]) {} + func onTimedMetadataChanged(timedMetadata: [AVMetadataItem]) {} + func onRateChanged(rate: Float) {} + func onPlaybackBufferEmpty() {} + func onPlaybackLikelyToKeepUp() {} + func onVolumeChanged(volume: Float) {} + func onExternalPlaybackActiveChanged(isActive: Bool) {} + func onTimeControlStatusChanged(status: AVPlayer.TimeControlStatus) {} + func onPlayerStatusChanged(status: AVPlayer.Status) {} + func onPlayerItemStatusChanged(status: AVPlayerItem.Status) {} + func onBandwidthUpdate(bitrate: Double) {} + func onProgressUpdate(currentTime: Double, bufferDuration: Double) {} } -class VideoPlayerObserver { +class VideoPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate, AVPlayerItemLegibleOutputPushDelegate { private weak var delegate: HybridVideoPlayer? var player: AVPlayer? { delegate?.player @@ -26,27 +50,41 @@ class VideoPlayerObserver { // Player observers var playerCurrentItemObserver: NSKeyValueObservation? + var playerRateObserver: NSKeyValueObservation? + var playerTimeControlStatusObserver: NSKeyValueObservation? + var playerExternalPlaybackActiveObserver: NSKeyValueObservation? + var playerVolumeObserver: NSKeyValueObservation? + var playerTimedMetadataObserver: NSKeyValueObservation? + var playerStatusObserver: NSKeyValueObservation? + var playerProgressPeriodicObserver: Any? // Player item observers var playbackEndedObserver: NSObjectProtocol? + var playbackBufferEmptyObserver: NSKeyValueObservation? + var playbackLikelyToKeepUpObserver: NSKeyValueObservation? + var playerItemStatusObserver: NSKeyValueObservation? + var playerItemAccessLogObserver: NSObjectProtocol? + + var metadataOutput: AVPlayerItemMetadataOutput? + var legibleOutput: AVPlayerItemLegibleOutput? init(delegate: HybridVideoPlayer) { self.delegate = delegate } deinit { - removeObservers() + invalidatePlayerObservers() invalidatePlayerItemObservers() } public func updatePlayerObservers() { invalidatePlayerItemObservers() - removeObservers() + invalidatePlayerObservers() initializePlayerObservers() } - private func initializePlayerObservers() { + func initializePlayerObservers() { guard let player else { return } @@ -54,6 +92,39 @@ class VideoPlayerObserver { playerCurrentItemObserver = player.observe(\.currentItem, options: [.new, .old]) { [weak self] _, change in self?.onPlayerCurrentItemChanged(player: player, change: change) } + + playerRateObserver = player.observe(\.rate, options: [.new]) { [weak self] _, change in + guard let rate = change.newValue else { return } + self?.delegate?.onRateChanged(rate: rate) + } + + playerTimeControlStatusObserver = player.observe(\.timeControlStatus, options: [.new]) { [weak self] _, change in + guard let status = change.newValue else { return } + self?.delegate?.onTimeControlStatusChanged(status: status) + } + + playerExternalPlaybackActiveObserver = player.observe(\.isExternalPlaybackActive, options: [.new]) { [weak self] _, change in + guard let isActive = change.newValue else { return } + self?.delegate?.onExternalPlaybackActiveChanged(isActive: isActive) + } + + playerVolumeObserver = player.observe(\.volume, options: [.new]) { [weak self] _, change in + guard let volume = change.newValue else { return } + self?.delegate?.onVolumeChanged(volume: volume) + } + + playerStatusObserver = player.observe(\.status, options: [.new]) { [weak self] _, change in + guard let status = change.newValue else { return } + self?.delegate?.onPlayerStatusChanged(status: status) + } + + // 500ms interval TODO: Make this configurable + let interval = CMTime(seconds: 0.5, preferredTimescale: 600) + playerProgressPeriodicObserver = player.addPeriodicTimeObserver(forInterval: interval, queue: .main) { [weak self] _ in + guard let self, let player = self.player, let delegate = self.delegate else { return } + + delegate.onProgressUpdate(currentTime: player.currentTime().seconds, bufferDuration: player.currentItem?.getbufferDuration() ?? 0) + } } private func initializePlayerItemObservers(player: AVPlayer, playerItem: AVPlayerItem) { @@ -64,17 +135,106 @@ class VideoPlayerObserver { ) { [weak self] notification in self?.delegate?.onPlayedToEnd(player: player) } + + playerItemAccessLogObserver = NotificationCenter.default.addObserver( + forName: .AVPlayerItemNewAccessLogEntry, + object: playerItem, + queue: nil + ) { [weak self] notification in + self?.onPlayerAccessLog(playerItem: playerItem) + } + + playbackBufferEmptyObserver = playerItem.observe(\.isPlaybackBufferEmpty, options: [.new]) { [weak self] _, change in + guard change.newValue == true else { return } + self?.delegate?.onPlaybackBufferEmpty() + } + + playbackLikelyToKeepUpObserver = playerItem.observe(\.isPlaybackLikelyToKeepUp, options: [.new]) { [weak self] _, change in + guard change.newValue == true else { return } + self?.delegate?.onPlaybackLikelyToKeepUp() + } + + playerItemStatusObserver = playerItem.observe(\.status, options: [.new]) { [weak self] _, change in + self?.delegate?.onPlayerItemStatusChanged(status: playerItem.status) + } + + let metadataOutput = AVPlayerItemMetadataOutput() + playerItem.add(metadataOutput) + metadataOutput.setDelegate(self, queue: .global(qos: .userInteractive)) + + let legibleOutput = AVPlayerItemLegibleOutput() + playerItem.add(legibleOutput) + metadataOutput.setDelegate(self, queue: .global(qos: .userInteractive)) } private func invalidatePlayerItemObservers() { - NotificationCenter.default.removeObserver(playbackEndedObserver as Any) + // Remove NotificationCenter observers + if let playbackEndedObserver = playbackEndedObserver { + NotificationCenter.default.removeObserver(playbackEndedObserver) + self.playbackEndedObserver = nil + } + if let playerItemAccessLogObserver = playerItemAccessLogObserver { + NotificationCenter.default.removeObserver(playerItemAccessLogObserver) + self.playerItemAccessLogObserver = nil + } + // Invalidate KVO observers + playbackBufferEmptyObserver?.invalidate() + playbackBufferEmptyObserver = nil + playbackLikelyToKeepUpObserver?.invalidate() + playbackLikelyToKeepUpObserver = nil + playerItemStatusObserver?.invalidate() + playerItemStatusObserver = nil + // Remove outputs if needed + // (Assumes outputs are not shared between items) + if let playerItem = player?.currentItem { + if let metadataOutput = metadataOutput { + playerItem.remove(metadataOutput) + } + if let legibleOutput = legibleOutput { + playerItem.remove(legibleOutput) + } + } + metadataOutput = nil + legibleOutput = nil } - - private func removeObservers() { + func invalidatePlayerObservers() { + // Invalidate KVO observers playerCurrentItemObserver?.invalidate() + playerCurrentItemObserver = nil + playerRateObserver?.invalidate() + playerRateObserver = nil + playerTimeControlStatusObserver?.invalidate() + playerTimeControlStatusObserver = nil + playerExternalPlaybackActiveObserver?.invalidate() + playerExternalPlaybackActiveObserver = nil + playerVolumeObserver?.invalidate() + playerVolumeObserver = nil + playerStatusObserver?.invalidate() + playerStatusObserver = nil + // Remove periodic time observer from player + if let player = player, let periodicObserver = playerProgressPeriodicObserver { + player.removeTimeObserver(periodicObserver) + playerProgressPeriodicObserver = nil + } } + // MARK: - AVPlayerItemLegibleOutputPushDelegate + func legibleOutput(_: AVPlayerItemLegibleOutput, + didOutputAttributedStrings strings: [NSAttributedString], + nativeSampleBuffers _: [Any], + forItemTime _: CMTime) { + delegate?.onTextTrackDataChanged(texts: strings) + } + + // MARK: - AVPlayerItemMetadataOutputPushDelegate + func metadataOutput(_: AVPlayerItemMetadataOutput, didOutputTimedMetadataGroups groups: [AVTimedMetadataGroup], from _: AVPlayerItemTrack?) { + for metadataGroup in groups { + delegate?.onTimedMetadataChanged(timedMetadata: metadataGroup.items) + } + } + + // MARK: - AVPlayer Observers func onPlayerCurrentItemChanged(player: AVPlayer, change: NSKeyValueObservedChange) { let newPlayerItem = change.newValue?.flatMap { $0 } @@ -88,4 +248,12 @@ class VideoPlayerObserver { delegate?.onPlayerItemChange(player: player, playerItem: playerItem) } } + + // MARK: - AVPlayerItem Observers + func onPlayerAccessLog(playerItem: AVPlayerItem) { + guard let accessLog = playerItem.accessLog() else { return } + guard let lastEvent = accessLog.events.last else { return } + + delegate?.onBandwidthUpdate(bitrate: lastEvent.indicatedBitrate) + } } diff --git a/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer+Events.swift b/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer+Events.swift new file mode 100644 index 00000000..785d8675 --- /dev/null +++ b/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer+Events.swift @@ -0,0 +1,148 @@ +// +// HybridVideoPlayer+Events.swift +// ReactNativeVideo +// +// Created by Krzysztof Moch on 02/05/2025. +// + +import Foundation +import AVFoundation + +extension HybridVideoPlayer: VideoPlayerObserverDelegate { + // MARK: - VideoPlayerObserverDelegate + + func onPlayedToEnd(player: AVPlayer) { + eventEmitter.onEnd() + + if loop { + currentTime = 0 + try? play() + } + } + + func onRateChanged(rate: Float) { + eventEmitter.onPlaybackRateChange(Double(rate)) + } + + func onVolumeChanged(volume: Float) { + eventEmitter.onVolumeChange(Double(volume)) + } + + func onPlaybackBufferEmpty() { + if playerItem?.isPlaybackBufferEmpty == true { + eventEmitter.onBuffer(true) + status = .loading + } + } + + func onProgressUpdate(currentTime: Double, bufferDuration bufferDuration: Double) { + eventEmitter.onProgress(.init(currentTime: currentTime, bufferDuration: bufferDuration)) + } + + func onPlaybackLikelyToKeepUp() { + guard let playerItem else { + return + } + + if !playerItem.isPlaybackBufferEmpty && playerItem.isPlaybackBufferEmpty { + eventEmitter.onBuffer(true) + status = .loading + } else if playerItem.isPlaybackLikelyToKeepUp { + eventEmitter.onBuffer(false) + status = .readytoplay + } + } + + func onExternalPlaybackActiveChanged(isActive: Bool) { + eventEmitter.onExternalPlaybackChange(isActive) + } + + func onTimeControlStatusChanged(status: AVPlayer.TimeControlStatus) { + // check for error + if playerPointer.status == .failed || playerItem?.status == .failed { + self.status = .error + eventEmitter.onPlaybackStateChange(.init(isPlaying: false, isBuffering: false)) + return + } + + // check if player is waiting to play at specified rate + if playerPointer.timeControlStatus == .waitingToPlayAtSpecifiedRate { + self.status = .loading + return + } + + self.status = .readytoplay + + // check for playback state + switch playerPointer.timeControlStatus { + case .playing: + eventEmitter.onPlaybackStateChange(.init(isPlaying: true, isBuffering: playerItem?.isPlaybackBufferEmpty == true)) + case .paused: + eventEmitter.onPlaybackStateChange(.init(isPlaying: false, isBuffering: playerItem?.isPlaybackBufferEmpty == true)) + default: + break + } + } + + func onPlayerStatusChanged(status: AVPlayer.Status) { + // check for error + if status == .failed || playerItem?.status == .failed { + self.status = .error + } + } + + func onPlayerItemStatusChanged(status: AVPlayerItem.Status) { + if status == .failed { + self.status = .error + return + } + + switch status { + case .unknown: + self.status = .loading + case .readyToPlay: + self.status = playerItem?.isPlaybackBufferEmpty == true ? .loading : .readytoplay + case .failed: + self.status = .error + @unknown default: + break + } + + if self.status == .error || self.status == .readytoplay { + guard let playerItem else { + // unlikely to happen + return + } + + let height = playerItem.presentationSize.height + let width = playerItem.presentationSize.width + let orientation: VideoOrientation = playerItem.asset.tracks.first(where: { $0.mediaType == .video })?.orientation ?? .unknown + + eventEmitter.onLoad( + .init(currentTime, duration, height, width, orientation) + ) + } + } + + func onTextTrackDataChanged(texts: [NSAttributedString]) { + eventEmitter.onTextTrackDataChanged(texts.map { $0.string }) + } + + func onTimedMetadataChanged(timedMetadata: [AVMetadataItem]) { + var metadata: [TimedMetadataObject] = [] + for item in timedMetadata { + let value = item.value as? String + let identifier = item.identifier?.rawValue + + if let value, let identifier { + metadata.append(.init(value: value, identifier: identifier)) + } + } + + eventEmitter.onTimedMetadata(.init(metadata: metadata)) + } + + func onBandwidthUpdate(bitrate: Double) { + eventEmitter.onBandwidthUpdate(.init(bitrate: bitrate, width: nil, height: nil)) + } +} diff --git a/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift b/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift index 3915ee9c..9f02a301 100644 --- a/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift +++ b/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift @@ -9,42 +9,45 @@ import Foundation import NitroModules import AVFoundation -class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { +class HybridVideoPlayer: HybridVideoPlayerSpec { /** * This in general should not be used directly, use `playerPointer` instead. This should be set only from within the playerQueue. */ var player: AVPlayer? { didSet { - playerObserver?.updatePlayerObservers() + playerObserver?.initializePlayerObservers() + } + willSet { + playerObserver?.invalidatePlayerObservers() } } /** * The player queue is used to synchronize player initialization. */ - private let playerQueue = DispatchQueue(label: "com.nitro.hybridplayer") + private let playerQueue = DispatchQueue(label: "com.nitro.hybridplayer", qos: .userInitiated) /** * This is the actual player that should be used for playback. It is initialized lazily when `playerPointer` is accessed. */ var playerPointer: AVPlayer { get { - // Synchronize access to player initialization + // Synchronize access to player instance playerQueue.sync { - // If player is already initialized and playerItem is set, return it - // If playerItem is not set, it means that player was not loaded with any source if player != nil && playerItem != nil { return player! } - + do { - let item = try initializePlayerItem() - playerItem = item + if self.playerItem == nil { + self.playerItem = try initializePlayerItemSync() + } + + if player == nil { + player = AVPlayer() + } - // We need to intialize empty player first so player observers are set - // before we set the player item - player = AVPlayer() - player?.replaceCurrentItem(with: item) + player?.replaceCurrentItem(with: playerItem) } catch { playerItem = nil player = AVPlayer() @@ -65,6 +68,7 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { init(source: (any HybridVideoPlayerSourceSpec)) throws { self.source = source + self.eventEmitter = HybridVideoPlayerEventEmitter() super.init() self.playerObserver = VideoPlayerObserver(delegate: self) @@ -80,6 +84,16 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { var source: any HybridVideoPlayerSourceSpec + var status: VideoPlayerStatus = .idle { + didSet { + if status != oldValue { + eventEmitter.onStatusChange(status) + } + } + } + + var eventEmitter: HybridVideoPlayerEventEmitterSpec + var volume: Double { set { playerPointer.volume = Float(newValue) @@ -100,6 +114,7 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { var currentTime: Double { set { + eventEmitter.onSeek(newValue) playerPointer.seek( to: CMTime(seconds: newValue, preferredTimescale: 1000), toleranceBefore: .zero, @@ -135,7 +150,7 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { } func release() { - playerQueue.sync { [weak self] in + playerQueue.async { [weak self] in guard let self = self else { return } self.player?.replaceCurrentItem(with: nil) self.player = nil @@ -151,16 +166,29 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { } func preload() throws -> NitroModules.Promise { - return Promise.parallel { [weak self] in + let promise = Promise() + + Task.detached(priority: .userInitiated) { [weak self] in guard let self else { - throw LibraryError.deallocated(objectName: "HybridVideoPlayer").error() + promise.reject(withError: LibraryError.deallocated(objectName: "HybridVideoPlayer").error()) + return } - try self.playerQueue.sync { - self.playerItem = try self.initializePlayerItem() - self.player = AVPlayer(playerItem: self.playerItem) + do { + let playerItem = try await self.initializePlayerItem() + self.playerItem = playerItem + + self.playerQueue.sync { + self.player = AVPlayer() + self.player?.replaceCurrentItem(with: playerItem) + promise.resolve(withResult: ()) + } + } catch { + promise.reject(withError: error) } } + + return promise } func play() throws { @@ -192,56 +220,94 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, VideoPlayerObserverDelegate { } func replaceSourceAsync(source: (any HybridVideoPlayerSourceSpec)) throws -> Promise { - return Promise.parallel { [weak self] in + let promise = Promise() + + Task.detached(priority: .userInitiated) { [weak self] in guard let self else { - throw LibraryError.deallocated(objectName: "HybridVideoPlayer").error() + promise.reject(withError: LibraryError.deallocated(objectName: "HybridVideoPlayer").error()) + return } - try playerQueue.sync { - self.source = source - + self.playerItem = try await self.initializePlayerItem() + self.source = source + + playerQueue.sync { do { - self.playerItem = try self.initializePlayerItem() - guard let player = self.player else { throw PlayerError.notInitialized.error() } player.replaceCurrentItem(with: self.playerItem) + promise.resolve(withResult: ()) } catch { self.playerItem = nil self.player = AVPlayer() - throw error + promise.reject(withError: error) } } } + + return promise } // MARK: - Internal Methods - private func initializePlayerItem() throws -> AVPlayerItem { + /** + * Initialize the player item synchronously. This is used to initialize the player item before it is set to the player. + * This is necessary because the player item is used to initialize the player. + * This is a blocking call and should be used with caution. prefer using `initializePlayerItem()` instead. + */ + private func initializePlayerItemSync() throws -> AVPlayerItem { + let semaphore = DispatchSemaphore(value: 0) + var initializedItem: AVPlayerItem? + var initializationError: Error? + + Task.detached(priority: .userInitiated) { [weak self] in + guard let strongSelf = self else { + semaphore.signal() + throw LibraryError.deallocated(objectName: "HybridVideoPlayer").error() + } + + do { + initializedItem = try await strongSelf.initializePlayerItem() + } catch { + initializationError = error + } + + semaphore.signal() + } + + semaphore.wait() // Block current thread (playerQueue) + + if let error = initializationError, initializedItem == nil { + throw error + } + + return initializedItem! + } + + private func initializePlayerItem() async throws -> AVPlayerItem { guard let _source = source as? HybridVideoPlayerSource else { + status = .error throw PlayerError.invalidSource.error() } - try _source.initializeAsset() + let isNetowrkSource = _source.url.isFileURL == false + eventEmitter.onLoadStart(.init(sourceType: isNetowrkSource ? .network : .local, source: _source)) + + try await _source.initializeAsset() guard let asset = _source.asset else { + status = .error throw SourceError.failedToInitializeAsset.error() } - return AVPlayerItem(asset: asset) - } - - // MARK: - VideoPlayerObserverDelegate - - func onPlayedToEnd(player: AVPlayer) { - // TODO: Notify listeners once we implement callbacks - - if loop { - currentTime = 0 - try? play() + // iOS does not support external subtitles for HLS streams + if let externalSubtiles = source.config.externalSubtitles, externalSubtiles.isEmpty == false, source.uri.hasSuffix(".m3u8") == false { + return try await AVPlayerItem.withExternalSubtitles(for: asset, config: source.config) } + + return AVPlayerItem(asset: asset) } // MARK: - Memory Management diff --git a/packages/react-native-video/ios/hybrids/VideoPlayerEmitter/HybridVideoPlayerEventEmitter.swift b/packages/react-native-video/ios/hybrids/VideoPlayerEmitter/HybridVideoPlayerEventEmitter.swift new file mode 100644 index 00000000..065dbedd --- /dev/null +++ b/packages/react-native-video/ios/hybrids/VideoPlayerEmitter/HybridVideoPlayerEventEmitter.swift @@ -0,0 +1,47 @@ +// +// HybridVideoPlayerEventEmitter.swift +// ReactNativeVideo +// +// Created by Krzysztof Moch on 02/05/2025. +// + +import Foundation +import NitroModules + +class HybridVideoPlayerEventEmitter: HybridVideoPlayerEventEmitterSpec { + var onAudioBecomingNoisy: (() -> Void) = {} + + var onAudioFocusChange: ((Bool) -> Void) = { _ in } + + var onBandwidthUpdate: ((BandwidthData) -> Void) = { _ in } + + var onBuffer: ((Bool) -> Void) = { _ in } + + var onControlsVisibleChange: ((Bool) -> Void) = { _ in } + + var onEnd: (() -> Void) = {} + + var onExternalPlaybackChange: ((Bool) -> Void) = { _ in } + + var onLoad: ((onLoadData) -> Void) = { _ in } + + var onLoadStart: ((onLoadStartData) -> Void) = { _ in } + + var onPlaybackStateChange: ((onPlaybackStateChangeData) -> Void) = { _ in } + + var onPlaybackRateChange: ((Double) -> Void) = { _ in } + + var onProgress: ((onProgressData) -> Void) = { _ in } + + var onReadyToDisplay: (() -> Void) = {} + + var onSeek: ((Double) -> Void) = { _ in } + + var onStatusChange: (VideoPlayerStatus) -> Void = { _ in } + + var onTimedMetadata: ((TimedMetadata) -> Void) = { _ in } + + var onTextTrackDataChanged: ([String]) -> Void = { _ in } + + var onVolumeChange: ((Double) -> Void) = { _ in } +} diff --git a/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSource.swift b/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSource.swift index 69eca421..9eec8cb3 100644 --- a/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSource.swift +++ b/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSource.swift @@ -12,11 +12,13 @@ import NitroModules class HybridVideoPlayerSource: HybridVideoPlayerSourceSpec { public var asset: AVURLAsset? var uri: String + var config: NativeVideoConfig let url: URL - init(uri: String) throws { - self.uri = uri + init(config: NativeVideoConfig) throws { + self.uri = config.uri + self.config = config guard let url = URL(string: uri) else { throw SourceError.invalidUri(uri: uri).error() @@ -29,33 +31,58 @@ class HybridVideoPlayerSource: HybridVideoPlayerSourceSpec { releaseAsset() } - func getAssetInformationAsync() throws -> Promise { - return Promise.async(.utility) { [weak self] in + func getAssetInformationAsync() -> Promise { + let promise = Promise() + + Task.detached(priority: .utility) { [weak self] in guard let self else { - throw LibraryError.deallocated(objectName: "HybridVideoPlayerSource").error() + promise.reject(withError: LibraryError.deallocated(objectName: "HybridVideoPlayerSource").error()) + return } - if self.url.isFileURL { - try VideoFileHelper.validateReadPermission(for: self.url) + do { + if self.url.isFileURL { + try VideoFileHelper.validateReadPermission(for: self.url) + } + + try await self.initializeAsset() + + guard let asset = self.asset else { + throw PlayerError.assetNotInitialized.error() + } + + let videoInformation = try await asset.getAssetInformation() + + promise.resolve(withResult: videoInformation) + } catch { + promise.reject(withError: error) } - - try initializeAsset() - - guard let asset = self.asset else { - throw PlayerError.assetNotInitialized.error() - } - - return try await asset.getAssetInformation() } + + return promise } - public func initializeAsset() throws { + public func initializeAsset() async throws { guard asset == nil else { return } - // TODO: Pass headers here - asset = AVURLAsset(url: url) + if let headers = config.headers { + let options = [ + "AVURLAssetHTTPHeaderFieldsKey": headers + ] + asset = AVURLAsset(url: url, options: options) + } else { + asset = AVURLAsset(url: url) + } + + guard let asset else { + throw SourceError.failedToInitializeAsset.error() + } + + // Code browed from expo-video https://github.com/expo/expo/blob/ea17c9b1ce5111e1454b089ba381f3feb93f33cc/packages/expo-video/ios/VideoPlayerItem.swift#L40C30-L40C73 + // If we don't load those properties, they will be loaded on main thread casuing lags + _ = try? await asset.load(.duration, .preferredTransform, .isPlayable) } public func releaseAsset() { diff --git a/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSourceFactory.swift b/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSourceFactory.swift index f1a1a4f6..1d9ef726 100644 --- a/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSourceFactory.swift +++ b/packages/react-native-video/ios/hybrids/VideoPlayerSource/HybridVideoPlayerSourceFactory.swift @@ -8,7 +8,12 @@ import Foundation class HybridVideoPlayerSourceFactory: HybridVideoPlayerSourceFactorySpec { + func fromVideoConfig(config: NativeVideoConfig) throws -> any HybridVideoPlayerSourceSpec { + return try HybridVideoPlayerSource(config: config) + } + func fromUri(uri: String) throws -> HybridVideoPlayerSourceSpec { - return try HybridVideoPlayerSource(uri: uri) + let config = NativeVideoConfig(uri: uri, headers: nil, externalSubtitles: nil) + return try HybridVideoPlayerSource(config: config) } } diff --git a/packages/react-native-video/ios/hybrids/VideoViewViewManager/HybridVideoViewViewManager.swift b/packages/react-native-video/ios/hybrids/VideoViewViewManager/HybridVideoViewViewManager.swift index b866d551..99287353 100644 --- a/packages/react-native-video/ios/hybrids/VideoViewViewManager/HybridVideoViewViewManager.swift +++ b/packages/react-native-video/ios/hybrids/VideoViewViewManager/HybridVideoViewViewManager.swift @@ -19,9 +19,13 @@ class HybridVideoViewViewManager: HybridVideoViewViewManagerSpec { throw VideoViewError.viewNotFound(nitroId: nitroId).error() } - self.view = view + self.view = view + super.init() + view.delegate = VideoViewDelegate(viewManager: self) } + // MARK: - Properties + weak var player: (any HybridVideoPlayerSpec)? { get { guard let view = view else { @@ -131,4 +135,20 @@ class HybridVideoViewViewManager: HybridVideoViewViewManagerSpec { func canEnterPictureInPicture() -> Bool { return AVPictureInPictureController.isPictureInPictureSupported() } + + // MARK: - Callbacks + + var onPictureInPictureChange: ((Bool) -> Void)? + + var onFullscreenChange: ((Bool) -> Void)? + + var willEnterFullscreen: (() -> Void)? + + var willExitFullscreen: (() -> Void)? + + var willEnterPictureInPicture: (() -> Void)? + + var willExitPictureInPicture: (() -> Void)? + + var onReadyToDisplay: (() -> Void)? } diff --git a/packages/react-native-video/ios/view/VideoComponentView.swift b/packages/react-native-video/ios/view/VideoComponentView.swift index c9043ee5..713cc4c9 100644 --- a/packages/react-native-video/ios/view/VideoComponentView.swift +++ b/packages/react-native-video/ios/view/VideoComponentView.swift @@ -18,8 +18,23 @@ import AVKit } } + var delegate: VideoViewDelegate? private var playerView: UIView? = nil - private var playerViewController: AVPlayerViewController? + + private var observer: VideoComponentViewObserver? { + didSet { + playerViewController?.delegate = observer + observer?.updatePlayerViewControllerObservers() + } + } + + var playerViewController: AVPlayerViewController? { + didSet { + guard let observer, let playerViewController else { return } + playerViewController.delegate = observer + observer.updatePlayerViewControllerObservers() + } + } public var controls: Bool = false { didSet { @@ -64,6 +79,7 @@ import AVKit super.init(frame: frame) VideoManager.shared.register(view: self) setupPlayerView() + observer = VideoComponentViewObserver(view: self) } deinit { diff --git a/packages/react-native-video/ios/view/VideoComponentViewObserver.swift b/packages/react-native-video/ios/view/VideoComponentViewObserver.swift new file mode 100644 index 00000000..4413f824 --- /dev/null +++ b/packages/react-native-video/ios/view/VideoComponentViewObserver.swift @@ -0,0 +1,142 @@ +// +// VideoComponentViewObserver.swift +// ReactNativeVideo +// +// Created by Krzysztof Moch on 06/05/2025. +// + +import Foundation +import AVKit +import AVFoundation + +protocol VideoComponentViewDelegate: AnyObject { + func onPictureInPictureChange(_ isActive: Bool) + func onFullscreenChange(_ isActive: Bool) + func willEnterFullscreen() + func willExitFullscreen() + func willEnterPictureInPicture() + func willExitPictureInPicture() + func onReadyToDisplay() +} + +// Map delegate methods to view manager methods +final class VideoViewDelegate: NSObject, VideoComponentViewDelegate { + weak var viewManager: HybridVideoViewViewManager? + + init(viewManager: HybridVideoViewViewManager) { + self.viewManager = viewManager + } + + func onPictureInPictureChange(_ isActive: Bool) { + viewManager?.onPictureInPictureChange?(isActive) + } + + func onFullscreenChange(_ isActive: Bool) { + viewManager?.onFullscreenChange?(isActive) + } + + func willEnterFullscreen() { + viewManager?.willEnterFullscreen?() + } + + func willExitFullscreen() { + viewManager?.willExitFullscreen?() + } + + func willEnterPictureInPicture() { + viewManager?.willEnterPictureInPicture?() + } + + func willExitPictureInPicture() { + viewManager?.willExitPictureInPicture?() + } + + func onReadyToDisplay() { + viewManager?.player?.eventEmitter.onReadyToDisplay() + } +} + +class VideoComponentViewObserver: NSObject, AVPlayerViewControllerDelegate { + private weak var view: VideoComponentView? + + var delegate: VideoViewDelegate? { + get { + return view?.delegate + } + } + + var playerViewController: AVPlayerViewController? { + return view?.playerViewController + } + + // playerViewController observers + var onReadyToDisplayObserver: NSKeyValueObservation? + + init(view: VideoComponentView) { + self.view = view + super.init() + } + + func initializePlayerViewContorollerObservers() { + guard let playerViewController = playerViewController else { + return + } + + onReadyToDisplayObserver = playerViewController.observe(\.isReadyForDisplay, options: [.new]) { [weak self] _, change in + guard let self = self else { return } + if change.newValue == true { + self.delegate?.onReadyToDisplay() + } + } + } + + func removePlayerViewControllerObservers() { + onReadyToDisplayObserver?.invalidate() + onReadyToDisplayObserver = nil + } + + func updatePlayerViewControllerObservers() { + removePlayerViewControllerObservers() + initializePlayerViewContorollerObservers() + } + + func playerViewControllerDidStartPictureInPicture(_: AVPlayerViewController) { + delegate?.onPictureInPictureChange(true) + } + + func playerViewControllerDidStopPictureInPicture(_: AVPlayerViewController) { + delegate?.onPictureInPictureChange(false) + } + + func playerViewControllerWillStartPictureInPicture(_: AVPlayerViewController) { + delegate?.willEnterPictureInPicture() + } + + func playerViewControllerWillStopPictureInPicture(_: AVPlayerViewController) { + delegate?.willExitPictureInPicture() + } + + func playerViewController( + _: AVPlayerViewController, + willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator + ) { + delegate?.willExitFullscreen() + + coordinator.animate(alongsideTransition: nil) { [weak self] _ in + guard let self = self else { return } + self.delegate?.onFullscreenChange(false) + } + } + + func playerViewController( + _: AVPlayerViewController, + willBeginFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator + ) { + delegate?.willEnterFullscreen() + + coordinator.animate(alongsideTransition: nil) { [weak self] _ in + guard let self = self else { return } + self.delegate?.onFullscreenChange(true) + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/ReactNativeVideo+autolinking.cmake b/packages/react-native-video/nitrogen/generated/android/ReactNativeVideo+autolinking.cmake index 3bdf19cc..5fe7a956 100644 --- a/packages/react-native-video/nitrogen/generated/android/ReactNativeVideo+autolinking.cmake +++ b/packages/react-native-video/nitrogen/generated/android/ReactNativeVideo+autolinking.cmake @@ -29,6 +29,7 @@ target_sources( # Shared Nitrogen C++ sources ../nitrogen/generated/shared/c++/HybridVideoPlayerSpec.cpp ../nitrogen/generated/shared/c++/HybridVideoPlayerFactorySpec.cpp + ../nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.cpp ../nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.cpp ../nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.cpp ../nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.cpp @@ -36,6 +37,7 @@ target_sources( # Android-specific Nitrogen C++ sources ../nitrogen/generated/android/c++/JHybridVideoPlayerSpec.cpp ../nitrogen/generated/android/c++/JHybridVideoPlayerFactorySpec.cpp + ../nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.cpp ../nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.cpp ../nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.cpp ../nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.cpp diff --git a/packages/react-native-video/nitrogen/generated/android/ReactNativeVideoOnLoad.cpp b/packages/react-native-video/nitrogen/generated/android/ReactNativeVideoOnLoad.cpp index c3230597..cd0babe4 100644 --- a/packages/react-native-video/nitrogen/generated/android/ReactNativeVideoOnLoad.cpp +++ b/packages/react-native-video/nitrogen/generated/android/ReactNativeVideoOnLoad.cpp @@ -17,6 +17,18 @@ #include "JHybridVideoPlayerSpec.hpp" #include "JHybridVideoPlayerFactorySpec.hpp" +#include "JHybridVideoPlayerEventEmitterSpec.hpp" +#include "JFunc_void.hpp" +#include "JFunc_void_bool.hpp" +#include "JFunc_void_BandwidthData.hpp" +#include "JFunc_void_onLoadData.hpp" +#include "JFunc_void_onLoadStartData.hpp" +#include "JFunc_void_onPlaybackStateChangeData.hpp" +#include "JFunc_void_double.hpp" +#include "JFunc_void_onProgressData.hpp" +#include "JFunc_void_TimedMetadata.hpp" +#include "JFunc_void_std__vector_std__string_.hpp" +#include "JFunc_void_VideoPlayerStatus.hpp" #include "JHybridVideoPlayerSourceSpec.hpp" #include "JHybridVideoPlayerSourceFactorySpec.hpp" #include "JHybridVideoViewViewManagerSpec.hpp" @@ -35,6 +47,18 @@ int initialize(JavaVM* vm) { // Register native JNI methods margelo::nitro::video::JHybridVideoPlayerSpec::registerNatives(); margelo::nitro::video::JHybridVideoPlayerFactorySpec::registerNatives(); + margelo::nitro::video::JHybridVideoPlayerEventEmitterSpec::registerNatives(); + margelo::nitro::video::JFunc_void_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_bool_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_BandwidthData_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_onLoadData_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_onLoadStartData_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_onPlaybackStateChangeData_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_double_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_onProgressData_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_TimedMetadata_cxx::registerNatives(); + margelo::nitro::video::JFunc_void_std__vector_std__string__cxx::registerNatives(); + margelo::nitro::video::JFunc_void_VideoPlayerStatus_cxx::registerNatives(); margelo::nitro::video::JHybridVideoPlayerSourceSpec::registerNatives(); margelo::nitro::video::JHybridVideoPlayerSourceFactorySpec::registerNatives(); margelo::nitro::video::JHybridVideoViewViewManagerSpec::registerNatives(); diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JBandwidthData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JBandwidthData.hpp new file mode 100644 index 00000000..34482fcf --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JBandwidthData.hpp @@ -0,0 +1,61 @@ +/// +/// JBandwidthData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "BandwidthData.hpp" + +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "BandwidthData" and the the Kotlin data class "BandwidthData". + */ + struct JBandwidthData final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/BandwidthData;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct BandwidthData by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + BandwidthData toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldBitrate = clazz->getField("bitrate"); + double bitrate = this->getFieldValue(fieldBitrate); + static const auto fieldWidth = clazz->getField("width"); + jni::local_ref width = this->getFieldValue(fieldWidth); + static const auto fieldHeight = clazz->getField("height"); + jni::local_ref height = this->getFieldValue(fieldHeight); + return BandwidthData( + bitrate, + width != nullptr ? std::make_optional(width->value()) : std::nullopt, + height != nullptr ? std::make_optional(height->value()) : std::nullopt + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const BandwidthData& value) { + return newInstance( + value.bitrate, + value.width.has_value() ? jni::JDouble::valueOf(value.width.value()) : nullptr, + value.height.has_value() ? jni::JDouble::valueOf(value.height.value()) : nullptr + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JExternalSubtitle.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JExternalSubtitle.hpp new file mode 100644 index 00000000..01aa662d --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JExternalSubtitle.hpp @@ -0,0 +1,57 @@ +/// +/// JExternalSubtitle.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "ExternalSubtitle.hpp" + +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "ExternalSubtitle" and the the Kotlin data class "ExternalSubtitle". + */ + struct JExternalSubtitle final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/ExternalSubtitle;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct ExternalSubtitle by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + ExternalSubtitle toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldUri = clazz->getField("uri"); + jni::local_ref uri = this->getFieldValue(fieldUri); + static const auto fieldLabel = clazz->getField("label"); + jni::local_ref label = this->getFieldValue(fieldLabel); + return ExternalSubtitle( + uri->toStdString(), + label->toStdString() + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const ExternalSubtitle& value) { + return newInstance( + jni::make_jstring(value.uri), + jni::make_jstring(value.label) + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void.hpp new file mode 100644 index 00000000..ec57138c --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void.hpp @@ -0,0 +1,74 @@ +/// +/// JFunc_void.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `() -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void;"; + + public: + /** + * Invokes the function this `JFunc_void` instance holds through JNI. + */ + void invoke() const { + static const auto method = javaClassStatic()->getMethod("invoke"); + method(self()); + } + }; + + /** + * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds. + */ + void invoke_cxx() { + _func(); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_BandwidthData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_BandwidthData.hpp new file mode 100644 index 00000000..7eb56f79 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_BandwidthData.hpp @@ -0,0 +1,77 @@ +/// +/// JFunc_void_BandwidthData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "BandwidthData.hpp" +#include "JBandwidthData.hpp" +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(data: BandwidthData) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_BandwidthData: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_BandwidthData;"; + + public: + /** + * Invokes the function this `JFunc_void_BandwidthData` instance holds through JNI. + */ + void invoke(const BandwidthData& data) const { + static const auto method = javaClassStatic()->getMethod /* data */)>("invoke"); + method(self(), JBandwidthData::fromCpp(data)); + } + }; + + /** + * An implementation of Func_void_BandwidthData that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_BandwidthData_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_BandwidthData_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_BandwidthData_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref data) { + _func(data->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_BandwidthData_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_BandwidthData_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_BandwidthData_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_TimedMetadata.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_TimedMetadata.hpp new file mode 100644 index 00000000..a80e93e8 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_TimedMetadata.hpp @@ -0,0 +1,80 @@ +/// +/// JFunc_void_TimedMetadata.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "TimedMetadata.hpp" +#include "JTimedMetadata.hpp" +#include +#include "TimedMetadataObject.hpp" +#include "JTimedMetadataObject.hpp" +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(metadata: TimedMetadata) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_TimedMetadata: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_TimedMetadata;"; + + public: + /** + * Invokes the function this `JFunc_void_TimedMetadata` instance holds through JNI. + */ + void invoke(const TimedMetadata& metadata) const { + static const auto method = javaClassStatic()->getMethod /* metadata */)>("invoke"); + method(self(), JTimedMetadata::fromCpp(metadata)); + } + }; + + /** + * An implementation of Func_void_TimedMetadata that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_TimedMetadata_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_TimedMetadata_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_TimedMetadata_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref metadata) { + _func(metadata->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_TimedMetadata_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_TimedMetadata_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_TimedMetadata_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_VideoPlayerStatus.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_VideoPlayerStatus.hpp new file mode 100644 index 00000000..e1cc6371 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_VideoPlayerStatus.hpp @@ -0,0 +1,76 @@ +/// +/// JFunc_void_VideoPlayerStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "VideoPlayerStatus.hpp" +#include "JVideoPlayerStatus.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(status: VideoPlayerStatus) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_VideoPlayerStatus: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_VideoPlayerStatus;"; + + public: + /** + * Invokes the function this `JFunc_void_VideoPlayerStatus` instance holds through JNI. + */ + void invoke(VideoPlayerStatus status) const { + static const auto method = javaClassStatic()->getMethod /* status */)>("invoke"); + method(self(), JVideoPlayerStatus::fromCpp(status)); + } + }; + + /** + * An implementation of Func_void_VideoPlayerStatus that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_VideoPlayerStatus_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_VideoPlayerStatus_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_VideoPlayerStatus_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref status) { + _func(status->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_VideoPlayerStatus_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_VideoPlayerStatus_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_VideoPlayerStatus_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_bool.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_bool.hpp new file mode 100644 index 00000000..662eda55 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_bool.hpp @@ -0,0 +1,74 @@ +/// +/// JFunc_void_bool.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(fullscreen: Boolean) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_bool: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_bool;"; + + public: + /** + * Invokes the function this `JFunc_void_bool` instance holds through JNI. + */ + void invoke(bool fullscreen) const { + static const auto method = javaClassStatic()->getMethod("invoke"); + method(self(), fullscreen); + } + }; + + /** + * An implementation of Func_void_bool that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_bool_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_bool_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_bool_cxx` instance holds. + */ + void invoke_cxx(jboolean fullscreen) { + _func(static_cast(fullscreen)); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_bool_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_bool_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_bool_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_double.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_double.hpp new file mode 100644 index 00000000..566110a6 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_double.hpp @@ -0,0 +1,74 @@ +/// +/// JFunc_void_double.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(volume: Double) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_double: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_double;"; + + public: + /** + * Invokes the function this `JFunc_void_double` instance holds through JNI. + */ + void invoke(double volume) const { + static const auto method = javaClassStatic()->getMethod("invoke"); + method(self(), volume); + } + }; + + /** + * An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_double_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_double_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds. + */ + void invoke_cxx(double volume) { + _func(volume); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_double_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_double_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadData.hpp new file mode 100644 index 00000000..cd5282ff --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadData.hpp @@ -0,0 +1,78 @@ +/// +/// JFunc_void_onLoadData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "onLoadData.hpp" +#include "JonLoadData.hpp" +#include "VideoOrientation.hpp" +#include "JVideoOrientation.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(data: onLoadData) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_onLoadData: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onLoadData;"; + + public: + /** + * Invokes the function this `JFunc_void_onLoadData` instance holds through JNI. + */ + void invoke(const onLoadData& data) const { + static const auto method = javaClassStatic()->getMethod /* data */)>("invoke"); + method(self(), JonLoadData::fromCpp(data)); + } + }; + + /** + * An implementation of Func_void_onLoadData that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_onLoadData_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_onLoadData_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_onLoadData_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref data) { + _func(data->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onLoadData_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_onLoadData_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_onLoadData_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadStartData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadStartData.hpp new file mode 100644 index 00000000..2ccdfa9d --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onLoadStartData.hpp @@ -0,0 +1,82 @@ +/// +/// JFunc_void_onLoadStartData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "onLoadStartData.hpp" +#include "JonLoadStartData.hpp" +#include "SourceType.hpp" +#include "JSourceType.hpp" +#include +#include "HybridVideoPlayerSourceSpec.hpp" +#include "JHybridVideoPlayerSourceSpec.hpp" +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(data: onLoadStartData) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_onLoadStartData: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onLoadStartData;"; + + public: + /** + * Invokes the function this `JFunc_void_onLoadStartData` instance holds through JNI. + */ + void invoke(const onLoadStartData& data) const { + static const auto method = javaClassStatic()->getMethod /* data */)>("invoke"); + method(self(), JonLoadStartData::fromCpp(data)); + } + }; + + /** + * An implementation of Func_void_onLoadStartData that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_onLoadStartData_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_onLoadStartData_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_onLoadStartData_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref data) { + _func(data->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onLoadStartData_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_onLoadStartData_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_onLoadStartData_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onPlaybackStateChangeData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onPlaybackStateChangeData.hpp new file mode 100644 index 00000000..967b2dab --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onPlaybackStateChangeData.hpp @@ -0,0 +1,76 @@ +/// +/// JFunc_void_onPlaybackStateChangeData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "onPlaybackStateChangeData.hpp" +#include "JonPlaybackStateChangeData.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(data: onPlaybackStateChangeData) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_onPlaybackStateChangeData: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onPlaybackStateChangeData;"; + + public: + /** + * Invokes the function this `JFunc_void_onPlaybackStateChangeData` instance holds through JNI. + */ + void invoke(const onPlaybackStateChangeData& data) const { + static const auto method = javaClassStatic()->getMethod /* data */)>("invoke"); + method(self(), JonPlaybackStateChangeData::fromCpp(data)); + } + }; + + /** + * An implementation of Func_void_onPlaybackStateChangeData that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_onPlaybackStateChangeData_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_onPlaybackStateChangeData_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_onPlaybackStateChangeData_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref data) { + _func(data->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onPlaybackStateChangeData_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_onPlaybackStateChangeData_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_onPlaybackStateChangeData_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onProgressData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onProgressData.hpp new file mode 100644 index 00000000..335cc2ce --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_onProgressData.hpp @@ -0,0 +1,76 @@ +/// +/// JFunc_void_onProgressData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "onProgressData.hpp" +#include "JonProgressData.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(data: onProgressData) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_onProgressData: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onProgressData;"; + + public: + /** + * Invokes the function this `JFunc_void_onProgressData` instance holds through JNI. + */ + void invoke(const onProgressData& data) const { + static const auto method = javaClassStatic()->getMethod /* data */)>("invoke"); + method(self(), JonProgressData::fromCpp(data)); + } + }; + + /** + * An implementation of Func_void_onProgressData that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_onProgressData_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_onProgressData_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_onProgressData_cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref data) { + _func(data->toCpp()); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_onProgressData_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_onProgressData_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_onProgressData_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp new file mode 100644 index 00000000..6c6853c3 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp @@ -0,0 +1,93 @@ +/// +/// JFunc_void_std__vector_std__string_.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `(texts: Array) -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void_std__vector_std__string_: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_std__vector_std__string_;"; + + public: + /** + * Invokes the function this `JFunc_void_std__vector_std__string_` instance holds through JNI. + */ + void invoke(const std::vector& texts) const { + static const auto method = javaClassStatic()->getMethod> /* texts */)>("invoke"); + method(self(), [&]() { + size_t __size = texts.size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = texts[__i]; + __array->setElement(__i, *jni::make_jstring(__element)); + } + return __array; + }()); + } + }; + + /** + * An implementation of Func_void_std__vector_std__string_ that is backed by a C++ implementation (using `std::function<...>`) + */ + struct JFunc_void_std__vector_std__string__cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& /* texts */)>& func) { + return JFunc_void_std__vector_std__string__cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_std__vector_std__string__cxx` instance holds. + */ + void invoke_cxx(jni::alias_ref> texts) { + _func([&]() { + size_t __size = texts->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = texts->getElement(__i); + __vector.push_back(__element->toStdString()); + } + return __vector; + }()); + } + + public: + [[nodiscard]] + inline const std::function& /* texts */)>& getFunction() const { + return _func; + } + + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_std__vector_std__string__cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_std__string__cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_std__vector_std__string__cxx(const std::function& /* texts */)>& func): _func(func) { } + + private: + friend HybridBase; + std::function& /* texts */)> _func; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.cpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.cpp new file mode 100644 index 00000000..d8fb13c7 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.cpp @@ -0,0 +1,419 @@ +/// +/// JHybridVideoPlayerEventEmitterSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#include "JHybridVideoPlayerEventEmitterSpec.hpp" + +// Forward declaration of `BandwidthData` to properly resolve imports. +namespace margelo::nitro::video { struct BandwidthData; } +// Forward declaration of `onLoadData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadData; } +// Forward declaration of `VideoOrientation` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoOrientation; } +// Forward declaration of `onLoadStartData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadStartData; } +// Forward declaration of `SourceType` to properly resolve imports. +namespace margelo::nitro::video { enum class SourceType; } +// Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `onPlaybackStateChangeData` to properly resolve imports. +namespace margelo::nitro::video { struct onPlaybackStateChangeData; } +// Forward declaration of `onProgressData` to properly resolve imports. +namespace margelo::nitro::video { struct onProgressData; } +// Forward declaration of `TimedMetadata` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadata; } +// Forward declaration of `TimedMetadataObject` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadataObject; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } + +#include +#include "JFunc_void.hpp" +#include "JFunc_void_bool.hpp" +#include "BandwidthData.hpp" +#include "JFunc_void_BandwidthData.hpp" +#include "JBandwidthData.hpp" +#include +#include "onLoadData.hpp" +#include "JFunc_void_onLoadData.hpp" +#include "JonLoadData.hpp" +#include "VideoOrientation.hpp" +#include "JVideoOrientation.hpp" +#include "onLoadStartData.hpp" +#include "JFunc_void_onLoadStartData.hpp" +#include "JonLoadStartData.hpp" +#include "SourceType.hpp" +#include "JSourceType.hpp" +#include +#include "HybridVideoPlayerSourceSpec.hpp" +#include "JHybridVideoPlayerSourceSpec.hpp" +#include +#include "onPlaybackStateChangeData.hpp" +#include "JFunc_void_onPlaybackStateChangeData.hpp" +#include "JonPlaybackStateChangeData.hpp" +#include "JFunc_void_double.hpp" +#include "onProgressData.hpp" +#include "JFunc_void_onProgressData.hpp" +#include "JonProgressData.hpp" +#include "TimedMetadata.hpp" +#include "JFunc_void_TimedMetadata.hpp" +#include "JTimedMetadata.hpp" +#include +#include "TimedMetadataObject.hpp" +#include "JTimedMetadataObject.hpp" +#include +#include "JFunc_void_std__vector_std__string_.hpp" +#include "VideoPlayerStatus.hpp" +#include "JFunc_void_VideoPlayerStatus.hpp" +#include "JVideoPlayerStatus.hpp" + +namespace margelo::nitro::video { + + jni::local_ref JHybridVideoPlayerEventEmitterSpec::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + void JHybridVideoPlayerEventEmitterSpec::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridVideoPlayerEventEmitterSpec::initHybrid), + }); + } + + size_t JHybridVideoPlayerEventEmitterSpec::getExternalMemorySize() noexcept { + static const auto method = javaClassStatic()->getMethod("getMemorySize"); + return method(_javaPart); + } + + // Properties + std::function JHybridVideoPlayerEventEmitterSpec::getOnAudioBecomingNoisy() { + static const auto method = javaClassStatic()->getMethod()>("getOnAudioBecomingNoisy_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnAudioBecomingNoisy(const std::function& onAudioBecomingNoisy) { + static const auto method = javaClassStatic()->getMethod /* onAudioBecomingNoisy */)>("setOnAudioBecomingNoisy_cxx"); + method(_javaPart, JFunc_void_cxx::fromCpp(onAudioBecomingNoisy)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnAudioFocusChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnAudioFocusChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](bool hasAudioFocus) -> void { + return __result->invoke(hasAudioFocus); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnAudioFocusChange(const std::function& onAudioFocusChange) { + static const auto method = javaClassStatic()->getMethod /* onAudioFocusChange */)>("setOnAudioFocusChange_cxx"); + method(_javaPart, JFunc_void_bool_cxx::fromCpp(onAudioFocusChange)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnBandwidthUpdate() { + static const auto method = javaClassStatic()->getMethod()>("getOnBandwidthUpdate_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_BandwidthData_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](BandwidthData data) -> void { + return __result->invoke(data); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnBandwidthUpdate(const std::function& onBandwidthUpdate) { + static const auto method = javaClassStatic()->getMethod /* onBandwidthUpdate */)>("setOnBandwidthUpdate_cxx"); + method(_javaPart, JFunc_void_BandwidthData_cxx::fromCpp(onBandwidthUpdate)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnBuffer() { + static const auto method = javaClassStatic()->getMethod()>("getOnBuffer_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](bool buffering) -> void { + return __result->invoke(buffering); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnBuffer(const std::function& onBuffer) { + static const auto method = javaClassStatic()->getMethod /* onBuffer */)>("setOnBuffer_cxx"); + method(_javaPart, JFunc_void_bool_cxx::fromCpp(onBuffer)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnControlsVisibleChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnControlsVisibleChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](bool visible) -> void { + return __result->invoke(visible); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnControlsVisibleChange(const std::function& onControlsVisibleChange) { + static const auto method = javaClassStatic()->getMethod /* onControlsVisibleChange */)>("setOnControlsVisibleChange_cxx"); + method(_javaPart, JFunc_void_bool_cxx::fromCpp(onControlsVisibleChange)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnEnd() { + static const auto method = javaClassStatic()->getMethod()>("getOnEnd_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnEnd(const std::function& onEnd) { + static const auto method = javaClassStatic()->getMethod /* onEnd */)>("setOnEnd_cxx"); + method(_javaPart, JFunc_void_cxx::fromCpp(onEnd)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnExternalPlaybackChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnExternalPlaybackChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](bool externalPlaybackActive) -> void { + return __result->invoke(externalPlaybackActive); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnExternalPlaybackChange(const std::function& onExternalPlaybackChange) { + static const auto method = javaClassStatic()->getMethod /* onExternalPlaybackChange */)>("setOnExternalPlaybackChange_cxx"); + method(_javaPart, JFunc_void_bool_cxx::fromCpp(onExternalPlaybackChange)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnLoad() { + static const auto method = javaClassStatic()->getMethod()>("getOnLoad_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_onLoadData_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](onLoadData data) -> void { + return __result->invoke(data); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnLoad(const std::function& onLoad) { + static const auto method = javaClassStatic()->getMethod /* onLoad */)>("setOnLoad_cxx"); + method(_javaPart, JFunc_void_onLoadData_cxx::fromCpp(onLoad)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnLoadStart() { + static const auto method = javaClassStatic()->getMethod()>("getOnLoadStart_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_onLoadStartData_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](onLoadStartData data) -> void { + return __result->invoke(data); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnLoadStart(const std::function& onLoadStart) { + static const auto method = javaClassStatic()->getMethod /* onLoadStart */)>("setOnLoadStart_cxx"); + method(_javaPart, JFunc_void_onLoadStartData_cxx::fromCpp(onLoadStart)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnPlaybackStateChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnPlaybackStateChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_onPlaybackStateChangeData_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](onPlaybackStateChangeData data) -> void { + return __result->invoke(data); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnPlaybackStateChange(const std::function& onPlaybackStateChange) { + static const auto method = javaClassStatic()->getMethod /* onPlaybackStateChange */)>("setOnPlaybackStateChange_cxx"); + method(_javaPart, JFunc_void_onPlaybackStateChangeData_cxx::fromCpp(onPlaybackStateChange)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnPlaybackRateChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnPlaybackRateChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](double rate) -> void { + return __result->invoke(rate); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnPlaybackRateChange(const std::function& onPlaybackRateChange) { + static const auto method = javaClassStatic()->getMethod /* onPlaybackRateChange */)>("setOnPlaybackRateChange_cxx"); + method(_javaPart, JFunc_void_double_cxx::fromCpp(onPlaybackRateChange)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnProgress() { + static const auto method = javaClassStatic()->getMethod()>("getOnProgress_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_onProgressData_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](onProgressData data) -> void { + return __result->invoke(data); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnProgress(const std::function& onProgress) { + static const auto method = javaClassStatic()->getMethod /* onProgress */)>("setOnProgress_cxx"); + method(_javaPart, JFunc_void_onProgressData_cxx::fromCpp(onProgress)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnReadyToDisplay() { + static const auto method = javaClassStatic()->getMethod()>("getOnReadyToDisplay_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnReadyToDisplay(const std::function& onReadyToDisplay) { + static const auto method = javaClassStatic()->getMethod /* onReadyToDisplay */)>("setOnReadyToDisplay_cxx"); + method(_javaPart, JFunc_void_cxx::fromCpp(onReadyToDisplay)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnSeek() { + static const auto method = javaClassStatic()->getMethod()>("getOnSeek_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](double seekTime) -> void { + return __result->invoke(seekTime); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnSeek(const std::function& onSeek) { + static const auto method = javaClassStatic()->getMethod /* onSeek */)>("setOnSeek_cxx"); + method(_javaPart, JFunc_void_double_cxx::fromCpp(onSeek)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnTimedMetadata() { + static const auto method = javaClassStatic()->getMethod()>("getOnTimedMetadata_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_TimedMetadata_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](TimedMetadata metadata) -> void { + return __result->invoke(metadata); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnTimedMetadata(const std::function& onTimedMetadata) { + static const auto method = javaClassStatic()->getMethod /* onTimedMetadata */)>("setOnTimedMetadata_cxx"); + method(_javaPart, JFunc_void_TimedMetadata_cxx::fromCpp(onTimedMetadata)); + } + std::function& /* texts */)> JHybridVideoPlayerEventEmitterSpec::getOnTextTrackDataChanged() { + static const auto method = javaClassStatic()->getMethod()>("getOnTextTrackDataChanged_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function& /* texts */)> { + if (__result->isInstanceOf(JFunc_void_std__vector_std__string__cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](std::vector texts) -> void { + return __result->invoke(texts); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnTextTrackDataChanged(const std::function& /* texts */)>& onTextTrackDataChanged) { + static const auto method = javaClassStatic()->getMethod /* onTextTrackDataChanged */)>("setOnTextTrackDataChanged_cxx"); + method(_javaPart, JFunc_void_std__vector_std__string__cxx::fromCpp(onTextTrackDataChanged)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnVolumeChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnVolumeChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](double volume) -> void { + return __result->invoke(volume); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnVolumeChange(const std::function& onVolumeChange) { + static const auto method = javaClassStatic()->getMethod /* onVolumeChange */)>("setOnVolumeChange_cxx"); + method(_javaPart, JFunc_void_double_cxx::fromCpp(onVolumeChange)); + } + std::function JHybridVideoPlayerEventEmitterSpec::getOnStatusChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnStatusChange_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_VideoPlayerStatus_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](VideoPlayerStatus status) -> void { + return __result->invoke(status); + }; + } + }(); + } + void JHybridVideoPlayerEventEmitterSpec::setOnStatusChange(const std::function& onStatusChange) { + static const auto method = javaClassStatic()->getMethod /* onStatusChange */)>("setOnStatusChange_cxx"); + method(_javaPart, JFunc_void_VideoPlayerStatus_cxx::fromCpp(onStatusChange)); + } + + // Methods + + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.hpp new file mode 100644 index 00000000..61fb6aa9 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerEventEmitterSpec.hpp @@ -0,0 +1,97 @@ +/// +/// HybridVideoPlayerEventEmitterSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "HybridVideoPlayerEventEmitterSpec.hpp" + + + + +namespace margelo::nitro::video { + + using namespace facebook; + + class JHybridVideoPlayerEventEmitterSpec: public jni::HybridClass, + public virtual HybridVideoPlayerEventEmitterSpec { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/HybridVideoPlayerEventEmitterSpec;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + + protected: + // C++ constructor (called from Java via `initHybrid()`) + explicit JHybridVideoPlayerEventEmitterSpec(jni::alias_ref jThis) : + HybridObject(HybridVideoPlayerEventEmitterSpec::TAG), + _javaPart(jni::make_global(jThis)) {} + + public: + ~JHybridVideoPlayerEventEmitterSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + size_t getExternalMemorySize() noexcept override; + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + std::function getOnAudioBecomingNoisy() override; + void setOnAudioBecomingNoisy(const std::function& onAudioBecomingNoisy) override; + std::function getOnAudioFocusChange() override; + void setOnAudioFocusChange(const std::function& onAudioFocusChange) override; + std::function getOnBandwidthUpdate() override; + void setOnBandwidthUpdate(const std::function& onBandwidthUpdate) override; + std::function getOnBuffer() override; + void setOnBuffer(const std::function& onBuffer) override; + std::function getOnControlsVisibleChange() override; + void setOnControlsVisibleChange(const std::function& onControlsVisibleChange) override; + std::function getOnEnd() override; + void setOnEnd(const std::function& onEnd) override; + std::function getOnExternalPlaybackChange() override; + void setOnExternalPlaybackChange(const std::function& onExternalPlaybackChange) override; + std::function getOnLoad() override; + void setOnLoad(const std::function& onLoad) override; + std::function getOnLoadStart() override; + void setOnLoadStart(const std::function& onLoadStart) override; + std::function getOnPlaybackStateChange() override; + void setOnPlaybackStateChange(const std::function& onPlaybackStateChange) override; + std::function getOnPlaybackRateChange() override; + void setOnPlaybackRateChange(const std::function& onPlaybackRateChange) override; + std::function getOnProgress() override; + void setOnProgress(const std::function& onProgress) override; + std::function getOnReadyToDisplay() override; + void setOnReadyToDisplay(const std::function& onReadyToDisplay) override; + std::function getOnSeek() override; + void setOnSeek(const std::function& onSeek) override; + std::function getOnTimedMetadata() override; + void setOnTimedMetadata(const std::function& onTimedMetadata) override; + std::function& /* texts */)> getOnTextTrackDataChanged() override; + void setOnTextTrackDataChanged(const std::function& /* texts */)>& onTextTrackDataChanged) override; + std::function getOnVolumeChange() override; + void setOnVolumeChange(const std::function& onVolumeChange) override; + std::function getOnStatusChange() override; + void setOnStatusChange(const std::function& onStatusChange) override; + + public: + // Methods + + + private: + friend HybridBase; + using HybridBase::HybridBase; + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.cpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.cpp index 888756c6..171e338e 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.cpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.cpp @@ -9,12 +9,23 @@ // Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } #include #include "HybridVideoPlayerSourceSpec.hpp" #include "JHybridVideoPlayerSourceSpec.hpp" #include #include +#include "NativeVideoConfig.hpp" +#include "JNativeVideoConfig.hpp" +#include +#include +#include +#include "ExternalSubtitle.hpp" +#include "JExternalSubtitle.hpp" namespace margelo::nitro::video { @@ -42,5 +53,10 @@ namespace margelo::nitro::video { auto __result = method(_javaPart, jni::make_jstring(uri)); return JNISharedPtr::make_shared_from_jni(jni::make_global(__result)); } + std::shared_ptr JHybridVideoPlayerSourceFactorySpec::fromVideoConfig(const NativeVideoConfig& config) { + static const auto method = javaClassStatic()->getMethod(jni::alias_ref /* config */)>("fromVideoConfig"); + auto __result = method(_javaPart, JNativeVideoConfig::fromCpp(config)); + return JNISharedPtr::make_shared_from_jni(jni::make_global(__result)); + } } // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.hpp index 47bfdb79..11177b85 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.hpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceFactorySpec.hpp @@ -52,6 +52,7 @@ namespace margelo::nitro::video { public: // Methods std::shared_ptr fromUri(const std::string& uri) override; + std::shared_ptr fromVideoConfig(const NativeVideoConfig& config) override; private: friend HybridBase; diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.cpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.cpp index a88176a8..36dee035 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.cpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.cpp @@ -7,12 +7,23 @@ #include "JHybridVideoPlayerSourceSpec.hpp" +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } // Forward declaration of `VideoInformation` to properly resolve imports. namespace margelo::nitro::video { struct VideoInformation; } // Forward declaration of `VideoOrientation` to properly resolve imports. namespace margelo::nitro::video { enum class VideoOrientation; } #include +#include "NativeVideoConfig.hpp" +#include "JNativeVideoConfig.hpp" +#include +#include +#include +#include "ExternalSubtitle.hpp" +#include "JExternalSubtitle.hpp" #include #include "VideoInformation.hpp" #include @@ -43,6 +54,11 @@ namespace margelo::nitro::video { auto __result = method(_javaPart); return __result->toStdString(); } + NativeVideoConfig JHybridVideoPlayerSourceSpec::getConfig() { + static const auto method = javaClassStatic()->getMethod()>("getConfig"); + auto __result = method(_javaPart); + return __result->toCpp(); + } // Methods std::shared_ptr> JHybridVideoPlayerSourceSpec::getAssetInformationAsync() { diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.hpp index a881748a..f4291631 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.hpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSourceSpec.hpp @@ -48,6 +48,7 @@ namespace margelo::nitro::video { public: // Properties std::string getUri() override; + NativeVideoConfig getConfig() override; public: // Methods diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.cpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.cpp index 9e5c9129..c4102156 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.cpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.cpp @@ -9,11 +9,19 @@ // Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `HybridVideoPlayerEventEmitterSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerEventEmitterSpec; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } #include #include "HybridVideoPlayerSourceSpec.hpp" #include "JHybridVideoPlayerSourceSpec.hpp" #include +#include "HybridVideoPlayerEventEmitterSpec.hpp" +#include "JHybridVideoPlayerEventEmitterSpec.hpp" +#include "VideoPlayerStatus.hpp" +#include "JVideoPlayerStatus.hpp" #include #include @@ -40,6 +48,16 @@ namespace margelo::nitro::video { auto __result = method(_javaPart); return JNISharedPtr::make_shared_from_jni(jni::make_global(__result)); } + std::shared_ptr JHybridVideoPlayerSpec::getEventEmitter() { + static const auto method = javaClassStatic()->getMethod()>("getEventEmitter"); + auto __result = method(_javaPart); + return JNISharedPtr::make_shared_from_jni(jni::make_global(__result)); + } + VideoPlayerStatus JHybridVideoPlayerSpec::getStatus() { + static const auto method = javaClassStatic()->getMethod()>("getStatus"); + auto __result = method(_javaPart); + return __result->toCpp(); + } double JHybridVideoPlayerSpec::getDuration() { static const auto method = javaClassStatic()->getMethod("getDuration"); auto __result = method(_javaPart); diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.hpp index 9b1a38b3..23617180 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.hpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoPlayerSpec.hpp @@ -48,6 +48,8 @@ namespace margelo::nitro::video { public: // Properties std::shared_ptr getSource() override; + std::shared_ptr getEventEmitter() override; + VideoPlayerStatus getStatus() override; double getDuration() override; double getVolume() override; void setVolume(double volume) override; diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.cpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.cpp index 1d2d7f88..5d71a9e0 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.cpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.cpp @@ -15,6 +15,9 @@ namespace margelo::nitro::video { class HybridVideoPlayerSpec; } #include "HybridVideoPlayerSpec.hpp" #include "JHybridVideoPlayerSpec.hpp" #include +#include +#include "JFunc_void_bool.hpp" +#include "JFunc_void.hpp" namespace margelo::nitro::video { @@ -70,6 +73,114 @@ namespace margelo::nitro::video { static const auto method = javaClassStatic()->getMethod("setAutoEnterPictureInPicture"); method(_javaPart, autoEnterPictureInPicture); } + std::optional> JHybridVideoViewViewManagerSpec::getOnPictureInPictureChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnPictureInPictureChange_cxx"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](bool isInPictureInPicture) -> void { + return __result->invoke(isInPictureInPicture); + }; + } + }()) : std::nullopt; + } + void JHybridVideoViewViewManagerSpec::setOnPictureInPictureChange(const std::optional>& onPictureInPictureChange) { + static const auto method = javaClassStatic()->getMethod /* onPictureInPictureChange */)>("setOnPictureInPictureChange_cxx"); + method(_javaPart, onPictureInPictureChange.has_value() ? JFunc_void_bool_cxx::fromCpp(onPictureInPictureChange.value()) : nullptr); + } + std::optional> JHybridVideoViewViewManagerSpec::getOnFullscreenChange() { + static const auto method = javaClassStatic()->getMethod()>("getOnFullscreenChange_cxx"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result](bool fullscreen) -> void { + return __result->invoke(fullscreen); + }; + } + }()) : std::nullopt; + } + void JHybridVideoViewViewManagerSpec::setOnFullscreenChange(const std::optional>& onFullscreenChange) { + static const auto method = javaClassStatic()->getMethod /* onFullscreenChange */)>("setOnFullscreenChange_cxx"); + method(_javaPart, onFullscreenChange.has_value() ? JFunc_void_bool_cxx::fromCpp(onFullscreenChange.value()) : nullptr); + } + std::optional> JHybridVideoViewViewManagerSpec::getWillEnterFullscreen() { + static const auto method = javaClassStatic()->getMethod()>("getWillEnterFullscreen_cxx"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }()) : std::nullopt; + } + void JHybridVideoViewViewManagerSpec::setWillEnterFullscreen(const std::optional>& willEnterFullscreen) { + static const auto method = javaClassStatic()->getMethod /* willEnterFullscreen */)>("setWillEnterFullscreen_cxx"); + method(_javaPart, willEnterFullscreen.has_value() ? JFunc_void_cxx::fromCpp(willEnterFullscreen.value()) : nullptr); + } + std::optional> JHybridVideoViewViewManagerSpec::getWillExitFullscreen() { + static const auto method = javaClassStatic()->getMethod()>("getWillExitFullscreen_cxx"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }()) : std::nullopt; + } + void JHybridVideoViewViewManagerSpec::setWillExitFullscreen(const std::optional>& willExitFullscreen) { + static const auto method = javaClassStatic()->getMethod /* willExitFullscreen */)>("setWillExitFullscreen_cxx"); + method(_javaPart, willExitFullscreen.has_value() ? JFunc_void_cxx::fromCpp(willExitFullscreen.value()) : nullptr); + } + std::optional> JHybridVideoViewViewManagerSpec::getWillEnterPictureInPicture() { + static const auto method = javaClassStatic()->getMethod()>("getWillEnterPictureInPicture_cxx"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }()) : std::nullopt; + } + void JHybridVideoViewViewManagerSpec::setWillEnterPictureInPicture(const std::optional>& willEnterPictureInPicture) { + static const auto method = javaClassStatic()->getMethod /* willEnterPictureInPicture */)>("setWillEnterPictureInPicture_cxx"); + method(_javaPart, willEnterPictureInPicture.has_value() ? JFunc_void_cxx::fromCpp(willEnterPictureInPicture.value()) : nullptr); + } + std::optional> JHybridVideoViewViewManagerSpec::getWillExitPictureInPicture() { + static const auto method = javaClassStatic()->getMethod()>("getWillExitPictureInPicture_cxx"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional([&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + return [__result]() -> void { + return __result->invoke(); + }; + } + }()) : std::nullopt; + } + void JHybridVideoViewViewManagerSpec::setWillExitPictureInPicture(const std::optional>& willExitPictureInPicture) { + static const auto method = javaClassStatic()->getMethod /* willExitPictureInPicture */)>("setWillExitPictureInPicture_cxx"); + method(_javaPart, willExitPictureInPicture.has_value() ? JFunc_void_cxx::fromCpp(willExitPictureInPicture.value()) : nullptr); + } // Methods void JHybridVideoViewViewManagerSpec::enterFullscreen() { diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.hpp index ef27f780..70746841 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.hpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JHybridVideoViewViewManagerSpec.hpp @@ -55,6 +55,18 @@ namespace margelo::nitro::video { void setPictureInPicture(bool pictureInPicture) override; bool getAutoEnterPictureInPicture() override; void setAutoEnterPictureInPicture(bool autoEnterPictureInPicture) override; + std::optional> getOnPictureInPictureChange() override; + void setOnPictureInPictureChange(const std::optional>& onPictureInPictureChange) override; + std::optional> getOnFullscreenChange() override; + void setOnFullscreenChange(const std::optional>& onFullscreenChange) override; + std::optional> getWillEnterFullscreen() override; + void setWillEnterFullscreen(const std::optional>& willEnterFullscreen) override; + std::optional> getWillExitFullscreen() override; + void setWillExitFullscreen(const std::optional>& willExitFullscreen) override; + std::optional> getWillEnterPictureInPicture() override; + void setWillEnterPictureInPicture(const std::optional>& willEnterPictureInPicture) override; + std::optional> getWillExitPictureInPicture() override; + void setWillExitPictureInPicture(const std::optional>& willExitPictureInPicture) override; public: // Methods diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JNativeVideoConfig.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JNativeVideoConfig.hpp new file mode 100644 index 00000000..1e96dab2 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JNativeVideoConfig.hpp @@ -0,0 +1,96 @@ +/// +/// JNativeVideoConfig.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "NativeVideoConfig.hpp" + +#include "ExternalSubtitle.hpp" +#include "JExternalSubtitle.hpp" +#include +#include +#include +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "NativeVideoConfig" and the the Kotlin data class "NativeVideoConfig". + */ + struct JNativeVideoConfig final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/NativeVideoConfig;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct NativeVideoConfig by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + NativeVideoConfig toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldUri = clazz->getField("uri"); + jni::local_ref uri = this->getFieldValue(fieldUri); + static const auto fieldHeaders = clazz->getField>("headers"); + jni::local_ref> headers = this->getFieldValue(fieldHeaders); + static const auto fieldExternalSubtitles = clazz->getField>("externalSubtitles"); + jni::local_ref> externalSubtitles = this->getFieldValue(fieldExternalSubtitles); + return NativeVideoConfig( + uri->toStdString(), + headers != nullptr ? std::make_optional([&]() { + std::unordered_map __map; + __map.reserve(headers->size()); + for (const auto& __entry : *headers) { + __map.emplace(__entry.first->toStdString(), __entry.second->toStdString()); + } + return __map; + }()) : std::nullopt, + externalSubtitles != nullptr ? std::make_optional([&]() { + size_t __size = externalSubtitles->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = externalSubtitles->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }()) : std::nullopt + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const NativeVideoConfig& value) { + return newInstance( + jni::make_jstring(value.uri), + value.headers.has_value() ? [&]() -> jni::local_ref> { + auto __map = jni::JHashMap::create(value.headers.value().size()); + for (const auto& __entry : value.headers.value()) { + __map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second)); + } + return __map; + }() : nullptr, + value.externalSubtitles.has_value() ? [&]() { + size_t __size = value.externalSubtitles.value().size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = value.externalSubtitles.value()[__i]; + __array->setElement(__i, *JExternalSubtitle::fromCpp(__element)); + } + return __array; + }() : nullptr + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JSourceType.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JSourceType.hpp new file mode 100644 index 00000000..0a8bb228 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JSourceType.hpp @@ -0,0 +1,59 @@ +/// +/// JSourceType.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "SourceType.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ enum "SourceType" and the the Kotlin enum "SourceType". + */ + struct JSourceType final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/SourceType;"; + + public: + /** + * Convert this Java/Kotlin-based enum to the C++ enum SourceType. + */ + [[maybe_unused]] + [[nodiscard]] + SourceType toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldOrdinal = clazz->getField("_ordinal"); + int ordinal = this->getFieldValue(fieldOrdinal); + return static_cast(ordinal); + } + + public: + /** + * Create a Java/Kotlin-based enum with the given C++ enum's value. + */ + [[maybe_unused]] + static jni::alias_ref fromCpp(SourceType value) { + static const auto clazz = javaClassStatic(); + static const auto fieldLOCAL = clazz->getStaticField("LOCAL"); + static const auto fieldNETWORK = clazz->getStaticField("NETWORK"); + + switch (value) { + case SourceType::LOCAL: + return clazz->getStaticFieldValue(fieldLOCAL); + case SourceType::NETWORK: + return clazz->getStaticFieldValue(fieldNETWORK); + default: + std::string stringValue = std::to_string(static_cast(value)); + throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); + } + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadata.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadata.hpp new file mode 100644 index 00000000..a0e4ae48 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadata.hpp @@ -0,0 +1,73 @@ +/// +/// JTimedMetadata.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "TimedMetadata.hpp" + +#include "JTimedMetadataObject.hpp" +#include "TimedMetadataObject.hpp" +#include +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "TimedMetadata" and the the Kotlin data class "TimedMetadata". + */ + struct JTimedMetadata final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/TimedMetadata;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct TimedMetadata by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + TimedMetadata toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldMetadata = clazz->getField>("metadata"); + jni::local_ref> metadata = this->getFieldValue(fieldMetadata); + return TimedMetadata( + [&]() { + size_t __size = metadata->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = metadata->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }() + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const TimedMetadata& value) { + return newInstance( + [&]() { + size_t __size = value.metadata.size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = value.metadata[__i]; + __array->setElement(__i, *JTimedMetadataObject::fromCpp(__element)); + } + return __array; + }() + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadataObject.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadataObject.hpp new file mode 100644 index 00000000..59e72c03 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JTimedMetadataObject.hpp @@ -0,0 +1,57 @@ +/// +/// JTimedMetadataObject.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "TimedMetadataObject.hpp" + +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "TimedMetadataObject" and the the Kotlin data class "TimedMetadataObject". + */ + struct JTimedMetadataObject final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/TimedMetadataObject;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct TimedMetadataObject by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + TimedMetadataObject toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldValue = clazz->getField("value"); + jni::local_ref value = this->getFieldValue(fieldValue); + static const auto fieldIdentifier = clazz->getField("identifier"); + jni::local_ref identifier = this->getFieldValue(fieldIdentifier); + return TimedMetadataObject( + value->toStdString(), + identifier->toStdString() + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const TimedMetadataObject& value) { + return newInstance( + jni::make_jstring(value.value), + jni::make_jstring(value.identifier) + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JVideoOrientation.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JVideoOrientation.hpp index 96fd8499..2d23b1ed 100644 --- a/packages/react-native-video/nitrogen/generated/android/c++/JVideoOrientation.hpp +++ b/packages/react-native-video/nitrogen/generated/android/c++/JVideoOrientation.hpp @@ -46,6 +46,7 @@ namespace margelo::nitro::video { static const auto fieldPORTRAIT_UPSIDE_DOWN = clazz->getStaticField("PORTRAIT_UPSIDE_DOWN"); static const auto fieldLANDSCAPE_LEFT = clazz->getStaticField("LANDSCAPE_LEFT"); static const auto fieldLANDSCAPE_RIGHT = clazz->getStaticField("LANDSCAPE_RIGHT"); + static const auto fieldSQUARE = clazz->getStaticField("SQUARE"); static const auto fieldUNKNOWN = clazz->getStaticField("UNKNOWN"); switch (value) { @@ -59,6 +60,8 @@ namespace margelo::nitro::video { return clazz->getStaticFieldValue(fieldLANDSCAPE_LEFT); case VideoOrientation::LANDSCAPE_RIGHT: return clazz->getStaticFieldValue(fieldLANDSCAPE_RIGHT); + case VideoOrientation::SQUARE: + return clazz->getStaticFieldValue(fieldSQUARE); case VideoOrientation::UNKNOWN: return clazz->getStaticFieldValue(fieldUNKNOWN); default: diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JVideoPlayerStatus.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JVideoPlayerStatus.hpp new file mode 100644 index 00000000..f68a6d8c --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JVideoPlayerStatus.hpp @@ -0,0 +1,65 @@ +/// +/// JVideoPlayerStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "VideoPlayerStatus.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ enum "VideoPlayerStatus" and the the Kotlin enum "VideoPlayerStatus". + */ + struct JVideoPlayerStatus final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/VideoPlayerStatus;"; + + public: + /** + * Convert this Java/Kotlin-based enum to the C++ enum VideoPlayerStatus. + */ + [[maybe_unused]] + [[nodiscard]] + VideoPlayerStatus toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldOrdinal = clazz->getField("_ordinal"); + int ordinal = this->getFieldValue(fieldOrdinal); + return static_cast(ordinal); + } + + public: + /** + * Create a Java/Kotlin-based enum with the given C++ enum's value. + */ + [[maybe_unused]] + static jni::alias_ref fromCpp(VideoPlayerStatus value) { + static const auto clazz = javaClassStatic(); + static const auto fieldIDLE = clazz->getStaticField("IDLE"); + static const auto fieldLOADING = clazz->getStaticField("LOADING"); + static const auto fieldREADYTOPLAY = clazz->getStaticField("READYTOPLAY"); + static const auto fieldERROR = clazz->getStaticField("ERROR"); + + switch (value) { + case VideoPlayerStatus::IDLE: + return clazz->getStaticFieldValue(fieldIDLE); + case VideoPlayerStatus::LOADING: + return clazz->getStaticFieldValue(fieldLOADING); + case VideoPlayerStatus::READYTOPLAY: + return clazz->getStaticFieldValue(fieldREADYTOPLAY); + case VideoPlayerStatus::ERROR: + return clazz->getStaticFieldValue(fieldERROR); + default: + std::string stringValue = std::to_string(static_cast(value)); + throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); + } + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JonLoadData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JonLoadData.hpp new file mode 100644 index 00000000..123cbfbc --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JonLoadData.hpp @@ -0,0 +1,70 @@ +/// +/// JonLoadData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "onLoadData.hpp" + +#include "JVideoOrientation.hpp" +#include "VideoOrientation.hpp" + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "onLoadData" and the the Kotlin data class "onLoadData". + */ + struct JonLoadData final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/onLoadData;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct onLoadData by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + onLoadData toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldCurrentTime = clazz->getField("currentTime"); + double currentTime = this->getFieldValue(fieldCurrentTime); + static const auto fieldDuration = clazz->getField("duration"); + double duration = this->getFieldValue(fieldDuration); + static const auto fieldHeight = clazz->getField("height"); + double height = this->getFieldValue(fieldHeight); + static const auto fieldWidth = clazz->getField("width"); + double width = this->getFieldValue(fieldWidth); + static const auto fieldOrientation = clazz->getField("orientation"); + jni::local_ref orientation = this->getFieldValue(fieldOrientation); + return onLoadData( + currentTime, + duration, + height, + width, + orientation->toCpp() + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const onLoadData& value) { + return newInstance( + value.currentTime, + value.duration, + value.height, + value.width, + JVideoOrientation::fromCpp(value.orientation) + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JonLoadStartData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JonLoadStartData.hpp new file mode 100644 index 00000000..c3dae850 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JonLoadStartData.hpp @@ -0,0 +1,62 @@ +/// +/// JonLoadStartData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "onLoadStartData.hpp" + +#include "HybridVideoPlayerSourceSpec.hpp" +#include "JHybridVideoPlayerSourceSpec.hpp" +#include "JSourceType.hpp" +#include "SourceType.hpp" +#include +#include + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "onLoadStartData" and the the Kotlin data class "onLoadStartData". + */ + struct JonLoadStartData final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/onLoadStartData;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct onLoadStartData by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + onLoadStartData toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldSourceType = clazz->getField("sourceType"); + jni::local_ref sourceType = this->getFieldValue(fieldSourceType); + static const auto fieldSource = clazz->getField("source"); + jni::local_ref source = this->getFieldValue(fieldSource); + return onLoadStartData( + sourceType->toCpp(), + JNISharedPtr::make_shared_from_jni(jni::make_global(source)) + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const onLoadStartData& value) { + return newInstance( + JSourceType::fromCpp(value.sourceType), + std::dynamic_pointer_cast(value.source)->getJavaPart() + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JonPlaybackStateChangeData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JonPlaybackStateChangeData.hpp new file mode 100644 index 00000000..85cd53d6 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JonPlaybackStateChangeData.hpp @@ -0,0 +1,57 @@ +/// +/// JonPlaybackStateChangeData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "onPlaybackStateChangeData.hpp" + + + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "onPlaybackStateChangeData" and the the Kotlin data class "onPlaybackStateChangeData". + */ + struct JonPlaybackStateChangeData final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/onPlaybackStateChangeData;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct onPlaybackStateChangeData by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + onPlaybackStateChangeData toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldIsPlaying = clazz->getField("isPlaying"); + jboolean isPlaying = this->getFieldValue(fieldIsPlaying); + static const auto fieldIsBuffering = clazz->getField("isBuffering"); + jboolean isBuffering = this->getFieldValue(fieldIsBuffering); + return onPlaybackStateChangeData( + static_cast(isPlaying), + static_cast(isBuffering) + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const onPlaybackStateChangeData& value) { + return newInstance( + value.isPlaying, + value.isBuffering + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/c++/JonProgressData.hpp b/packages/react-native-video/nitrogen/generated/android/c++/JonProgressData.hpp new file mode 100644 index 00000000..e470d9c7 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/c++/JonProgressData.hpp @@ -0,0 +1,57 @@ +/// +/// JonProgressData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "onProgressData.hpp" + + + +namespace margelo::nitro::video { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "onProgressData" and the the Kotlin data class "onProgressData". + */ + struct JonProgressData final: public jni::JavaClass { + public: + static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/onProgressData;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct onProgressData by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + onProgressData toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldCurrentTime = clazz->getField("currentTime"); + double currentTime = this->getFieldValue(fieldCurrentTime); + static const auto fieldBufferDuration = clazz->getField("bufferDuration"); + double bufferDuration = this->getFieldValue(fieldBufferDuration); + return onProgressData( + currentTime, + bufferDuration + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const onProgressData& value) { + return newInstance( + value.currentTime, + value.bufferDuration + ); + } + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/BandwidthData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/BandwidthData.kt new file mode 100644 index 00000000..15097568 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/BandwidthData.kt @@ -0,0 +1,28 @@ +/// +/// BandwidthData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "BandwidthData". + */ +@DoNotStrip +@Keep +data class BandwidthData + @DoNotStrip + @Keep + constructor( + val bitrate: Double, + val width: Double?, + val height: Double? + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/ExternalSubtitle.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/ExternalSubtitle.kt new file mode 100644 index 00000000..9c171c09 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/ExternalSubtitle.kt @@ -0,0 +1,27 @@ +/// +/// ExternalSubtitle.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "ExternalSubtitle". + */ +@DoNotStrip +@Keep +data class ExternalSubtitle + @DoNotStrip + @Keep + constructor( + val uri: String, + val label: String + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void.kt new file mode 100644 index 00000000..ffc3df62 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void.kt @@ -0,0 +1,80 @@ +/// +/// Func_void.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `() => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void: () -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Unit +} + +/** + * Represents the JavaScript callback `() => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_cxx: Func_void { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(): Unit + = invoke_cxx() + + @FastNative + private external fun invoke_cxx(): Unit +} + +/** + * Represents the JavaScript callback `() => void`. + * This is implemented in Java/Kotlin, via a `() -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_java(private val function: () -> Unit): Func_void { + @DoNotStrip + @Keep + override fun invoke(): Unit { + return this.function() + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_BandwidthData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_BandwidthData.kt new file mode 100644 index 00000000..6a995fff --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_BandwidthData.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_BandwidthData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_BandwidthData: (BandwidthData) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(data: BandwidthData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_BandwidthData_cxx: Func_void_BandwidthData { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(data: BandwidthData): Unit + = invoke_cxx(data) + + @FastNative + private external fun invoke_cxx(data: BandwidthData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in Java/Kotlin, via a `(BandwidthData) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_BandwidthData_java(private val function: (BandwidthData) -> Unit): Func_void_BandwidthData { + @DoNotStrip + @Keep + override fun invoke(data: BandwidthData): Unit { + return this.function(data) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_TimedMetadata.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_TimedMetadata.kt new file mode 100644 index 00000000..0070ef84 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_TimedMetadata.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_TimedMetadata.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(metadata: struct) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_TimedMetadata: (TimedMetadata) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(metadata: TimedMetadata): Unit +} + +/** + * Represents the JavaScript callback `(metadata: struct) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_TimedMetadata_cxx: Func_void_TimedMetadata { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(metadata: TimedMetadata): Unit + = invoke_cxx(metadata) + + @FastNative + private external fun invoke_cxx(metadata: TimedMetadata): Unit +} + +/** + * Represents the JavaScript callback `(metadata: struct) => void`. + * This is implemented in Java/Kotlin, via a `(TimedMetadata) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_TimedMetadata_java(private val function: (TimedMetadata) -> Unit): Func_void_TimedMetadata { + @DoNotStrip + @Keep + override fun invoke(metadata: TimedMetadata): Unit { + return this.function(metadata) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_VideoPlayerStatus.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_VideoPlayerStatus.kt new file mode 100644 index 00000000..d1c6a852 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_VideoPlayerStatus.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_VideoPlayerStatus.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(status: enum) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_VideoPlayerStatus: (VideoPlayerStatus) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(status: VideoPlayerStatus): Unit +} + +/** + * Represents the JavaScript callback `(status: enum) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_VideoPlayerStatus_cxx: Func_void_VideoPlayerStatus { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(status: VideoPlayerStatus): Unit + = invoke_cxx(status) + + @FastNative + private external fun invoke_cxx(status: VideoPlayerStatus): Unit +} + +/** + * Represents the JavaScript callback `(status: enum) => void`. + * This is implemented in Java/Kotlin, via a `(VideoPlayerStatus) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_VideoPlayerStatus_java(private val function: (VideoPlayerStatus) -> Unit): Func_void_VideoPlayerStatus { + @DoNotStrip + @Keep + override fun invoke(status: VideoPlayerStatus): Unit { + return this.function(status) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_bool.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_bool.kt new file mode 100644 index 00000000..01f78710 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_bool.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_bool.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(fullscreen: boolean) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_bool: (Boolean) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(fullscreen: Boolean): Unit +} + +/** + * Represents the JavaScript callback `(fullscreen: boolean) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_bool_cxx: Func_void_bool { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(fullscreen: Boolean): Unit + = invoke_cxx(fullscreen) + + @FastNative + private external fun invoke_cxx(fullscreen: Boolean): Unit +} + +/** + * Represents the JavaScript callback `(fullscreen: boolean) => void`. + * This is implemented in Java/Kotlin, via a `(Boolean) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_bool_java(private val function: (Boolean) -> Unit): Func_void_bool { + @DoNotStrip + @Keep + override fun invoke(fullscreen: Boolean): Unit { + return this.function(fullscreen) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_double.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_double.kt new file mode 100644 index 00000000..6d70fbe3 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_double.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_double.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(volume: number) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_double: (Double) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(volume: Double): Unit +} + +/** + * Represents the JavaScript callback `(volume: number) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_double_cxx: Func_void_double { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(volume: Double): Unit + = invoke_cxx(volume) + + @FastNative + private external fun invoke_cxx(volume: Double): Unit +} + +/** + * Represents the JavaScript callback `(volume: number) => void`. + * This is implemented in Java/Kotlin, via a `(Double) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_double_java(private val function: (Double) -> Unit): Func_void_double { + @DoNotStrip + @Keep + override fun invoke(volume: Double): Unit { + return this.function(volume) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadData.kt new file mode 100644 index 00000000..53d588c2 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadData.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_onLoadData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_onLoadData: (onLoadData) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(data: onLoadData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_onLoadData_cxx: Func_void_onLoadData { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(data: onLoadData): Unit + = invoke_cxx(data) + + @FastNative + private external fun invoke_cxx(data: onLoadData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in Java/Kotlin, via a `(onLoadData) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_onLoadData_java(private val function: (onLoadData) -> Unit): Func_void_onLoadData { + @DoNotStrip + @Keep + override fun invoke(data: onLoadData): Unit { + return this.function(data) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadStartData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadStartData.kt new file mode 100644 index 00000000..4b7ba28a --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onLoadStartData.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_onLoadStartData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_onLoadStartData: (onLoadStartData) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(data: onLoadStartData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_onLoadStartData_cxx: Func_void_onLoadStartData { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(data: onLoadStartData): Unit + = invoke_cxx(data) + + @FastNative + private external fun invoke_cxx(data: onLoadStartData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in Java/Kotlin, via a `(onLoadStartData) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_onLoadStartData_java(private val function: (onLoadStartData) -> Unit): Func_void_onLoadStartData { + @DoNotStrip + @Keep + override fun invoke(data: onLoadStartData): Unit { + return this.function(data) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onPlaybackStateChangeData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onPlaybackStateChangeData.kt new file mode 100644 index 00000000..dc35d7c6 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onPlaybackStateChangeData.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_onPlaybackStateChangeData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_onPlaybackStateChangeData: (onPlaybackStateChangeData) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(data: onPlaybackStateChangeData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_onPlaybackStateChangeData_cxx: Func_void_onPlaybackStateChangeData { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(data: onPlaybackStateChangeData): Unit + = invoke_cxx(data) + + @FastNative + private external fun invoke_cxx(data: onPlaybackStateChangeData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in Java/Kotlin, via a `(onPlaybackStateChangeData) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_onPlaybackStateChangeData_java(private val function: (onPlaybackStateChangeData) -> Unit): Func_void_onPlaybackStateChangeData { + @DoNotStrip + @Keep + override fun invoke(data: onPlaybackStateChangeData): Unit { + return this.function(data) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onProgressData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onProgressData.kt new file mode 100644 index 00000000..def12eb2 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_onProgressData.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_onProgressData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_onProgressData: (onProgressData) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(data: onProgressData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_onProgressData_cxx: Func_void_onProgressData { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(data: onProgressData): Unit + = invoke_cxx(data) + + @FastNative + private external fun invoke_cxx(data: onProgressData): Unit +} + +/** + * Represents the JavaScript callback `(data: struct) => void`. + * This is implemented in Java/Kotlin, via a `(onProgressData) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_onProgressData_java(private val function: (onProgressData) -> Unit): Func_void_onProgressData { + @DoNotStrip + @Keep + override fun invoke(data: onProgressData): Unit { + return this.function(data) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_std__vector_std__string_.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_std__vector_std__string_.kt new file mode 100644 index 00000000..681115d5 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/Func_void_std__vector_std__string_.kt @@ -0,0 +1,80 @@ +/// +/// Func_void_std__vector_std__string_.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* +import dalvik.annotation.optimization.FastNative + +/** + * Represents the JavaScript callback `(texts: array) => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void_std__vector_std__string_: (Array) -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(texts: Array): Unit +} + +/** + * Represents the JavaScript callback `(texts: array) => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_std__vector_std__string__cxx: Func_void_std__vector_std__string_ { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(texts: Array): Unit + = invoke_cxx(texts) + + @FastNative + private external fun invoke_cxx(texts: Array): Unit +} + +/** + * Represents the JavaScript callback `(texts: array) => void`. + * This is implemented in Java/Kotlin, via a `(Array) -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_std__vector_std__string__java(private val function: (Array) -> Unit): Func_void_std__vector_std__string_ { + @DoNotStrip + @Keep + override fun invoke(texts: Array): Unit { + return this.function(texts) + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerEventEmitterSpec.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerEventEmitterSpec.kt new file mode 100644 index 00000000..fe1bfdc2 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerEventEmitterSpec.kt @@ -0,0 +1,300 @@ +/// +/// HybridVideoPlayerEventEmitterSpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * A Kotlin class representing the VideoPlayerEventEmitter HybridObject. + * Implement this abstract class to create Kotlin-based instances of VideoPlayerEventEmitter. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridVideoPlayerEventEmitterSpec: HybridObject() { + @DoNotStrip + private var mHybridData: HybridData = initHybrid() + + init { + super.updateNative(mHybridData) + } + + override fun updateNative(hybridData: HybridData) { + mHybridData = hybridData + super.updateNative(hybridData) + } + + // Properties + abstract var onAudioBecomingNoisy: () -> Unit + + private var onAudioBecomingNoisy_cxx: Func_void + @Keep + @DoNotStrip + get() { + return Func_void_java(onAudioBecomingNoisy) + } + @Keep + @DoNotStrip + set(value) { + onAudioBecomingNoisy = value + } + + abstract var onAudioFocusChange: (hasAudioFocus: Boolean) -> Unit + + private var onAudioFocusChange_cxx: Func_void_bool + @Keep + @DoNotStrip + get() { + return Func_void_bool_java(onAudioFocusChange) + } + @Keep + @DoNotStrip + set(value) { + onAudioFocusChange = value + } + + abstract var onBandwidthUpdate: (data: BandwidthData) -> Unit + + private var onBandwidthUpdate_cxx: Func_void_BandwidthData + @Keep + @DoNotStrip + get() { + return Func_void_BandwidthData_java(onBandwidthUpdate) + } + @Keep + @DoNotStrip + set(value) { + onBandwidthUpdate = value + } + + abstract var onBuffer: (buffering: Boolean) -> Unit + + private var onBuffer_cxx: Func_void_bool + @Keep + @DoNotStrip + get() { + return Func_void_bool_java(onBuffer) + } + @Keep + @DoNotStrip + set(value) { + onBuffer = value + } + + abstract var onControlsVisibleChange: (visible: Boolean) -> Unit + + private var onControlsVisibleChange_cxx: Func_void_bool + @Keep + @DoNotStrip + get() { + return Func_void_bool_java(onControlsVisibleChange) + } + @Keep + @DoNotStrip + set(value) { + onControlsVisibleChange = value + } + + abstract var onEnd: () -> Unit + + private var onEnd_cxx: Func_void + @Keep + @DoNotStrip + get() { + return Func_void_java(onEnd) + } + @Keep + @DoNotStrip + set(value) { + onEnd = value + } + + abstract var onExternalPlaybackChange: (externalPlaybackActive: Boolean) -> Unit + + private var onExternalPlaybackChange_cxx: Func_void_bool + @Keep + @DoNotStrip + get() { + return Func_void_bool_java(onExternalPlaybackChange) + } + @Keep + @DoNotStrip + set(value) { + onExternalPlaybackChange = value + } + + abstract var onLoad: (data: onLoadData) -> Unit + + private var onLoad_cxx: Func_void_onLoadData + @Keep + @DoNotStrip + get() { + return Func_void_onLoadData_java(onLoad) + } + @Keep + @DoNotStrip + set(value) { + onLoad = value + } + + abstract var onLoadStart: (data: onLoadStartData) -> Unit + + private var onLoadStart_cxx: Func_void_onLoadStartData + @Keep + @DoNotStrip + get() { + return Func_void_onLoadStartData_java(onLoadStart) + } + @Keep + @DoNotStrip + set(value) { + onLoadStart = value + } + + abstract var onPlaybackStateChange: (data: onPlaybackStateChangeData) -> Unit + + private var onPlaybackStateChange_cxx: Func_void_onPlaybackStateChangeData + @Keep + @DoNotStrip + get() { + return Func_void_onPlaybackStateChangeData_java(onPlaybackStateChange) + } + @Keep + @DoNotStrip + set(value) { + onPlaybackStateChange = value + } + + abstract var onPlaybackRateChange: (rate: Double) -> Unit + + private var onPlaybackRateChange_cxx: Func_void_double + @Keep + @DoNotStrip + get() { + return Func_void_double_java(onPlaybackRateChange) + } + @Keep + @DoNotStrip + set(value) { + onPlaybackRateChange = value + } + + abstract var onProgress: (data: onProgressData) -> Unit + + private var onProgress_cxx: Func_void_onProgressData + @Keep + @DoNotStrip + get() { + return Func_void_onProgressData_java(onProgress) + } + @Keep + @DoNotStrip + set(value) { + onProgress = value + } + + abstract var onReadyToDisplay: () -> Unit + + private var onReadyToDisplay_cxx: Func_void + @Keep + @DoNotStrip + get() { + return Func_void_java(onReadyToDisplay) + } + @Keep + @DoNotStrip + set(value) { + onReadyToDisplay = value + } + + abstract var onSeek: (seekTime: Double) -> Unit + + private var onSeek_cxx: Func_void_double + @Keep + @DoNotStrip + get() { + return Func_void_double_java(onSeek) + } + @Keep + @DoNotStrip + set(value) { + onSeek = value + } + + abstract var onTimedMetadata: (metadata: TimedMetadata) -> Unit + + private var onTimedMetadata_cxx: Func_void_TimedMetadata + @Keep + @DoNotStrip + get() { + return Func_void_TimedMetadata_java(onTimedMetadata) + } + @Keep + @DoNotStrip + set(value) { + onTimedMetadata = value + } + + abstract var onTextTrackDataChanged: (texts: Array) -> Unit + + private var onTextTrackDataChanged_cxx: Func_void_std__vector_std__string_ + @Keep + @DoNotStrip + get() { + return Func_void_std__vector_std__string__java(onTextTrackDataChanged) + } + @Keep + @DoNotStrip + set(value) { + onTextTrackDataChanged = value + } + + abstract var onVolumeChange: (volume: Double) -> Unit + + private var onVolumeChange_cxx: Func_void_double + @Keep + @DoNotStrip + get() { + return Func_void_double_java(onVolumeChange) + } + @Keep + @DoNotStrip + set(value) { + onVolumeChange = value + } + + abstract var onStatusChange: (status: VideoPlayerStatus) -> Unit + + private var onStatusChange_cxx: Func_void_VideoPlayerStatus + @Keep + @DoNotStrip + get() { + return Func_void_VideoPlayerStatus_java(onStatusChange) + } + @Keep + @DoNotStrip + set(value) { + onStatusChange = value + } + + // Methods + + + private external fun initHybrid(): HybridData + + companion object { + private const val TAG = "HybridVideoPlayerEventEmitterSpec" + } +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceFactorySpec.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceFactorySpec.kt index ceee82cc..0eff8294 100644 --- a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceFactorySpec.kt +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceFactorySpec.kt @@ -43,6 +43,10 @@ abstract class HybridVideoPlayerSourceFactorySpec: HybridObject() { @DoNotStrip @Keep abstract fun fromUri(uri: String): HybridVideoPlayerSourceSpec + + @DoNotStrip + @Keep + abstract fun fromVideoConfig(config: NativeVideoConfig): HybridVideoPlayerSourceSpec private external fun initHybrid(): HybridData diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceSpec.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceSpec.kt index 871905b7..b7fe7344 100644 --- a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceSpec.kt +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSourceSpec.kt @@ -40,6 +40,10 @@ abstract class HybridVideoPlayerSourceSpec: HybridObject() { @get:DoNotStrip @get:Keep abstract val uri: String + + @get:DoNotStrip + @get:Keep + abstract val config: NativeVideoConfig // Methods @DoNotStrip diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSpec.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSpec.kt index 3fb9aea7..81fc6e74 100644 --- a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSpec.kt +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoPlayerSpec.kt @@ -41,6 +41,14 @@ abstract class HybridVideoPlayerSpec: HybridObject() { @get:Keep abstract val source: HybridVideoPlayerSourceSpec + @get:DoNotStrip + @get:Keep + abstract val eventEmitter: HybridVideoPlayerEventEmitterSpec + + @get:DoNotStrip + @get:Keep + abstract val status: VideoPlayerStatus + @get:DoNotStrip @get:Keep abstract val duration: Double diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoViewViewManagerSpec.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoViewViewManagerSpec.kt index 9ff7b905..9a4a5dea 100644 --- a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoViewViewManagerSpec.kt +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/HybridVideoViewViewManagerSpec.kt @@ -60,6 +60,90 @@ abstract class HybridVideoViewViewManagerSpec: HybridObject() { @set:DoNotStrip @set:Keep abstract var autoEnterPictureInPicture: Boolean + + abstract var onPictureInPictureChange: ((isInPictureInPicture: Boolean) -> Unit)? + + private var onPictureInPictureChange_cxx: Func_void_bool? + @Keep + @DoNotStrip + get() { + return onPictureInPictureChange?.let { Func_void_bool_java(it) } + } + @Keep + @DoNotStrip + set(value) { + onPictureInPictureChange = value?.let { it } + } + + abstract var onFullscreenChange: ((fullscreen: Boolean) -> Unit)? + + private var onFullscreenChange_cxx: Func_void_bool? + @Keep + @DoNotStrip + get() { + return onFullscreenChange?.let { Func_void_bool_java(it) } + } + @Keep + @DoNotStrip + set(value) { + onFullscreenChange = value?.let { it } + } + + abstract var willEnterFullscreen: (() -> Unit)? + + private var willEnterFullscreen_cxx: Func_void? + @Keep + @DoNotStrip + get() { + return willEnterFullscreen?.let { Func_void_java(it) } + } + @Keep + @DoNotStrip + set(value) { + willEnterFullscreen = value?.let { it } + } + + abstract var willExitFullscreen: (() -> Unit)? + + private var willExitFullscreen_cxx: Func_void? + @Keep + @DoNotStrip + get() { + return willExitFullscreen?.let { Func_void_java(it) } + } + @Keep + @DoNotStrip + set(value) { + willExitFullscreen = value?.let { it } + } + + abstract var willEnterPictureInPicture: (() -> Unit)? + + private var willEnterPictureInPicture_cxx: Func_void? + @Keep + @DoNotStrip + get() { + return willEnterPictureInPicture?.let { Func_void_java(it) } + } + @Keep + @DoNotStrip + set(value) { + willEnterPictureInPicture = value?.let { it } + } + + abstract var willExitPictureInPicture: (() -> Unit)? + + private var willExitPictureInPicture_cxx: Func_void? + @Keep + @DoNotStrip + get() { + return willExitPictureInPicture?.let { Func_void_java(it) } + } + @Keep + @DoNotStrip + set(value) { + willExitPictureInPicture = value?.let { it } + } // Methods @DoNotStrip diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/NativeVideoConfig.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/NativeVideoConfig.kt new file mode 100644 index 00000000..39f2f0c7 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/NativeVideoConfig.kt @@ -0,0 +1,28 @@ +/// +/// NativeVideoConfig.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "NativeVideoConfig". + */ +@DoNotStrip +@Keep +data class NativeVideoConfig + @DoNotStrip + @Keep + constructor( + val uri: String, + val headers: Map?, + val externalSubtitles: Array? + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/SourceType.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/SourceType.kt new file mode 100644 index 00000000..b0be9aac --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/SourceType.kt @@ -0,0 +1,25 @@ +/// +/// SourceType.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +/** + * Represents the JavaScript enum/union "SourceType". + */ +@DoNotStrip +@Keep +enum class SourceType { + LOCAL, + NETWORK; + + @DoNotStrip + @Keep + private val _ordinal = ordinal +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadata.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadata.kt new file mode 100644 index 00000000..89fc7230 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadata.kt @@ -0,0 +1,26 @@ +/// +/// TimedMetadata.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "TimedMetadata". + */ +@DoNotStrip +@Keep +data class TimedMetadata + @DoNotStrip + @Keep + constructor( + val metadata: Array + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadataObject.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadataObject.kt new file mode 100644 index 00000000..2984a229 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/TimedMetadataObject.kt @@ -0,0 +1,27 @@ +/// +/// TimedMetadataObject.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "TimedMetadataObject". + */ +@DoNotStrip +@Keep +data class TimedMetadataObject + @DoNotStrip + @Keep + constructor( + val value: String, + val identifier: String + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoOrientation.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoOrientation.kt index e2e784e7..d6c37e6e 100644 --- a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoOrientation.kt +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoOrientation.kt @@ -21,6 +21,7 @@ enum class VideoOrientation { PORTRAIT_UPSIDE_DOWN, LANDSCAPE_LEFT, LANDSCAPE_RIGHT, + SQUARE, UNKNOWN; @DoNotStrip diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoPlayerStatus.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoPlayerStatus.kt new file mode 100644 index 00000000..e6c4996e --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/VideoPlayerStatus.kt @@ -0,0 +1,27 @@ +/// +/// VideoPlayerStatus.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +/** + * Represents the JavaScript enum/union "VideoPlayerStatus". + */ +@DoNotStrip +@Keep +enum class VideoPlayerStatus { + IDLE, + LOADING, + READYTOPLAY, + ERROR; + + @DoNotStrip + @Keep + private val _ordinal = ordinal +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadData.kt new file mode 100644 index 00000000..90d552b6 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadData.kt @@ -0,0 +1,30 @@ +/// +/// onLoadData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "onLoadData". + */ +@DoNotStrip +@Keep +data class onLoadData + @DoNotStrip + @Keep + constructor( + val currentTime: Double, + val duration: Double, + val height: Double, + val width: Double, + val orientation: VideoOrientation + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadStartData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadStartData.kt new file mode 100644 index 00000000..e39c48da --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onLoadStartData.kt @@ -0,0 +1,27 @@ +/// +/// onLoadStartData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "onLoadStartData". + */ +@DoNotStrip +@Keep +data class onLoadStartData + @DoNotStrip + @Keep + constructor( + val sourceType: SourceType, + val source: HybridVideoPlayerSourceSpec + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onPlaybackStateChangeData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onPlaybackStateChangeData.kt new file mode 100644 index 00000000..e9dd5599 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onPlaybackStateChangeData.kt @@ -0,0 +1,27 @@ +/// +/// onPlaybackStateChangeData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "onPlaybackStateChangeData". + */ +@DoNotStrip +@Keep +data class onPlaybackStateChangeData + @DoNotStrip + @Keep + constructor( + val isPlaying: Boolean, + val isBuffering: Boolean + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onProgressData.kt b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onProgressData.kt new file mode 100644 index 00000000..fd580a39 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/android/kotlin/com/margelo/nitro/video/onProgressData.kt @@ -0,0 +1,27 @@ +/// +/// onProgressData.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.video + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.* + +/** + * Represents the JavaScript object/struct "onProgressData". + */ +@DoNotStrip +@Keep +data class onProgressData + @DoNotStrip + @Keep + constructor( + val currentTime: Double, + val bufferDuration: Double + ) { + /* main constructor */ +} diff --git a/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.cpp b/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.cpp index 89697abe..998858eb 100644 --- a/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.cpp +++ b/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.cpp @@ -8,6 +8,7 @@ #include "ReactNativeVideo-Swift-Cxx-Bridge.hpp" // Include C++ implementation defined types +#include "HybridVideoPlayerEventEmitterSpecSwift.hpp" #include "HybridVideoPlayerFactorySpecSwift.hpp" #include "HybridVideoPlayerSourceFactorySpecSwift.hpp" #include "HybridVideoPlayerSourceSpecSwift.hpp" @@ -34,6 +35,22 @@ namespace margelo::nitro::video::bridge::swift { return swiftPart.toUnsafe(); } + // pragma MARK: std::shared_ptr + std::shared_ptr create_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(void* _Nonnull swiftUnsafePointer) { + ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx swiftPart = ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx::fromUnsafe(swiftUnsafePointer); + return std::make_shared(swiftPart); + } + void* _Nonnull get_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ cppType) { + std::shared_ptr swiftWrapper = std::dynamic_pointer_cast(cppType); + #ifdef NITRO_DEBUG + if (swiftWrapper == nullptr) [[unlikely]] { + throw std::runtime_error("Class \"HybridVideoPlayerEventEmitterSpec\" is not implemented in Swift!"); + } + #endif + ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx& swiftPart = swiftWrapper->getSwiftPart(); + return swiftPart.toUnsafe(); + } + // pragma MARK: std::function Func_void create_Func_void(void* _Nonnull swiftClosureWrapper) { auto swiftClosure = ReactNativeVideo::Func_void::fromUnsafe(swiftClosureWrapper); @@ -82,6 +99,86 @@ namespace margelo::nitro::video::bridge::swift { return swiftPart.toUnsafe(); } + // pragma MARK: std::function + Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_bool::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](bool hasAudioFocus) mutable -> void { + swiftClosure.call(hasAudioFocus); + }; + } + + // pragma MARK: std::function + Func_void_BandwidthData create_Func_void_BandwidthData(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_BandwidthData::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const BandwidthData& data) mutable -> void { + swiftClosure.call(data); + }; + } + + // pragma MARK: std::function + Func_void_onLoadData create_Func_void_onLoadData(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_onLoadData::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const onLoadData& data) mutable -> void { + swiftClosure.call(data); + }; + } + + // pragma MARK: std::function + Func_void_onLoadStartData create_Func_void_onLoadStartData(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_onLoadStartData::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const onLoadStartData& data) mutable -> void { + swiftClosure.call(data); + }; + } + + // pragma MARK: std::function + Func_void_onPlaybackStateChangeData create_Func_void_onPlaybackStateChangeData(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_onPlaybackStateChangeData::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const onPlaybackStateChangeData& data) mutable -> void { + swiftClosure.call(data); + }; + } + + // pragma MARK: std::function + Func_void_double create_Func_void_double(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_double::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](double rate) mutable -> void { + swiftClosure.call(rate); + }; + } + + // pragma MARK: std::function + Func_void_onProgressData create_Func_void_onProgressData(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_onProgressData::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const onProgressData& data) mutable -> void { + swiftClosure.call(data); + }; + } + + // pragma MARK: std::function + Func_void_TimedMetadata create_Func_void_TimedMetadata(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_TimedMetadata::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const TimedMetadata& metadata) mutable -> void { + swiftClosure.call(metadata); + }; + } + + // pragma MARK: std::function& /* texts */)> + Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_std__vector_std__string_::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](const std::vector& texts) mutable -> void { + swiftClosure.call(texts); + }; + } + + // pragma MARK: std::function + Func_void_VideoPlayerStatus create_Func_void_VideoPlayerStatus(void* _Nonnull swiftClosureWrapper) { + auto swiftClosure = ReactNativeVideo::Func_void_VideoPlayerStatus::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)](VideoPlayerStatus status) mutable -> void { + swiftClosure.call(static_cast(status)); + }; + } + // pragma MARK: std::function Func_void_VideoInformation create_Func_void_VideoInformation(void* _Nonnull swiftClosureWrapper) { auto swiftClosure = ReactNativeVideo::Func_void_VideoInformation::fromUnsafe(swiftClosureWrapper); diff --git a/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.hpp b/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.hpp index 95a0ba5e..abc8da96 100644 --- a/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.hpp +++ b/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Bridge.hpp @@ -8,6 +8,12 @@ #pragma once // Forward declarations of C++ defined types +// Forward declaration of `BandwidthData` to properly resolve imports. +namespace margelo::nitro::video { struct BandwidthData; } +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } +// Forward declaration of `HybridVideoPlayerEventEmitterSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerEventEmitterSpec; } // Forward declaration of `HybridVideoPlayerFactorySpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerFactorySpec; } // Forward declaration of `HybridVideoPlayerSourceFactorySpec` to properly resolve imports. @@ -20,12 +26,30 @@ namespace margelo::nitro::video { class HybridVideoPlayerSpec; } namespace margelo::nitro::video { class HybridVideoViewViewManagerFactorySpec; } // Forward declaration of `HybridVideoViewViewManagerSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoViewViewManagerSpec; } +// Forward declaration of `SourceType` to properly resolve imports. +namespace margelo::nitro::video { enum class SourceType; } +// Forward declaration of `TimedMetadataObject` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadataObject; } +// Forward declaration of `TimedMetadata` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadata; } // Forward declaration of `VideoInformation` to properly resolve imports. namespace margelo::nitro::video { struct VideoInformation; } // Forward declaration of `VideoOrientation` to properly resolve imports. namespace margelo::nitro::video { enum class VideoOrientation; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } +// Forward declaration of `onLoadData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadData; } +// Forward declaration of `onLoadStartData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadStartData; } +// Forward declaration of `onPlaybackStateChangeData` to properly resolve imports. +namespace margelo::nitro::video { struct onPlaybackStateChangeData; } +// Forward declaration of `onProgressData` to properly resolve imports. +namespace margelo::nitro::video { struct onProgressData; } // Forward declarations of Swift defined types +// Forward declaration of `HybridVideoPlayerEventEmitterSpec_cxx` to properly resolve imports. +namespace ReactNativeVideo { class HybridVideoPlayerEventEmitterSpec_cxx; } // Forward declaration of `HybridVideoPlayerFactorySpec_cxx` to properly resolve imports. namespace ReactNativeVideo { class HybridVideoPlayerFactorySpec_cxx; } // Forward declaration of `HybridVideoPlayerSourceFactorySpec_cxx` to properly resolve imports. @@ -40,14 +64,25 @@ namespace ReactNativeVideo { class HybridVideoViewViewManagerFactorySpec_cxx; } namespace ReactNativeVideo { class HybridVideoViewViewManagerSpec_cxx; } // Include C++ defined types +#include "BandwidthData.hpp" +#include "ExternalSubtitle.hpp" +#include "HybridVideoPlayerEventEmitterSpec.hpp" #include "HybridVideoPlayerFactorySpec.hpp" #include "HybridVideoPlayerSourceFactorySpec.hpp" #include "HybridVideoPlayerSourceSpec.hpp" #include "HybridVideoPlayerSpec.hpp" #include "HybridVideoViewViewManagerFactorySpec.hpp" #include "HybridVideoViewViewManagerSpec.hpp" +#include "SourceType.hpp" +#include "TimedMetadata.hpp" +#include "TimedMetadataObject.hpp" #include "VideoInformation.hpp" #include "VideoOrientation.hpp" +#include "VideoPlayerStatus.hpp" +#include "onLoadData.hpp" +#include "onLoadStartData.hpp" +#include "onPlaybackStateChangeData.hpp" +#include "onProgressData.hpp" #include #include #include @@ -55,6 +90,9 @@ namespace ReactNativeVideo { class HybridVideoViewViewManagerSpec_cxx; } #include #include #include +#include +#include +#include /** * Contains specialized versions of C++ templated types so they can be accessed from Swift, @@ -74,6 +112,18 @@ namespace margelo::nitro::video::bridge::swift { using std__weak_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_ = std::weak_ptr; inline std__weak_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_ weakify_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_(const std::shared_ptr& strong) { return strong; } + // pragma MARK: std::shared_ptr + /** + * Specialized version of `std::shared_ptr`. + */ + using std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ = std::shared_ptr; + std::shared_ptr create_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(void* _Nonnull swiftUnsafePointer); + void* _Nonnull get_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ cppType); + + // pragma MARK: std::weak_ptr + using std__weak_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ = std::weak_ptr; + inline std__weak_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ weakify_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(const std::shared_ptr& strong) { return strong; } + // pragma MARK: std::shared_ptr> /** * Specialized version of `std::shared_ptr>`. @@ -181,6 +231,308 @@ namespace margelo::nitro::video::bridge::swift { return Result>::withError(error); } + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_bool = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_bool_Wrapper final { + public: + explicit Func_void_bool_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(bool hasAudioFocus) const { + _function->operator()(hasAudioFocus); + } + private: + std::shared_ptr> _function; + }; + Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper); + inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) { + return Func_void_bool_Wrapper(std::move(value)); + } + + // pragma MARK: std::optional + /** + * Specialized version of `std::optional`. + */ + using std__optional_double_ = std::optional; + inline std::optional create_std__optional_double_(const double& value) { + return std::optional(value); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_BandwidthData = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_BandwidthData_Wrapper final { + public: + explicit Func_void_BandwidthData_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(BandwidthData data) const { + _function->operator()(data); + } + private: + std::shared_ptr> _function; + }; + Func_void_BandwidthData create_Func_void_BandwidthData(void* _Nonnull swiftClosureWrapper); + inline Func_void_BandwidthData_Wrapper wrap_Func_void_BandwidthData(Func_void_BandwidthData value) { + return Func_void_BandwidthData_Wrapper(std::move(value)); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_onLoadData = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_onLoadData_Wrapper final { + public: + explicit Func_void_onLoadData_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(onLoadData data) const { + _function->operator()(data); + } + private: + std::shared_ptr> _function; + }; + Func_void_onLoadData create_Func_void_onLoadData(void* _Nonnull swiftClosureWrapper); + inline Func_void_onLoadData_Wrapper wrap_Func_void_onLoadData(Func_void_onLoadData value) { + return Func_void_onLoadData_Wrapper(std::move(value)); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_onLoadStartData = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_onLoadStartData_Wrapper final { + public: + explicit Func_void_onLoadStartData_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(onLoadStartData data) const { + _function->operator()(data); + } + private: + std::shared_ptr> _function; + }; + Func_void_onLoadStartData create_Func_void_onLoadStartData(void* _Nonnull swiftClosureWrapper); + inline Func_void_onLoadStartData_Wrapper wrap_Func_void_onLoadStartData(Func_void_onLoadStartData value) { + return Func_void_onLoadStartData_Wrapper(std::move(value)); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_onPlaybackStateChangeData = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_onPlaybackStateChangeData_Wrapper final { + public: + explicit Func_void_onPlaybackStateChangeData_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(onPlaybackStateChangeData data) const { + _function->operator()(data); + } + private: + std::shared_ptr> _function; + }; + Func_void_onPlaybackStateChangeData create_Func_void_onPlaybackStateChangeData(void* _Nonnull swiftClosureWrapper); + inline Func_void_onPlaybackStateChangeData_Wrapper wrap_Func_void_onPlaybackStateChangeData(Func_void_onPlaybackStateChangeData value) { + return Func_void_onPlaybackStateChangeData_Wrapper(std::move(value)); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_double = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_double_Wrapper final { + public: + explicit Func_void_double_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(double rate) const { + _function->operator()(rate); + } + private: + std::shared_ptr> _function; + }; + Func_void_double create_Func_void_double(void* _Nonnull swiftClosureWrapper); + inline Func_void_double_Wrapper wrap_Func_void_double(Func_void_double value) { + return Func_void_double_Wrapper(std::move(value)); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_onProgressData = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_onProgressData_Wrapper final { + public: + explicit Func_void_onProgressData_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(onProgressData data) const { + _function->operator()(data); + } + private: + std::shared_ptr> _function; + }; + Func_void_onProgressData create_Func_void_onProgressData(void* _Nonnull swiftClosureWrapper); + inline Func_void_onProgressData_Wrapper wrap_Func_void_onProgressData(Func_void_onProgressData value) { + return Func_void_onProgressData_Wrapper(std::move(value)); + } + + // pragma MARK: std::vector + /** + * Specialized version of `std::vector`. + */ + using std__vector_TimedMetadataObject_ = std::vector; + inline std::vector create_std__vector_TimedMetadataObject_(size_t size) { + std::vector vector; + vector.reserve(size); + return vector; + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_TimedMetadata = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_TimedMetadata_Wrapper final { + public: + explicit Func_void_TimedMetadata_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(TimedMetadata metadata) const { + _function->operator()(metadata); + } + private: + std::shared_ptr> _function; + }; + Func_void_TimedMetadata create_Func_void_TimedMetadata(void* _Nonnull swiftClosureWrapper); + inline Func_void_TimedMetadata_Wrapper wrap_Func_void_TimedMetadata(Func_void_TimedMetadata value) { + return Func_void_TimedMetadata_Wrapper(std::move(value)); + } + + // pragma MARK: std::vector + /** + * Specialized version of `std::vector`. + */ + using std__vector_std__string_ = std::vector; + inline std::vector create_std__vector_std__string_(size_t size) { + std::vector vector; + vector.reserve(size); + return vector; + } + + // pragma MARK: std::function& /* texts */)> + /** + * Specialized version of `std::function&)>`. + */ + using Func_void_std__vector_std__string_ = std::function& /* texts */)>; + /** + * Wrapper class for a `std::function& / * texts * /)>`, this can be used from Swift. + */ + class Func_void_std__vector_std__string__Wrapper final { + public: + explicit Func_void_std__vector_std__string__Wrapper(std::function& /* texts */)>&& func): _function(std::make_shared& /* texts */)>>(std::move(func))) {} + inline void call(std::vector texts) const { + _function->operator()(texts); + } + private: + std::shared_ptr& /* texts */)>> _function; + }; + Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* _Nonnull swiftClosureWrapper); + inline Func_void_std__vector_std__string__Wrapper wrap_Func_void_std__vector_std__string_(Func_void_std__vector_std__string_ value) { + return Func_void_std__vector_std__string__Wrapper(std::move(value)); + } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void_VideoPlayerStatus = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_VideoPlayerStatus_Wrapper final { + public: + explicit Func_void_VideoPlayerStatus_Wrapper(std::function&& func): _function(std::make_shared>(std::move(func))) {} + inline void call(int status) const { + _function->operator()(static_cast(status)); + } + private: + std::shared_ptr> _function; + }; + Func_void_VideoPlayerStatus create_Func_void_VideoPlayerStatus(void* _Nonnull swiftClosureWrapper); + inline Func_void_VideoPlayerStatus_Wrapper wrap_Func_void_VideoPlayerStatus(Func_void_VideoPlayerStatus value) { + return Func_void_VideoPlayerStatus_Wrapper(std::move(value)); + } + + // pragma MARK: std::unordered_map + /** + * Specialized version of `std::unordered_map`. + */ + using std__unordered_map_std__string__std__string_ = std::unordered_map; + inline std::unordered_map create_std__unordered_map_std__string__std__string_(size_t size) { + std::unordered_map map; + map.reserve(size); + return map; + } + inline std::vector get_std__unordered_map_std__string__std__string__keys(const std__unordered_map_std__string__std__string_& map) { + std::vector keys; + keys.reserve(map.size()); + for (const auto& entry : map) { + keys.push_back(entry.first); + } + return keys; + } + inline void emplace_std__unordered_map_std__string__std__string_(std__unordered_map_std__string__std__string_& map, const std::string& key, const std::string& value) { + map.emplace(key, value); + } + + // pragma MARK: std::optional> + /** + * Specialized version of `std::optional>`. + */ + using std__optional_std__unordered_map_std__string__std__string__ = std::optional>; + inline std::optional> create_std__optional_std__unordered_map_std__string__std__string__(const std::unordered_map& value) { + return std::optional>(value); + } + + // pragma MARK: std::vector + /** + * Specialized version of `std::vector`. + */ + using std__vector_ExternalSubtitle_ = std::vector; + inline std::vector create_std__vector_ExternalSubtitle_(size_t size) { + std::vector vector; + vector.reserve(size); + return vector; + } + + // pragma MARK: std::optional> + /** + * Specialized version of `std::optional>`. + */ + using std__optional_std__vector_ExternalSubtitle__ = std::optional>; + inline std::optional> create_std__optional_std__vector_ExternalSubtitle__(const std::vector& value) { + return std::optional>(value); + } + // pragma MARK: std::shared_ptr> /** * Specialized version of `std::shared_ptr>`. @@ -254,6 +606,33 @@ namespace margelo::nitro::video::bridge::swift { return std::optional>(value); } + // pragma MARK: std::optional> + /** + * Specialized version of `std::optional>`. + */ + using std__optional_std__function_void_bool____isInPictureInPicture______ = std::optional>; + inline std::optional> create_std__optional_std__function_void_bool____isInPictureInPicture______(const std::function& value) { + return std::optional>(value); + } + + // pragma MARK: std::optional> + /** + * Specialized version of `std::optional>`. + */ + using std__optional_std__function_void_bool____fullscreen______ = std::optional>; + inline std::optional> create_std__optional_std__function_void_bool____fullscreen______(const std::function& value) { + return std::optional>(value); + } + + // pragma MARK: std::optional> + /** + * Specialized version of `std::optional>`. + */ + using std__optional_std__function_void____ = std::optional>; + inline std::optional> create_std__optional_std__function_void____(const std::function& value) { + return std::optional>(value); + } + // pragma MARK: std::shared_ptr /** * Specialized version of `std::shared_ptr`. diff --git a/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Umbrella.hpp b/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Umbrella.hpp index 85f645e4..e988b1f5 100644 --- a/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Umbrella.hpp +++ b/packages/react-native-video/nitrogen/generated/ios/ReactNativeVideo-Swift-Cxx-Umbrella.hpp @@ -8,6 +8,12 @@ #pragma once // Forward declarations of C++ defined types +// Forward declaration of `BandwidthData` to properly resolve imports. +namespace margelo::nitro::video { struct BandwidthData; } +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } +// Forward declaration of `HybridVideoPlayerEventEmitterSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerEventEmitterSpec; } // Forward declaration of `HybridVideoPlayerFactorySpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerFactorySpec; } // Forward declaration of `HybridVideoPlayerSourceFactorySpec` to properly resolve imports. @@ -20,26 +26,59 @@ namespace margelo::nitro::video { class HybridVideoPlayerSpec; } namespace margelo::nitro::video { class HybridVideoViewViewManagerFactorySpec; } // Forward declaration of `HybridVideoViewViewManagerSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoViewViewManagerSpec; } +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } +// Forward declaration of `SourceType` to properly resolve imports. +namespace margelo::nitro::video { enum class SourceType; } +// Forward declaration of `TimedMetadataObject` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadataObject; } +// Forward declaration of `TimedMetadata` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadata; } // Forward declaration of `VideoInformation` to properly resolve imports. namespace margelo::nitro::video { struct VideoInformation; } // Forward declaration of `VideoOrientation` to properly resolve imports. namespace margelo::nitro::video { enum class VideoOrientation; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } +// Forward declaration of `onLoadData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadData; } +// Forward declaration of `onLoadStartData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadStartData; } +// Forward declaration of `onPlaybackStateChangeData` to properly resolve imports. +namespace margelo::nitro::video { struct onPlaybackStateChangeData; } +// Forward declaration of `onProgressData` to properly resolve imports. +namespace margelo::nitro::video { struct onProgressData; } // Include C++ defined types +#include "BandwidthData.hpp" +#include "ExternalSubtitle.hpp" +#include "HybridVideoPlayerEventEmitterSpec.hpp" #include "HybridVideoPlayerFactorySpec.hpp" #include "HybridVideoPlayerSourceFactorySpec.hpp" #include "HybridVideoPlayerSourceSpec.hpp" #include "HybridVideoPlayerSpec.hpp" #include "HybridVideoViewViewManagerFactorySpec.hpp" #include "HybridVideoViewViewManagerSpec.hpp" +#include "NativeVideoConfig.hpp" +#include "SourceType.hpp" +#include "TimedMetadata.hpp" +#include "TimedMetadataObject.hpp" #include "VideoInformation.hpp" #include "VideoOrientation.hpp" +#include "VideoPlayerStatus.hpp" +#include "onLoadData.hpp" +#include "onLoadStartData.hpp" +#include "onPlaybackStateChangeData.hpp" +#include "onProgressData.hpp" #include #include #include +#include #include #include #include +#include +#include // C++ helpers for Swift #include "ReactNativeVideo-Swift-Cxx-Bridge.hpp" @@ -50,6 +89,8 @@ namespace margelo::nitro::video { enum class VideoOrientation; } #include // Forward declarations of Swift defined types +// Forward declaration of `HybridVideoPlayerEventEmitterSpec_cxx` to properly resolve imports. +namespace ReactNativeVideo { class HybridVideoPlayerEventEmitterSpec_cxx; } // Forward declaration of `HybridVideoPlayerFactorySpec_cxx` to properly resolve imports. namespace ReactNativeVideo { class HybridVideoPlayerFactorySpec_cxx; } // Forward declaration of `HybridVideoPlayerSourceFactorySpec_cxx` to properly resolve imports. diff --git a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.cpp b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.cpp new file mode 100644 index 00000000..6c47efb2 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.cpp @@ -0,0 +1,11 @@ +/// +/// HybridVideoPlayerEventEmitterSpecSwift.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#include "HybridVideoPlayerEventEmitterSpecSwift.hpp" + +namespace margelo::nitro::video { +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.hpp b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.hpp new file mode 100644 index 00000000..10da575a --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerEventEmitterSpecSwift.hpp @@ -0,0 +1,225 @@ +/// +/// HybridVideoPlayerEventEmitterSpecSwift.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#include "HybridVideoPlayerEventEmitterSpec.hpp" + +// Forward declaration of `HybridVideoPlayerEventEmitterSpec_cxx` to properly resolve imports. +namespace ReactNativeVideo { class HybridVideoPlayerEventEmitterSpec_cxx; } + +// Forward declaration of `BandwidthData` to properly resolve imports. +namespace margelo::nitro::video { struct BandwidthData; } +// Forward declaration of `onLoadData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadData; } +// Forward declaration of `VideoOrientation` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoOrientation; } +// Forward declaration of `onLoadStartData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadStartData; } +// Forward declaration of `SourceType` to properly resolve imports. +namespace margelo::nitro::video { enum class SourceType; } +// Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `onPlaybackStateChangeData` to properly resolve imports. +namespace margelo::nitro::video { struct onPlaybackStateChangeData; } +// Forward declaration of `onProgressData` to properly resolve imports. +namespace margelo::nitro::video { struct onProgressData; } +// Forward declaration of `TimedMetadata` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadata; } +// Forward declaration of `TimedMetadataObject` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadataObject; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } + +#include +#include "BandwidthData.hpp" +#include +#include "onLoadData.hpp" +#include "VideoOrientation.hpp" +#include "onLoadStartData.hpp" +#include "SourceType.hpp" +#include +#include "HybridVideoPlayerSourceSpec.hpp" +#include "onPlaybackStateChangeData.hpp" +#include "onProgressData.hpp" +#include "TimedMetadata.hpp" +#include +#include "TimedMetadataObject.hpp" +#include +#include "VideoPlayerStatus.hpp" + +#include "ReactNativeVideo-Swift-Cxx-Umbrella.hpp" + +namespace margelo::nitro::video { + + /** + * The C++ part of HybridVideoPlayerEventEmitterSpec_cxx.swift. + * + * HybridVideoPlayerEventEmitterSpecSwift (C++) accesses HybridVideoPlayerEventEmitterSpec_cxx (Swift), and might + * contain some additional bridging code for C++ <> Swift interop. + * + * Since this obviously introduces an overhead, I hope at some point in + * the future, HybridVideoPlayerEventEmitterSpec_cxx can directly inherit from the C++ class HybridVideoPlayerEventEmitterSpec + * to simplify the whole structure and memory management. + */ + class HybridVideoPlayerEventEmitterSpecSwift: public virtual HybridVideoPlayerEventEmitterSpec { + public: + // Constructor from a Swift instance + explicit HybridVideoPlayerEventEmitterSpecSwift(const ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx& swiftPart): + HybridObject(HybridVideoPlayerEventEmitterSpec::TAG), + _swiftPart(swiftPart) { } + + public: + // Get the Swift part + inline ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx& getSwiftPart() noexcept { + return _swiftPart; + } + + public: + // Get memory pressure + inline size_t getExternalMemorySize() noexcept override { + return _swiftPart.getMemorySize(); + } + + public: + // Properties + inline std::function getOnAudioBecomingNoisy() noexcept override { + auto __result = _swiftPart.getOnAudioBecomingNoisy(); + return __result; + } + inline void setOnAudioBecomingNoisy(const std::function& onAudioBecomingNoisy) noexcept override { + _swiftPart.setOnAudioBecomingNoisy(onAudioBecomingNoisy); + } + inline std::function getOnAudioFocusChange() noexcept override { + auto __result = _swiftPart.getOnAudioFocusChange(); + return __result; + } + inline void setOnAudioFocusChange(const std::function& onAudioFocusChange) noexcept override { + _swiftPart.setOnAudioFocusChange(onAudioFocusChange); + } + inline std::function getOnBandwidthUpdate() noexcept override { + auto __result = _swiftPart.getOnBandwidthUpdate(); + return __result; + } + inline void setOnBandwidthUpdate(const std::function& onBandwidthUpdate) noexcept override { + _swiftPart.setOnBandwidthUpdate(onBandwidthUpdate); + } + inline std::function getOnBuffer() noexcept override { + auto __result = _swiftPart.getOnBuffer(); + return __result; + } + inline void setOnBuffer(const std::function& onBuffer) noexcept override { + _swiftPart.setOnBuffer(onBuffer); + } + inline std::function getOnControlsVisibleChange() noexcept override { + auto __result = _swiftPart.getOnControlsVisibleChange(); + return __result; + } + inline void setOnControlsVisibleChange(const std::function& onControlsVisibleChange) noexcept override { + _swiftPart.setOnControlsVisibleChange(onControlsVisibleChange); + } + inline std::function getOnEnd() noexcept override { + auto __result = _swiftPart.getOnEnd(); + return __result; + } + inline void setOnEnd(const std::function& onEnd) noexcept override { + _swiftPart.setOnEnd(onEnd); + } + inline std::function getOnExternalPlaybackChange() noexcept override { + auto __result = _swiftPart.getOnExternalPlaybackChange(); + return __result; + } + inline void setOnExternalPlaybackChange(const std::function& onExternalPlaybackChange) noexcept override { + _swiftPart.setOnExternalPlaybackChange(onExternalPlaybackChange); + } + inline std::function getOnLoad() noexcept override { + auto __result = _swiftPart.getOnLoad(); + return __result; + } + inline void setOnLoad(const std::function& onLoad) noexcept override { + _swiftPart.setOnLoad(onLoad); + } + inline std::function getOnLoadStart() noexcept override { + auto __result = _swiftPart.getOnLoadStart(); + return __result; + } + inline void setOnLoadStart(const std::function& onLoadStart) noexcept override { + _swiftPart.setOnLoadStart(onLoadStart); + } + inline std::function getOnPlaybackStateChange() noexcept override { + auto __result = _swiftPart.getOnPlaybackStateChange(); + return __result; + } + inline void setOnPlaybackStateChange(const std::function& onPlaybackStateChange) noexcept override { + _swiftPart.setOnPlaybackStateChange(onPlaybackStateChange); + } + inline std::function getOnPlaybackRateChange() noexcept override { + auto __result = _swiftPart.getOnPlaybackRateChange(); + return __result; + } + inline void setOnPlaybackRateChange(const std::function& onPlaybackRateChange) noexcept override { + _swiftPart.setOnPlaybackRateChange(onPlaybackRateChange); + } + inline std::function getOnProgress() noexcept override { + auto __result = _swiftPart.getOnProgress(); + return __result; + } + inline void setOnProgress(const std::function& onProgress) noexcept override { + _swiftPart.setOnProgress(onProgress); + } + inline std::function getOnReadyToDisplay() noexcept override { + auto __result = _swiftPart.getOnReadyToDisplay(); + return __result; + } + inline void setOnReadyToDisplay(const std::function& onReadyToDisplay) noexcept override { + _swiftPart.setOnReadyToDisplay(onReadyToDisplay); + } + inline std::function getOnSeek() noexcept override { + auto __result = _swiftPart.getOnSeek(); + return __result; + } + inline void setOnSeek(const std::function& onSeek) noexcept override { + _swiftPart.setOnSeek(onSeek); + } + inline std::function getOnTimedMetadata() noexcept override { + auto __result = _swiftPart.getOnTimedMetadata(); + return __result; + } + inline void setOnTimedMetadata(const std::function& onTimedMetadata) noexcept override { + _swiftPart.setOnTimedMetadata(onTimedMetadata); + } + inline std::function& /* texts */)> getOnTextTrackDataChanged() noexcept override { + auto __result = _swiftPart.getOnTextTrackDataChanged(); + return __result; + } + inline void setOnTextTrackDataChanged(const std::function& /* texts */)>& onTextTrackDataChanged) noexcept override { + _swiftPart.setOnTextTrackDataChanged(onTextTrackDataChanged); + } + inline std::function getOnVolumeChange() noexcept override { + auto __result = _swiftPart.getOnVolumeChange(); + return __result; + } + inline void setOnVolumeChange(const std::function& onVolumeChange) noexcept override { + _swiftPart.setOnVolumeChange(onVolumeChange); + } + inline std::function getOnStatusChange() noexcept override { + auto __result = _swiftPart.getOnStatusChange(); + return __result; + } + inline void setOnStatusChange(const std::function& onStatusChange) noexcept override { + _swiftPart.setOnStatusChange(onStatusChange); + } + + public: + // Methods + + + private: + ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx _swiftPart; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceFactorySpecSwift.hpp b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceFactorySpecSwift.hpp index 2de7611a..3e1faad8 100644 --- a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceFactorySpecSwift.hpp +++ b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceFactorySpecSwift.hpp @@ -14,10 +14,19 @@ namespace ReactNativeVideo { class HybridVideoPlayerSourceFactorySpec_cxx; } // Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } #include #include "HybridVideoPlayerSourceSpec.hpp" #include +#include "NativeVideoConfig.hpp" +#include +#include +#include +#include "ExternalSubtitle.hpp" #include "ReactNativeVideo-Swift-Cxx-Umbrella.hpp" @@ -66,6 +75,14 @@ namespace margelo::nitro::video { auto __value = std::move(__result.value()); return __value; } + inline std::shared_ptr fromVideoConfig(const NativeVideoConfig& config) override { + auto __result = _swiftPart.fromVideoConfig(config); + if (__result.hasError()) [[unlikely]] { + std::rethrow_exception(__result.error()); + } + auto __value = std::move(__result.value()); + return __value; + } private: ReactNativeVideo::HybridVideoPlayerSourceFactorySpec_cxx _swiftPart; diff --git a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceSpecSwift.hpp b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceSpecSwift.hpp index 85732074..d6b2014b 100644 --- a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceSpecSwift.hpp +++ b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSourceSpecSwift.hpp @@ -12,12 +12,21 @@ // Forward declaration of `HybridVideoPlayerSourceSpec_cxx` to properly resolve imports. namespace ReactNativeVideo { class HybridVideoPlayerSourceSpec_cxx; } +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } // Forward declaration of `VideoInformation` to properly resolve imports. namespace margelo::nitro::video { struct VideoInformation; } // Forward declaration of `VideoOrientation` to properly resolve imports. namespace margelo::nitro::video { enum class VideoOrientation; } #include +#include "NativeVideoConfig.hpp" +#include +#include +#include +#include "ExternalSubtitle.hpp" #include #include "VideoInformation.hpp" #include "VideoOrientation.hpp" @@ -61,6 +70,10 @@ namespace margelo::nitro::video { auto __result = _swiftPart.getUri(); return __result; } + inline NativeVideoConfig getConfig() noexcept override { + auto __result = _swiftPart.getConfig(); + return __result; + } public: // Methods diff --git a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSpecSwift.hpp b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSpecSwift.hpp index 62d5bc7b..ebac2482 100644 --- a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSpecSwift.hpp +++ b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoPlayerSpecSwift.hpp @@ -14,9 +14,15 @@ namespace ReactNativeVideo { class HybridVideoPlayerSpec_cxx; } // Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `HybridVideoPlayerEventEmitterSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerEventEmitterSpec; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } #include #include "HybridVideoPlayerSourceSpec.hpp" +#include "HybridVideoPlayerEventEmitterSpec.hpp" +#include "VideoPlayerStatus.hpp" #include #include "ReactNativeVideo-Swift-Cxx-Umbrella.hpp" @@ -58,6 +64,14 @@ namespace margelo::nitro::video { auto __result = _swiftPart.getSource(); return __result; } + inline std::shared_ptr getEventEmitter() noexcept override { + auto __result = _swiftPart.getEventEmitter(); + return __result; + } + inline VideoPlayerStatus getStatus() noexcept override { + auto __result = _swiftPart.getStatus(); + return static_cast(__result); + } inline double getDuration() noexcept override { return _swiftPart.getDuration(); } diff --git a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoViewViewManagerSpecSwift.hpp b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoViewViewManagerSpecSwift.hpp index 02562091..aca623b7 100644 --- a/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoViewViewManagerSpecSwift.hpp +++ b/packages/react-native-video/nitrogen/generated/ios/c++/HybridVideoViewViewManagerSpecSwift.hpp @@ -18,6 +18,7 @@ namespace margelo::nitro::video { class HybridVideoPlayerSpec; } #include #include #include "HybridVideoPlayerSpec.hpp" +#include #include "ReactNativeVideo-Swift-Cxx-Umbrella.hpp" @@ -79,6 +80,48 @@ namespace margelo::nitro::video { inline void setAutoEnterPictureInPicture(bool autoEnterPictureInPicture) noexcept override { _swiftPart.setAutoEnterPictureInPicture(std::forward(autoEnterPictureInPicture)); } + inline std::optional> getOnPictureInPictureChange() noexcept override { + auto __result = _swiftPart.getOnPictureInPictureChange(); + return __result; + } + inline void setOnPictureInPictureChange(const std::optional>& onPictureInPictureChange) noexcept override { + _swiftPart.setOnPictureInPictureChange(onPictureInPictureChange); + } + inline std::optional> getOnFullscreenChange() noexcept override { + auto __result = _swiftPart.getOnFullscreenChange(); + return __result; + } + inline void setOnFullscreenChange(const std::optional>& onFullscreenChange) noexcept override { + _swiftPart.setOnFullscreenChange(onFullscreenChange); + } + inline std::optional> getWillEnterFullscreen() noexcept override { + auto __result = _swiftPart.getWillEnterFullscreen(); + return __result; + } + inline void setWillEnterFullscreen(const std::optional>& willEnterFullscreen) noexcept override { + _swiftPart.setWillEnterFullscreen(willEnterFullscreen); + } + inline std::optional> getWillExitFullscreen() noexcept override { + auto __result = _swiftPart.getWillExitFullscreen(); + return __result; + } + inline void setWillExitFullscreen(const std::optional>& willExitFullscreen) noexcept override { + _swiftPart.setWillExitFullscreen(willExitFullscreen); + } + inline std::optional> getWillEnterPictureInPicture() noexcept override { + auto __result = _swiftPart.getWillEnterPictureInPicture(); + return __result; + } + inline void setWillEnterPictureInPicture(const std::optional>& willEnterPictureInPicture) noexcept override { + _swiftPart.setWillEnterPictureInPicture(willEnterPictureInPicture); + } + inline std::optional> getWillExitPictureInPicture() noexcept override { + auto __result = _swiftPart.getWillExitPictureInPicture(); + return __result; + } + inline void setWillExitPictureInPicture(const std::optional>& willExitPictureInPicture) noexcept override { + _swiftPart.setWillExitPictureInPicture(willExitPictureInPicture); + } public: // Methods diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/BandwidthData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/BandwidthData.swift new file mode 100644 index 00000000..94f0d26a --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/BandwidthData.swift @@ -0,0 +1,81 @@ +/// +/// BandwidthData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `BandwidthData`, backed by a C++ struct. + */ +public typealias BandwidthData = margelo.nitro.video.BandwidthData + +public extension BandwidthData { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `BandwidthData`. + */ + init(bitrate: Double, width: Double?, height: Double?) { + self.init(bitrate, { () -> bridge.std__optional_double_ in + if let __unwrappedValue = width { + return bridge.create_std__optional_double_(__unwrappedValue) + } else { + return .init() + } + }(), { () -> bridge.std__optional_double_ in + if let __unwrappedValue = height { + return bridge.create_std__optional_double_(__unwrappedValue) + } else { + return .init() + } + }()) + } + + var bitrate: Double { + @inline(__always) + get { + return self.__bitrate + } + @inline(__always) + set { + self.__bitrate = newValue + } + } + + var width: Double? { + @inline(__always) + get { + return self.__width.value + } + @inline(__always) + set { + self.__width = { () -> bridge.std__optional_double_ in + if let __unwrappedValue = newValue { + return bridge.create_std__optional_double_(__unwrappedValue) + } else { + return .init() + } + }() + } + } + + var height: Double? { + @inline(__always) + get { + return self.__height.value + } + @inline(__always) + set { + self.__height = { () -> bridge.std__optional_double_ in + if let __unwrappedValue = newValue { + return bridge.create_std__optional_double_(__unwrappedValue) + } else { + return .init() + } + }() + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/ExternalSubtitle.swift b/packages/react-native-video/nitrogen/generated/ios/swift/ExternalSubtitle.swift new file mode 100644 index 00000000..1e91d7f4 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/ExternalSubtitle.swift @@ -0,0 +1,46 @@ +/// +/// ExternalSubtitle.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `ExternalSubtitle`, backed by a C++ struct. + */ +public typealias ExternalSubtitle = margelo.nitro.video.ExternalSubtitle + +public extension ExternalSubtitle { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `ExternalSubtitle`. + */ + init(uri: String, label: String) { + self.init(std.string(uri), std.string(label)) + } + + var uri: String { + @inline(__always) + get { + return String(self.__uri) + } + @inline(__always) + set { + self.__uri = std.string(newValue) + } + } + + var label: String { + @inline(__always) + get { + return String(self.__label) + } + @inline(__always) + set { + self.__label = std.string(newValue) + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_BandwidthData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_BandwidthData.swift new file mode 100644 index 00000000..df714ea9 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_BandwidthData.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_BandwidthData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ data: BandwidthData) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_BandwidthData { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ data: BandwidthData) -> Void + + public init(_ closure: @escaping (_ data: BandwidthData) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(data: BandwidthData) -> Void { + self.closure(data) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_BandwidthData`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_BandwidthData { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_TimedMetadata.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_TimedMetadata.swift new file mode 100644 index 00000000..04224e5f --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_TimedMetadata.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_TimedMetadata.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ metadata: TimedMetadata) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_TimedMetadata { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ metadata: TimedMetadata) -> Void + + public init(_ closure: @escaping (_ metadata: TimedMetadata) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(metadata: TimedMetadata) -> Void { + self.closure(metadata) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_TimedMetadata`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_TimedMetadata { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_VideoPlayerStatus.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_VideoPlayerStatus.swift new file mode 100644 index 00000000..58130add --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_VideoPlayerStatus.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_VideoPlayerStatus.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ status: VideoPlayerStatus) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_VideoPlayerStatus { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ status: VideoPlayerStatus) -> Void + + public init(_ closure: @escaping (_ status: VideoPlayerStatus) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(status: Int32) -> Void { + self.closure(margelo.nitro.video.VideoPlayerStatus(rawValue: status)!) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_VideoPlayerStatus`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_VideoPlayerStatus { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_bool.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_bool.swift new file mode 100644 index 00000000..7dfc62de --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_bool.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_bool.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ fullscreen: Bool) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_bool { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ fullscreen: Bool) -> Void + + public init(_ closure: @escaping (_ fullscreen: Bool) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(fullscreen: Bool) -> Void { + self.closure(fullscreen) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_bool`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_double.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_double.swift new file mode 100644 index 00000000..6676bcb0 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_double.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_double.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ volume: Double) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_double { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ volume: Double) -> Void + + public init(_ closure: @escaping (_ volume: Double) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(volume: Double) -> Void { + self.closure(volume) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_double`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadData.swift new file mode 100644 index 00000000..fb4cb6d9 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadData.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_onLoadData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ data: onLoadData) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_onLoadData { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ data: onLoadData) -> Void + + public init(_ closure: @escaping (_ data: onLoadData) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(data: onLoadData) -> Void { + self.closure(data) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_onLoadData`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_onLoadData { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadStartData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadStartData.swift new file mode 100644 index 00000000..25aed2bc --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onLoadStartData.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_onLoadStartData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ data: onLoadStartData) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_onLoadStartData { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ data: onLoadStartData) -> Void + + public init(_ closure: @escaping (_ data: onLoadStartData) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(data: onLoadStartData) -> Void { + self.closure(data) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_onLoadStartData`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_onLoadStartData { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onPlaybackStateChangeData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onPlaybackStateChangeData.swift new file mode 100644 index 00000000..b59f5cc0 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onPlaybackStateChangeData.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_onPlaybackStateChangeData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ data: onPlaybackStateChangeData) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_onPlaybackStateChangeData { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ data: onPlaybackStateChangeData) -> Void + + public init(_ closure: @escaping (_ data: onPlaybackStateChangeData) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(data: onPlaybackStateChangeData) -> Void { + self.closure(data) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_onPlaybackStateChangeData`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_onPlaybackStateChangeData { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onProgressData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onProgressData.swift new file mode 100644 index 00000000..4df0ea8e --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_onProgressData.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_onProgressData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ data: onProgressData) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_onProgressData { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ data: onProgressData) -> Void + + public init(_ closure: @escaping (_ data: onProgressData) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(data: onProgressData) -> Void { + self.closure(data) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_onProgressData`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_onProgressData { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift new file mode 100644 index 00000000..fd5973a4 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift @@ -0,0 +1,46 @@ +/// +/// Func_void_std__vector_std__string_.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `(_ texts: [String]) -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void_std__vector_std__string_ { + public typealias bridge = margelo.nitro.video.bridge.swift + + private let closure: (_ texts: [String]) -> Void + + public init(_ closure: @escaping (_ texts: [String]) -> Void) { + self.closure = closure + } + + @inline(__always) + public func call(texts: bridge.std__vector_std__string_) -> Void { + self.closure(texts.map({ __item in String(__item) })) + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void_std__vector_std__string_`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_std__string_ { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec.swift new file mode 100644 index 00000000..18572c5e --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec.swift @@ -0,0 +1,65 @@ +/// +/// HybridVideoPlayerEventEmitterSpec.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import Foundation +import NitroModules + +/// See ``HybridVideoPlayerEventEmitterSpec`` +public protocol HybridVideoPlayerEventEmitterSpec_protocol: HybridObject { + // Properties + var onAudioBecomingNoisy: () -> Void { get set } + var onAudioFocusChange: (_ hasAudioFocus: Bool) -> Void { get set } + var onBandwidthUpdate: (_ data: BandwidthData) -> Void { get set } + var onBuffer: (_ buffering: Bool) -> Void { get set } + var onControlsVisibleChange: (_ visible: Bool) -> Void { get set } + var onEnd: () -> Void { get set } + var onExternalPlaybackChange: (_ externalPlaybackActive: Bool) -> Void { get set } + var onLoad: (_ data: onLoadData) -> Void { get set } + var onLoadStart: (_ data: onLoadStartData) -> Void { get set } + var onPlaybackStateChange: (_ data: onPlaybackStateChangeData) -> Void { get set } + var onPlaybackRateChange: (_ rate: Double) -> Void { get set } + var onProgress: (_ data: onProgressData) -> Void { get set } + var onReadyToDisplay: () -> Void { get set } + var onSeek: (_ seekTime: Double) -> Void { get set } + var onTimedMetadata: (_ metadata: TimedMetadata) -> Void { get set } + var onTextTrackDataChanged: (_ texts: [String]) -> Void { get set } + var onVolumeChange: (_ volume: Double) -> Void { get set } + var onStatusChange: (_ status: VideoPlayerStatus) -> Void { get set } + + // Methods + +} + +/// See ``HybridVideoPlayerEventEmitterSpec`` +public class HybridVideoPlayerEventEmitterSpec_base { + private weak var cxxWrapper: HybridVideoPlayerEventEmitterSpec_cxx? = nil + public func getCxxWrapper() -> HybridVideoPlayerEventEmitterSpec_cxx { + #if DEBUG + guard self is HybridVideoPlayerEventEmitterSpec else { + fatalError("`self` is not a `HybridVideoPlayerEventEmitterSpec`! Did you accidentally inherit from `HybridVideoPlayerEventEmitterSpec_base` instead of `HybridVideoPlayerEventEmitterSpec`?") + } + #endif + if let cxxWrapper = self.cxxWrapper { + return cxxWrapper + } else { + let cxxWrapper = HybridVideoPlayerEventEmitterSpec_cxx(self as! HybridVideoPlayerEventEmitterSpec) + self.cxxWrapper = cxxWrapper + return cxxWrapper + } + } +} + +/** + * A Swift base-protocol representing the VideoPlayerEventEmitter HybridObject. + * Implement this protocol to create Swift-based instances of VideoPlayerEventEmitter. + * ```swift + * class HybridVideoPlayerEventEmitter : HybridVideoPlayerEventEmitterSpec { + * // ... + * } + * ``` + */ +public typealias HybridVideoPlayerEventEmitterSpec = HybridVideoPlayerEventEmitterSpec_protocol & HybridVideoPlayerEventEmitterSpec_base diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec_cxx.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec_cxx.swift new file mode 100644 index 00000000..0f5fd5af --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerEventEmitterSpec_cxx.swift @@ -0,0 +1,450 @@ +/// +/// HybridVideoPlayerEventEmitterSpec_cxx.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import Foundation +import NitroModules + +/** + * A class implementation that bridges HybridVideoPlayerEventEmitterSpec over to C++. + * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined. + * + * Also, some Swift types need to be bridged with special handling: + * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330) + * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper + * - Throwing methods need to be wrapped with a Result type, as exceptions cannot be propagated to C++ + */ +public class HybridVideoPlayerEventEmitterSpec_cxx { + /** + * The Swift <> C++ bridge's namespace (`margelo::nitro::video::bridge::swift`) + * from `ReactNativeVideo-Swift-Cxx-Bridge.hpp`. + * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift. + */ + public typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Holds an instance of the `HybridVideoPlayerEventEmitterSpec` Swift protocol. + */ + private var __implementation: any HybridVideoPlayerEventEmitterSpec + + /** + * Holds a weak pointer to the C++ class that wraps the Swift class. + */ + private var __cxxPart: bridge.std__weak_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ + + /** + * Create a new `HybridVideoPlayerEventEmitterSpec_cxx` that wraps the given `HybridVideoPlayerEventEmitterSpec`. + * All properties and methods bridge to C++ types. + */ + public init(_ implementation: any HybridVideoPlayerEventEmitterSpec) { + self.__implementation = implementation + self.__cxxPart = .init() + /* no base class */ + } + + /** + * Get the actual `HybridVideoPlayerEventEmitterSpec` instance this class wraps. + */ + @inline(__always) + public func getHybridVideoPlayerEventEmitterSpec() -> any HybridVideoPlayerEventEmitterSpec { + return __implementation + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `HybridVideoPlayerEventEmitterSpec_cxx`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridVideoPlayerEventEmitterSpec_cxx { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } + + /** + * Gets (or creates) the C++ part of this Hybrid Object. + * The C++ part is a `std::shared_ptr`. + */ + public func getCxxPart() -> bridge.std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ { + let cachedCxxPart = self.__cxxPart.lock() + if cachedCxxPart.__convertToBool() { + return cachedCxxPart + } else { + let newCxxPart = bridge.create_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(self.toUnsafe()) + __cxxPart = bridge.weakify_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_(newCxxPart) + return newCxxPart + } + } + + + + /** + * Get the memory size of the Swift class (plus size of any other allocations) + * so the JS VM can properly track it and garbage-collect the JS object if needed. + */ + @inline(__always) + public var memorySize: Int { + return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize + } + + // Properties + public final var onAudioBecomingNoisy: bridge.Func_void { + @inline(__always) + get { + return { () -> bridge.Func_void in + let __closureWrapper = Func_void(self.__implementation.onAudioBecomingNoisy) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onAudioBecomingNoisy = { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(newValue) + return { () -> Void in + __wrappedFunction.call() + } + }() + } + } + + public final var onAudioFocusChange: bridge.Func_void_bool { + @inline(__always) + get { + return { () -> bridge.Func_void_bool in + let __closureWrapper = Func_void_bool(self.__implementation.onAudioFocusChange) + return bridge.create_Func_void_bool(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onAudioFocusChange = { () -> (Bool) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_bool(newValue) + return { (__hasAudioFocus: Bool) -> Void in + __wrappedFunction.call(__hasAudioFocus) + } + }() + } + } + + public final var onBandwidthUpdate: bridge.Func_void_BandwidthData { + @inline(__always) + get { + return { () -> bridge.Func_void_BandwidthData in + let __closureWrapper = Func_void_BandwidthData(self.__implementation.onBandwidthUpdate) + return bridge.create_Func_void_BandwidthData(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onBandwidthUpdate = { () -> (BandwidthData) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_BandwidthData(newValue) + return { (__data: BandwidthData) -> Void in + __wrappedFunction.call(__data) + } + }() + } + } + + public final var onBuffer: bridge.Func_void_bool { + @inline(__always) + get { + return { () -> bridge.Func_void_bool in + let __closureWrapper = Func_void_bool(self.__implementation.onBuffer) + return bridge.create_Func_void_bool(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onBuffer = { () -> (Bool) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_bool(newValue) + return { (__buffering: Bool) -> Void in + __wrappedFunction.call(__buffering) + } + }() + } + } + + public final var onControlsVisibleChange: bridge.Func_void_bool { + @inline(__always) + get { + return { () -> bridge.Func_void_bool in + let __closureWrapper = Func_void_bool(self.__implementation.onControlsVisibleChange) + return bridge.create_Func_void_bool(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onControlsVisibleChange = { () -> (Bool) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_bool(newValue) + return { (__visible: Bool) -> Void in + __wrappedFunction.call(__visible) + } + }() + } + } + + public final var onEnd: bridge.Func_void { + @inline(__always) + get { + return { () -> bridge.Func_void in + let __closureWrapper = Func_void(self.__implementation.onEnd) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onEnd = { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(newValue) + return { () -> Void in + __wrappedFunction.call() + } + }() + } + } + + public final var onExternalPlaybackChange: bridge.Func_void_bool { + @inline(__always) + get { + return { () -> bridge.Func_void_bool in + let __closureWrapper = Func_void_bool(self.__implementation.onExternalPlaybackChange) + return bridge.create_Func_void_bool(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onExternalPlaybackChange = { () -> (Bool) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_bool(newValue) + return { (__externalPlaybackActive: Bool) -> Void in + __wrappedFunction.call(__externalPlaybackActive) + } + }() + } + } + + public final var onLoad: bridge.Func_void_onLoadData { + @inline(__always) + get { + return { () -> bridge.Func_void_onLoadData in + let __closureWrapper = Func_void_onLoadData(self.__implementation.onLoad) + return bridge.create_Func_void_onLoadData(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onLoad = { () -> (onLoadData) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_onLoadData(newValue) + return { (__data: onLoadData) -> Void in + __wrappedFunction.call(__data) + } + }() + } + } + + public final var onLoadStart: bridge.Func_void_onLoadStartData { + @inline(__always) + get { + return { () -> bridge.Func_void_onLoadStartData in + let __closureWrapper = Func_void_onLoadStartData(self.__implementation.onLoadStart) + return bridge.create_Func_void_onLoadStartData(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onLoadStart = { () -> (onLoadStartData) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_onLoadStartData(newValue) + return { (__data: onLoadStartData) -> Void in + __wrappedFunction.call(__data) + } + }() + } + } + + public final var onPlaybackStateChange: bridge.Func_void_onPlaybackStateChangeData { + @inline(__always) + get { + return { () -> bridge.Func_void_onPlaybackStateChangeData in + let __closureWrapper = Func_void_onPlaybackStateChangeData(self.__implementation.onPlaybackStateChange) + return bridge.create_Func_void_onPlaybackStateChangeData(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onPlaybackStateChange = { () -> (onPlaybackStateChangeData) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_onPlaybackStateChangeData(newValue) + return { (__data: onPlaybackStateChangeData) -> Void in + __wrappedFunction.call(__data) + } + }() + } + } + + public final var onPlaybackRateChange: bridge.Func_void_double { + @inline(__always) + get { + return { () -> bridge.Func_void_double in + let __closureWrapper = Func_void_double(self.__implementation.onPlaybackRateChange) + return bridge.create_Func_void_double(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onPlaybackRateChange = { () -> (Double) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_double(newValue) + return { (__rate: Double) -> Void in + __wrappedFunction.call(__rate) + } + }() + } + } + + public final var onProgress: bridge.Func_void_onProgressData { + @inline(__always) + get { + return { () -> bridge.Func_void_onProgressData in + let __closureWrapper = Func_void_onProgressData(self.__implementation.onProgress) + return bridge.create_Func_void_onProgressData(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onProgress = { () -> (onProgressData) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_onProgressData(newValue) + return { (__data: onProgressData) -> Void in + __wrappedFunction.call(__data) + } + }() + } + } + + public final var onReadyToDisplay: bridge.Func_void { + @inline(__always) + get { + return { () -> bridge.Func_void in + let __closureWrapper = Func_void(self.__implementation.onReadyToDisplay) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onReadyToDisplay = { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(newValue) + return { () -> Void in + __wrappedFunction.call() + } + }() + } + } + + public final var onSeek: bridge.Func_void_double { + @inline(__always) + get { + return { () -> bridge.Func_void_double in + let __closureWrapper = Func_void_double(self.__implementation.onSeek) + return bridge.create_Func_void_double(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onSeek = { () -> (Double) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_double(newValue) + return { (__seekTime: Double) -> Void in + __wrappedFunction.call(__seekTime) + } + }() + } + } + + public final var onTimedMetadata: bridge.Func_void_TimedMetadata { + @inline(__always) + get { + return { () -> bridge.Func_void_TimedMetadata in + let __closureWrapper = Func_void_TimedMetadata(self.__implementation.onTimedMetadata) + return bridge.create_Func_void_TimedMetadata(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onTimedMetadata = { () -> (TimedMetadata) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_TimedMetadata(newValue) + return { (__metadata: TimedMetadata) -> Void in + __wrappedFunction.call(__metadata) + } + }() + } + } + + public final var onTextTrackDataChanged: bridge.Func_void_std__vector_std__string_ { + @inline(__always) + get { + return { () -> bridge.Func_void_std__vector_std__string_ in + let __closureWrapper = Func_void_std__vector_std__string_(self.__implementation.onTextTrackDataChanged) + return bridge.create_Func_void_std__vector_std__string_(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onTextTrackDataChanged = { () -> ([String]) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_std__vector_std__string_(newValue) + return { (__texts: [String]) -> Void in + __wrappedFunction.call({ () -> bridge.std__vector_std__string_ in + var __vector = bridge.create_std__vector_std__string_(__texts.count) + for __item in __texts { + __vector.push_back(std.string(__item)) + } + return __vector + }()) + } + }() + } + } + + public final var onVolumeChange: bridge.Func_void_double { + @inline(__always) + get { + return { () -> bridge.Func_void_double in + let __closureWrapper = Func_void_double(self.__implementation.onVolumeChange) + return bridge.create_Func_void_double(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onVolumeChange = { () -> (Double) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_double(newValue) + return { (__volume: Double) -> Void in + __wrappedFunction.call(__volume) + } + }() + } + } + + public final var onStatusChange: bridge.Func_void_VideoPlayerStatus { + @inline(__always) + get { + return { () -> bridge.Func_void_VideoPlayerStatus in + let __closureWrapper = Func_void_VideoPlayerStatus(self.__implementation.onStatusChange) + return bridge.create_Func_void_VideoPlayerStatus(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.onStatusChange = { () -> (VideoPlayerStatus) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_VideoPlayerStatus(newValue) + return { (__status: VideoPlayerStatus) -> Void in + __wrappedFunction.call(__status.rawValue) + } + }() + } + } + + // Methods + +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec.swift index f4d043ab..6f0be3cd 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec.swift @@ -15,6 +15,7 @@ public protocol HybridVideoPlayerSourceFactorySpec_protocol: HybridObject { // Methods func fromUri(uri: String) throws -> (any HybridVideoPlayerSourceSpec) + func fromVideoConfig(config: NativeVideoConfig) throws -> (any HybridVideoPlayerSourceSpec) } /// See ``HybridVideoPlayerSourceFactorySpec`` diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec_cxx.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec_cxx.swift index b85ef247..e4d1f7f2 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec_cxx.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceFactorySpec_cxx.swift @@ -114,4 +114,19 @@ public class HybridVideoPlayerSourceFactorySpec_cxx { return bridge.create_Result_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec__(__exceptionPtr) } } + + @inline(__always) + public final func fromVideoConfig(config: NativeVideoConfig) -> bridge.Result_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec__ { + do { + let __result = try self.__implementation.fromVideoConfig(config: config) + let __resultCpp = { () -> bridge.std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_ in + let __cxxWrapped = __result.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }() + return bridge.create_Result_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec__(__resultCpp) + } catch (let __error) { + let __exceptionPtr = __error.toCpp() + return bridge.create_Result_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec__(__exceptionPtr) + } + } } diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec.swift index d20223ad..2c35a592 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec.swift @@ -12,6 +12,7 @@ import NitroModules public protocol HybridVideoPlayerSourceSpec_protocol: HybridObject { // Properties var uri: String { get } + var config: NativeVideoConfig { get } // Methods func getAssetInformationAsync() throws -> Promise diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec_cxx.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec_cxx.swift index 1870010f..099e5e70 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec_cxx.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSourceSpec_cxx.swift @@ -103,6 +103,13 @@ public class HybridVideoPlayerSourceSpec_cxx { return std.string(self.__implementation.uri) } } + + public final var config: NativeVideoConfig { + @inline(__always) + get { + return self.__implementation.config + } + } // Methods @inline(__always) diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec.swift index 5fc46e6a..a3bd711a 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec.swift @@ -12,6 +12,8 @@ import NitroModules public protocol HybridVideoPlayerSpec_protocol: HybridObject { // Properties var source: (any HybridVideoPlayerSourceSpec) { get } + var eventEmitter: (any HybridVideoPlayerEventEmitterSpec) { get } + var status: VideoPlayerStatus { get } var duration: Double { get } var volume: Double { get set } var currentTime: Double { get set } diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec_cxx.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec_cxx.swift index c8636a81..01cc1925 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec_cxx.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoPlayerSpec_cxx.swift @@ -107,6 +107,23 @@ public class HybridVideoPlayerSpec_cxx { } } + public final var eventEmitter: bridge.std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ { + @inline(__always) + get { + return { () -> bridge.std__shared_ptr_margelo__nitro__video__HybridVideoPlayerEventEmitterSpec_ in + let __cxxWrapped = self.__implementation.eventEmitter.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }() + } + } + + public final var status: Int32 { + @inline(__always) + get { + return self.__implementation.status.rawValue + } + } + public final var duration: Double { @inline(__always) get { diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec.swift index e5d2b3f2..ecd5cfc3 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec.swift @@ -15,6 +15,12 @@ public protocol HybridVideoViewViewManagerSpec_protocol: HybridObject { var controls: Bool { get set } var pictureInPicture: Bool { get set } var autoEnterPictureInPicture: Bool { get set } + var onPictureInPictureChange: ((_ isInPictureInPicture: Bool) -> Void)? { get set } + var onFullscreenChange: ((_ fullscreen: Bool) -> Void)? { get set } + var willEnterFullscreen: (() -> Void)? { get set } + var willExitFullscreen: (() -> Void)? { get set } + var willEnterPictureInPicture: (() -> Void)? { get set } + var willExitPictureInPicture: (() -> Void)? { get set } // Methods func enterFullscreen() throws -> Void diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec_cxx.swift b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec_cxx.swift index 45cba54a..18c18f95 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec_cxx.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/HybridVideoViewViewManagerSpec_cxx.swift @@ -159,6 +159,192 @@ public class HybridVideoViewViewManagerSpec_cxx { self.__implementation.autoEnterPictureInPicture = newValue } } + + public final var onPictureInPictureChange: bridge.std__optional_std__function_void_bool____isInPictureInPicture______ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__function_void_bool____isInPictureInPicture______ in + if let __unwrappedValue = self.__implementation.onPictureInPictureChange { + return bridge.create_std__optional_std__function_void_bool____isInPictureInPicture______({ () -> bridge.Func_void_bool in + let __closureWrapper = Func_void_bool(__unwrappedValue) + return bridge.create_Func_void_bool(__closureWrapper.toUnsafe()) + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.onPictureInPictureChange = { () -> ((_ isInPictureInPicture: Bool) -> Void)? in + if let __unwrapped = newValue.value { + return { () -> (Bool) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_bool(__unwrapped) + return { (__isInPictureInPicture: Bool) -> Void in + __wrappedFunction.call(__isInPictureInPicture) + } + }() + } else { + return nil + } + }() + } + } + + public final var onFullscreenChange: bridge.std__optional_std__function_void_bool____fullscreen______ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__function_void_bool____fullscreen______ in + if let __unwrappedValue = self.__implementation.onFullscreenChange { + return bridge.create_std__optional_std__function_void_bool____fullscreen______({ () -> bridge.Func_void_bool in + let __closureWrapper = Func_void_bool(__unwrappedValue) + return bridge.create_Func_void_bool(__closureWrapper.toUnsafe()) + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.onFullscreenChange = { () -> ((_ fullscreen: Bool) -> Void)? in + if let __unwrapped = newValue.value { + return { () -> (Bool) -> Void in + let __wrappedFunction = bridge.wrap_Func_void_bool(__unwrapped) + return { (__fullscreen: Bool) -> Void in + __wrappedFunction.call(__fullscreen) + } + }() + } else { + return nil + } + }() + } + } + + public final var willEnterFullscreen: bridge.std__optional_std__function_void____ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__function_void____ in + if let __unwrappedValue = self.__implementation.willEnterFullscreen { + return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in + let __closureWrapper = Func_void(__unwrappedValue) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.willEnterFullscreen = { () -> (() -> Void)? in + if let __unwrapped = newValue.value { + return { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(__unwrapped) + return { () -> Void in + __wrappedFunction.call() + } + }() + } else { + return nil + } + }() + } + } + + public final var willExitFullscreen: bridge.std__optional_std__function_void____ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__function_void____ in + if let __unwrappedValue = self.__implementation.willExitFullscreen { + return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in + let __closureWrapper = Func_void(__unwrappedValue) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.willExitFullscreen = { () -> (() -> Void)? in + if let __unwrapped = newValue.value { + return { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(__unwrapped) + return { () -> Void in + __wrappedFunction.call() + } + }() + } else { + return nil + } + }() + } + } + + public final var willEnterPictureInPicture: bridge.std__optional_std__function_void____ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__function_void____ in + if let __unwrappedValue = self.__implementation.willEnterPictureInPicture { + return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in + let __closureWrapper = Func_void(__unwrappedValue) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.willEnterPictureInPicture = { () -> (() -> Void)? in + if let __unwrapped = newValue.value { + return { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(__unwrapped) + return { () -> Void in + __wrappedFunction.call() + } + }() + } else { + return nil + } + }() + } + } + + public final var willExitPictureInPicture: bridge.std__optional_std__function_void____ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__function_void____ in + if let __unwrappedValue = self.__implementation.willExitPictureInPicture { + return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in + let __closureWrapper = Func_void(__unwrappedValue) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.willExitPictureInPicture = { () -> (() -> Void)? in + if let __unwrapped = newValue.value { + return { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(__unwrapped) + return { () -> Void in + __wrappedFunction.call() + } + }() + } else { + return nil + } + }() + } + } // Methods @inline(__always) diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/NativeVideoConfig.swift b/packages/react-native-video/nitrogen/generated/ios/swift/NativeVideoConfig.swift new file mode 100644 index 00000000..e0e158df --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/NativeVideoConfig.swift @@ -0,0 +1,125 @@ +/// +/// NativeVideoConfig.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `NativeVideoConfig`, backed by a C++ struct. + */ +public typealias NativeVideoConfig = margelo.nitro.video.NativeVideoConfig + +public extension NativeVideoConfig { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `NativeVideoConfig`. + */ + init(uri: String, headers: Dictionary?, externalSubtitles: [ExternalSubtitle]?) { + self.init(std.string(uri), { () -> bridge.std__optional_std__unordered_map_std__string__std__string__ in + if let __unwrappedValue = headers { + return bridge.create_std__optional_std__unordered_map_std__string__std__string__({ () -> bridge.std__unordered_map_std__string__std__string_ in + var __map = bridge.create_std__unordered_map_std__string__std__string_(__unwrappedValue.count) + for (__k, __v) in __unwrappedValue { + bridge.emplace_std__unordered_map_std__string__std__string_(&__map, std.string(__k), std.string(__v)) + } + return __map + }()) + } else { + return .init() + } + }(), { () -> bridge.std__optional_std__vector_ExternalSubtitle__ in + if let __unwrappedValue = externalSubtitles { + return bridge.create_std__optional_std__vector_ExternalSubtitle__({ () -> bridge.std__vector_ExternalSubtitle_ in + var __vector = bridge.create_std__vector_ExternalSubtitle_(__unwrappedValue.count) + for __item in __unwrappedValue { + __vector.push_back(__item) + } + return __vector + }()) + } else { + return .init() + } + }()) + } + + var uri: String { + @inline(__always) + get { + return String(self.__uri) + } + @inline(__always) + set { + self.__uri = std.string(newValue) + } + } + + var headers: Dictionary? { + @inline(__always) + get { + return { () -> Dictionary? in + if let __unwrapped = self.__headers.value { + return { () -> Dictionary in + var __dictionary = Dictionary(minimumCapacity: __unwrapped.size()) + let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(__unwrapped) + for __key in __keys { + let __value = __unwrapped[__key]! + __dictionary[String(__key)] = String(__value) + } + return __dictionary + }() + } else { + return nil + } + }() + } + @inline(__always) + set { + self.__headers = { () -> bridge.std__optional_std__unordered_map_std__string__std__string__ in + if let __unwrappedValue = newValue { + return bridge.create_std__optional_std__unordered_map_std__string__std__string__({ () -> bridge.std__unordered_map_std__string__std__string_ in + var __map = bridge.create_std__unordered_map_std__string__std__string_(__unwrappedValue.count) + for (__k, __v) in __unwrappedValue { + bridge.emplace_std__unordered_map_std__string__std__string_(&__map, std.string(__k), std.string(__v)) + } + return __map + }()) + } else { + return .init() + } + }() + } + } + + var externalSubtitles: [ExternalSubtitle]? { + @inline(__always) + get { + return { () -> [ExternalSubtitle]? in + if let __unwrapped = self.__externalSubtitles.value { + return __unwrapped.map({ __item in __item }) + } else { + return nil + } + }() + } + @inline(__always) + set { + self.__externalSubtitles = { () -> bridge.std__optional_std__vector_ExternalSubtitle__ in + if let __unwrappedValue = newValue { + return bridge.create_std__optional_std__vector_ExternalSubtitle__({ () -> bridge.std__vector_ExternalSubtitle_ in + var __vector = bridge.create_std__vector_ExternalSubtitle_(__unwrappedValue.count) + for __item in __unwrappedValue { + __vector.push_back(__item) + } + return __vector + }()) + } else { + return .init() + } + }() + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/SourceType.swift b/packages/react-native-video/nitrogen/generated/ios/swift/SourceType.swift new file mode 100644 index 00000000..4ebe3cb8 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/SourceType.swift @@ -0,0 +1,40 @@ +/// +/// SourceType.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +/** + * Represents the JS union `SourceType`, backed by a C++ enum. + */ +public typealias SourceType = margelo.nitro.video.SourceType + +public extension SourceType { + /** + * Get a SourceType for the given String value, or + * return `nil` if the given value was invalid/unknown. + */ + init?(fromString string: String) { + switch string { + case "local": + self = .local + case "network": + self = .network + default: + return nil + } + } + + /** + * Get the String value this SourceType represents. + */ + var stringValue: String { + switch self { + case .local: + return "local" + case .network: + return "network" + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadata.swift b/packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadata.swift new file mode 100644 index 00000000..b0a231b7 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadata.swift @@ -0,0 +1,47 @@ +/// +/// TimedMetadata.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `TimedMetadata`, backed by a C++ struct. + */ +public typealias TimedMetadata = margelo.nitro.video.TimedMetadata + +public extension TimedMetadata { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `TimedMetadata`. + */ + init(metadata: [TimedMetadataObject]) { + self.init({ () -> bridge.std__vector_TimedMetadataObject_ in + var __vector = bridge.create_std__vector_TimedMetadataObject_(metadata.count) + for __item in metadata { + __vector.push_back(__item) + } + return __vector + }()) + } + + var metadata: [TimedMetadataObject] { + @inline(__always) + get { + return self.__metadata.map({ __item in __item }) + } + @inline(__always) + set { + self.__metadata = { () -> bridge.std__vector_TimedMetadataObject_ in + var __vector = bridge.create_std__vector_TimedMetadataObject_(newValue.count) + for __item in newValue { + __vector.push_back(__item) + } + return __vector + }() + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadataObject.swift b/packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadataObject.swift new file mode 100644 index 00000000..70dcf655 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/TimedMetadataObject.swift @@ -0,0 +1,46 @@ +/// +/// TimedMetadataObject.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `TimedMetadataObject`, backed by a C++ struct. + */ +public typealias TimedMetadataObject = margelo.nitro.video.TimedMetadataObject + +public extension TimedMetadataObject { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `TimedMetadataObject`. + */ + init(value: String, identifier: String) { + self.init(std.string(value), std.string(identifier)) + } + + var value: String { + @inline(__always) + get { + return String(self.__value) + } + @inline(__always) + set { + self.__value = std.string(newValue) + } + } + + var identifier: String { + @inline(__always) + get { + return String(self.__identifier) + } + @inline(__always) + set { + self.__identifier = std.string(newValue) + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/VideoOrientation.swift b/packages/react-native-video/nitrogen/generated/ios/swift/VideoOrientation.swift index 37f0affd..f74ff262 100644 --- a/packages/react-native-video/nitrogen/generated/ios/swift/VideoOrientation.swift +++ b/packages/react-native-video/nitrogen/generated/ios/swift/VideoOrientation.swift @@ -27,6 +27,8 @@ public extension VideoOrientation { self = .landscapeLeft case "landscape-right": self = .landscapeRight + case "square": + self = .square case "unknown": self = .unknown default: @@ -49,6 +51,8 @@ public extension VideoOrientation { return "landscape-left" case .landscapeRight: return "landscape-right" + case .square: + return "square" case .unknown: return "unknown" } diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/VideoPlayerStatus.swift b/packages/react-native-video/nitrogen/generated/ios/swift/VideoPlayerStatus.swift new file mode 100644 index 00000000..dae121cb --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/VideoPlayerStatus.swift @@ -0,0 +1,48 @@ +/// +/// VideoPlayerStatus.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +/** + * Represents the JS union `VideoPlayerStatus`, backed by a C++ enum. + */ +public typealias VideoPlayerStatus = margelo.nitro.video.VideoPlayerStatus + +public extension VideoPlayerStatus { + /** + * Get a VideoPlayerStatus for the given String value, or + * return `nil` if the given value was invalid/unknown. + */ + init?(fromString string: String) { + switch string { + case "idle": + self = .idle + case "loading": + self = .loading + case "readyToPlay": + self = .readytoplay + case "error": + self = .error + default: + return nil + } + } + + /** + * Get the String value this VideoPlayerStatus represents. + */ + var stringValue: String { + switch self { + case .idle: + return "idle" + case .loading: + return "loading" + case .readytoplay: + return "readyToPlay" + case .error: + return "error" + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/onLoadData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/onLoadData.swift new file mode 100644 index 00000000..301d21d3 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/onLoadData.swift @@ -0,0 +1,79 @@ +/// +/// onLoadData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `onLoadData`, backed by a C++ struct. + */ +public typealias onLoadData = margelo.nitro.video.onLoadData + +public extension onLoadData { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `onLoadData`. + */ + init(currentTime: Double, duration: Double, height: Double, width: Double, orientation: VideoOrientation) { + self.init(currentTime, duration, height, width, orientation) + } + + var currentTime: Double { + @inline(__always) + get { + return self.__currentTime + } + @inline(__always) + set { + self.__currentTime = newValue + } + } + + var duration: Double { + @inline(__always) + get { + return self.__duration + } + @inline(__always) + set { + self.__duration = newValue + } + } + + var height: Double { + @inline(__always) + get { + return self.__height + } + @inline(__always) + set { + self.__height = newValue + } + } + + var width: Double { + @inline(__always) + get { + return self.__width + } + @inline(__always) + set { + self.__width = newValue + } + } + + var orientation: VideoOrientation { + @inline(__always) + get { + return self.__orientation + } + @inline(__always) + set { + self.__orientation = newValue + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/onLoadStartData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/onLoadStartData.swift new file mode 100644 index 00000000..759d0604 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/onLoadStartData.swift @@ -0,0 +1,56 @@ +/// +/// onLoadStartData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `onLoadStartData`, backed by a C++ struct. + */ +public typealias onLoadStartData = margelo.nitro.video.onLoadStartData + +public extension onLoadStartData { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `onLoadStartData`. + */ + init(sourceType: SourceType, source: (any HybridVideoPlayerSourceSpec)) { + self.init(sourceType, { () -> bridge.std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_ in + let __cxxWrapped = source.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }()) + } + + var sourceType: SourceType { + @inline(__always) + get { + return self.__sourceType + } + @inline(__always) + set { + self.__sourceType = newValue + } + } + + var source: (any HybridVideoPlayerSourceSpec) { + @inline(__always) + get { + return { () -> HybridVideoPlayerSourceSpec in + let __unsafePointer = bridge.get_std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_(self.__source) + let __instance = HybridVideoPlayerSourceSpec_cxx.fromUnsafe(__unsafePointer) + return __instance.getHybridVideoPlayerSourceSpec() + }() + } + @inline(__always) + set { + self.__source = { () -> bridge.std__shared_ptr_margelo__nitro__video__HybridVideoPlayerSourceSpec_ in + let __cxxWrapped = newValue.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }() + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/onPlaybackStateChangeData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/onPlaybackStateChangeData.swift new file mode 100644 index 00000000..daa5601e --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/onPlaybackStateChangeData.swift @@ -0,0 +1,46 @@ +/// +/// onPlaybackStateChangeData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `onPlaybackStateChangeData`, backed by a C++ struct. + */ +public typealias onPlaybackStateChangeData = margelo.nitro.video.onPlaybackStateChangeData + +public extension onPlaybackStateChangeData { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `onPlaybackStateChangeData`. + */ + init(isPlaying: Bool, isBuffering: Bool) { + self.init(isPlaying, isBuffering) + } + + var isPlaying: Bool { + @inline(__always) + get { + return self.__isPlaying + } + @inline(__always) + set { + self.__isPlaying = newValue + } + } + + var isBuffering: Bool { + @inline(__always) + get { + return self.__isBuffering + } + @inline(__always) + set { + self.__isBuffering = newValue + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/ios/swift/onProgressData.swift b/packages/react-native-video/nitrogen/generated/ios/swift/onProgressData.swift new file mode 100644 index 00000000..9eda524d --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/ios/swift/onProgressData.swift @@ -0,0 +1,46 @@ +/// +/// onProgressData.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `onProgressData`, backed by a C++ struct. + */ +public typealias onProgressData = margelo.nitro.video.onProgressData + +public extension onProgressData { + private typealias bridge = margelo.nitro.video.bridge.swift + + /** + * Create a new instance of `onProgressData`. + */ + init(currentTime: Double, bufferDuration: Double) { + self.init(currentTime, bufferDuration) + } + + var currentTime: Double { + @inline(__always) + get { + return self.__currentTime + } + @inline(__always) + set { + self.__currentTime = newValue + } + } + + var bufferDuration: Double { + @inline(__always) + get { + return self.__bufferDuration + } + @inline(__always) + set { + self.__bufferDuration = newValue + } + } +} diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/BandwidthData.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/BandwidthData.hpp new file mode 100644 index 00000000..bb8ca01a --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/BandwidthData.hpp @@ -0,0 +1,77 @@ +/// +/// BandwidthData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (BandwidthData). + */ + struct BandwidthData { + public: + double bitrate SWIFT_PRIVATE; + std::optional width SWIFT_PRIVATE; + std::optional height SWIFT_PRIVATE; + + public: + BandwidthData() = default; + explicit BandwidthData(double bitrate, std::optional width, std::optional height): bitrate(bitrate), width(width), height(height) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ BandwidthData <> JS BandwidthData (object) + template <> + struct JSIConverter final { + static inline BandwidthData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return BandwidthData( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "bitrate")), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "width")), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "height")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const BandwidthData& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "bitrate", JSIConverter::toJSI(runtime, arg.bitrate)); + obj.setProperty(runtime, "width", JSIConverter>::toJSI(runtime, arg.width)); + obj.setProperty(runtime, "height", JSIConverter>::toJSI(runtime, arg.height)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "bitrate"))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "width"))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "height"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/ExternalSubtitle.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/ExternalSubtitle.hpp new file mode 100644 index 00000000..e0735441 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/ExternalSubtitle.hpp @@ -0,0 +1,73 @@ +/// +/// ExternalSubtitle.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (ExternalSubtitle). + */ + struct ExternalSubtitle { + public: + std::string uri SWIFT_PRIVATE; + std::string label SWIFT_PRIVATE; + + public: + ExternalSubtitle() = default; + explicit ExternalSubtitle(std::string uri, std::string label): uri(uri), label(label) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ ExternalSubtitle <> JS ExternalSubtitle (object) + template <> + struct JSIConverter final { + static inline ExternalSubtitle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return ExternalSubtitle( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "uri")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "label")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const ExternalSubtitle& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "uri", JSIConverter::toJSI(runtime, arg.uri)); + obj.setProperty(runtime, "label", JSIConverter::toJSI(runtime, arg.label)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "uri"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "label"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.cpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.cpp new file mode 100644 index 00000000..b7c06882 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.cpp @@ -0,0 +1,56 @@ +/// +/// HybridVideoPlayerEventEmitterSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#include "HybridVideoPlayerEventEmitterSpec.hpp" + +namespace margelo::nitro::video { + + void HybridVideoPlayerEventEmitterSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("onAudioBecomingNoisy", &HybridVideoPlayerEventEmitterSpec::getOnAudioBecomingNoisy); + prototype.registerHybridSetter("onAudioBecomingNoisy", &HybridVideoPlayerEventEmitterSpec::setOnAudioBecomingNoisy); + prototype.registerHybridGetter("onAudioFocusChange", &HybridVideoPlayerEventEmitterSpec::getOnAudioFocusChange); + prototype.registerHybridSetter("onAudioFocusChange", &HybridVideoPlayerEventEmitterSpec::setOnAudioFocusChange); + prototype.registerHybridGetter("onBandwidthUpdate", &HybridVideoPlayerEventEmitterSpec::getOnBandwidthUpdate); + prototype.registerHybridSetter("onBandwidthUpdate", &HybridVideoPlayerEventEmitterSpec::setOnBandwidthUpdate); + prototype.registerHybridGetter("onBuffer", &HybridVideoPlayerEventEmitterSpec::getOnBuffer); + prototype.registerHybridSetter("onBuffer", &HybridVideoPlayerEventEmitterSpec::setOnBuffer); + prototype.registerHybridGetter("onControlsVisibleChange", &HybridVideoPlayerEventEmitterSpec::getOnControlsVisibleChange); + prototype.registerHybridSetter("onControlsVisibleChange", &HybridVideoPlayerEventEmitterSpec::setOnControlsVisibleChange); + prototype.registerHybridGetter("onEnd", &HybridVideoPlayerEventEmitterSpec::getOnEnd); + prototype.registerHybridSetter("onEnd", &HybridVideoPlayerEventEmitterSpec::setOnEnd); + prototype.registerHybridGetter("onExternalPlaybackChange", &HybridVideoPlayerEventEmitterSpec::getOnExternalPlaybackChange); + prototype.registerHybridSetter("onExternalPlaybackChange", &HybridVideoPlayerEventEmitterSpec::setOnExternalPlaybackChange); + prototype.registerHybridGetter("onLoad", &HybridVideoPlayerEventEmitterSpec::getOnLoad); + prototype.registerHybridSetter("onLoad", &HybridVideoPlayerEventEmitterSpec::setOnLoad); + prototype.registerHybridGetter("onLoadStart", &HybridVideoPlayerEventEmitterSpec::getOnLoadStart); + prototype.registerHybridSetter("onLoadStart", &HybridVideoPlayerEventEmitterSpec::setOnLoadStart); + prototype.registerHybridGetter("onPlaybackStateChange", &HybridVideoPlayerEventEmitterSpec::getOnPlaybackStateChange); + prototype.registerHybridSetter("onPlaybackStateChange", &HybridVideoPlayerEventEmitterSpec::setOnPlaybackStateChange); + prototype.registerHybridGetter("onPlaybackRateChange", &HybridVideoPlayerEventEmitterSpec::getOnPlaybackRateChange); + prototype.registerHybridSetter("onPlaybackRateChange", &HybridVideoPlayerEventEmitterSpec::setOnPlaybackRateChange); + prototype.registerHybridGetter("onProgress", &HybridVideoPlayerEventEmitterSpec::getOnProgress); + prototype.registerHybridSetter("onProgress", &HybridVideoPlayerEventEmitterSpec::setOnProgress); + prototype.registerHybridGetter("onReadyToDisplay", &HybridVideoPlayerEventEmitterSpec::getOnReadyToDisplay); + prototype.registerHybridSetter("onReadyToDisplay", &HybridVideoPlayerEventEmitterSpec::setOnReadyToDisplay); + prototype.registerHybridGetter("onSeek", &HybridVideoPlayerEventEmitterSpec::getOnSeek); + prototype.registerHybridSetter("onSeek", &HybridVideoPlayerEventEmitterSpec::setOnSeek); + prototype.registerHybridGetter("onTimedMetadata", &HybridVideoPlayerEventEmitterSpec::getOnTimedMetadata); + prototype.registerHybridSetter("onTimedMetadata", &HybridVideoPlayerEventEmitterSpec::setOnTimedMetadata); + prototype.registerHybridGetter("onTextTrackDataChanged", &HybridVideoPlayerEventEmitterSpec::getOnTextTrackDataChanged); + prototype.registerHybridSetter("onTextTrackDataChanged", &HybridVideoPlayerEventEmitterSpec::setOnTextTrackDataChanged); + prototype.registerHybridGetter("onVolumeChange", &HybridVideoPlayerEventEmitterSpec::getOnVolumeChange); + prototype.registerHybridSetter("onVolumeChange", &HybridVideoPlayerEventEmitterSpec::setOnVolumeChange); + prototype.registerHybridGetter("onStatusChange", &HybridVideoPlayerEventEmitterSpec::getOnStatusChange); + prototype.registerHybridSetter("onStatusChange", &HybridVideoPlayerEventEmitterSpec::setOnStatusChange); + }); + } + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.hpp new file mode 100644 index 00000000..af097da4 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerEventEmitterSpec.hpp @@ -0,0 +1,119 @@ +/// +/// HybridVideoPlayerEventEmitterSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `BandwidthData` to properly resolve imports. +namespace margelo::nitro::video { struct BandwidthData; } +// Forward declaration of `onLoadData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadData; } +// Forward declaration of `onLoadStartData` to properly resolve imports. +namespace margelo::nitro::video { struct onLoadStartData; } +// Forward declaration of `onPlaybackStateChangeData` to properly resolve imports. +namespace margelo::nitro::video { struct onPlaybackStateChangeData; } +// Forward declaration of `onProgressData` to properly resolve imports. +namespace margelo::nitro::video { struct onProgressData; } +// Forward declaration of `TimedMetadata` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadata; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } + +#include +#include "BandwidthData.hpp" +#include "onLoadData.hpp" +#include "onLoadStartData.hpp" +#include "onPlaybackStateChangeData.hpp" +#include "onProgressData.hpp" +#include "TimedMetadata.hpp" +#include +#include +#include "VideoPlayerStatus.hpp" + +namespace margelo::nitro::video { + + using namespace margelo::nitro; + + /** + * An abstract base class for `VideoPlayerEventEmitter` + * Inherit this class to create instances of `HybridVideoPlayerEventEmitterSpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridVideoPlayerEventEmitter: public HybridVideoPlayerEventEmitterSpec { + * public: + * HybridVideoPlayerEventEmitter(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridVideoPlayerEventEmitterSpec: public virtual HybridObject { + public: + // Constructor + explicit HybridVideoPlayerEventEmitterSpec(): HybridObject(TAG) { } + + // Destructor + ~HybridVideoPlayerEventEmitterSpec() override = default; + + public: + // Properties + virtual std::function getOnAudioBecomingNoisy() = 0; + virtual void setOnAudioBecomingNoisy(const std::function& onAudioBecomingNoisy) = 0; + virtual std::function getOnAudioFocusChange() = 0; + virtual void setOnAudioFocusChange(const std::function& onAudioFocusChange) = 0; + virtual std::function getOnBandwidthUpdate() = 0; + virtual void setOnBandwidthUpdate(const std::function& onBandwidthUpdate) = 0; + virtual std::function getOnBuffer() = 0; + virtual void setOnBuffer(const std::function& onBuffer) = 0; + virtual std::function getOnControlsVisibleChange() = 0; + virtual void setOnControlsVisibleChange(const std::function& onControlsVisibleChange) = 0; + virtual std::function getOnEnd() = 0; + virtual void setOnEnd(const std::function& onEnd) = 0; + virtual std::function getOnExternalPlaybackChange() = 0; + virtual void setOnExternalPlaybackChange(const std::function& onExternalPlaybackChange) = 0; + virtual std::function getOnLoad() = 0; + virtual void setOnLoad(const std::function& onLoad) = 0; + virtual std::function getOnLoadStart() = 0; + virtual void setOnLoadStart(const std::function& onLoadStart) = 0; + virtual std::function getOnPlaybackStateChange() = 0; + virtual void setOnPlaybackStateChange(const std::function& onPlaybackStateChange) = 0; + virtual std::function getOnPlaybackRateChange() = 0; + virtual void setOnPlaybackRateChange(const std::function& onPlaybackRateChange) = 0; + virtual std::function getOnProgress() = 0; + virtual void setOnProgress(const std::function& onProgress) = 0; + virtual std::function getOnReadyToDisplay() = 0; + virtual void setOnReadyToDisplay(const std::function& onReadyToDisplay) = 0; + virtual std::function getOnSeek() = 0; + virtual void setOnSeek(const std::function& onSeek) = 0; + virtual std::function getOnTimedMetadata() = 0; + virtual void setOnTimedMetadata(const std::function& onTimedMetadata) = 0; + virtual std::function& /* texts */)> getOnTextTrackDataChanged() = 0; + virtual void setOnTextTrackDataChanged(const std::function& /* texts */)>& onTextTrackDataChanged) = 0; + virtual std::function getOnVolumeChange() = 0; + virtual void setOnVolumeChange(const std::function& onVolumeChange) = 0; + virtual std::function getOnStatusChange() = 0; + virtual void setOnStatusChange(const std::function& onStatusChange) = 0; + + public: + // Methods + + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "VideoPlayerEventEmitter"; + }; + +} // namespace margelo::nitro::video diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.cpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.cpp index deaf3b9d..19677655 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.cpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.cpp @@ -15,6 +15,7 @@ namespace margelo::nitro::video { // load custom methods/properties registerHybrids(this, [](Prototype& prototype) { prototype.registerHybridMethod("fromUri", &HybridVideoPlayerSourceFactorySpec::fromUri); + prototype.registerHybridMethod("fromVideoConfig", &HybridVideoPlayerSourceFactorySpec::fromVideoConfig); }); } diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.hpp index 42ad89ae..c7e7d305 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.hpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceFactorySpec.hpp @@ -15,10 +15,13 @@ // Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } #include #include "HybridVideoPlayerSourceSpec.hpp" #include +#include "NativeVideoConfig.hpp" namespace margelo::nitro::video { @@ -52,6 +55,7 @@ namespace margelo::nitro::video { public: // Methods virtual std::shared_ptr fromUri(const std::string& uri) = 0; + virtual std::shared_ptr fromVideoConfig(const NativeVideoConfig& config) = 0; protected: // Hybrid Setup diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.cpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.cpp index c22f752b..dcf46bc4 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.cpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.cpp @@ -15,6 +15,7 @@ namespace margelo::nitro::video { // load custom methods/properties registerHybrids(this, [](Prototype& prototype) { prototype.registerHybridGetter("uri", &HybridVideoPlayerSourceSpec::getUri); + prototype.registerHybridGetter("config", &HybridVideoPlayerSourceSpec::getConfig); prototype.registerHybridMethod("getAssetInformationAsync", &HybridVideoPlayerSourceSpec::getAssetInformationAsync); }); } diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.hpp index 95fc9e31..e87441ca 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.hpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSourceSpec.hpp @@ -13,10 +13,13 @@ #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif +// Forward declaration of `NativeVideoConfig` to properly resolve imports. +namespace margelo::nitro::video { struct NativeVideoConfig; } // Forward declaration of `VideoInformation` to properly resolve imports. namespace margelo::nitro::video { struct VideoInformation; } #include +#include "NativeVideoConfig.hpp" #include #include "VideoInformation.hpp" @@ -48,6 +51,7 @@ namespace margelo::nitro::video { public: // Properties virtual std::string getUri() = 0; + virtual NativeVideoConfig getConfig() = 0; public: // Methods diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.cpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.cpp index e9427e75..3ba45ecc 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.cpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.cpp @@ -15,6 +15,8 @@ namespace margelo::nitro::video { // load custom methods/properties registerHybrids(this, [](Prototype& prototype) { prototype.registerHybridGetter("source", &HybridVideoPlayerSpec::getSource); + prototype.registerHybridGetter("eventEmitter", &HybridVideoPlayerSpec::getEventEmitter); + prototype.registerHybridGetter("status", &HybridVideoPlayerSpec::getStatus); prototype.registerHybridGetter("duration", &HybridVideoPlayerSpec::getDuration); prototype.registerHybridGetter("volume", &HybridVideoPlayerSpec::getVolume); prototype.registerHybridSetter("volume", &HybridVideoPlayerSpec::setVolume); diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.hpp index bbbc1710..78f7cfa6 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.hpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoPlayerSpec.hpp @@ -15,9 +15,15 @@ // Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } +// Forward declaration of `HybridVideoPlayerEventEmitterSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerEventEmitterSpec; } +// Forward declaration of `VideoPlayerStatus` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoPlayerStatus; } #include #include "HybridVideoPlayerSourceSpec.hpp" +#include "HybridVideoPlayerEventEmitterSpec.hpp" +#include "VideoPlayerStatus.hpp" #include namespace margelo::nitro::video { @@ -48,6 +54,8 @@ namespace margelo::nitro::video { public: // Properties virtual std::shared_ptr getSource() = 0; + virtual std::shared_ptr getEventEmitter() = 0; + virtual VideoPlayerStatus getStatus() = 0; virtual double getDuration() = 0; virtual double getVolume() = 0; virtual void setVolume(double volume) = 0; diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.cpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.cpp index a7c412e8..8748622d 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.cpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.cpp @@ -22,6 +22,18 @@ namespace margelo::nitro::video { prototype.registerHybridSetter("pictureInPicture", &HybridVideoViewViewManagerSpec::setPictureInPicture); prototype.registerHybridGetter("autoEnterPictureInPicture", &HybridVideoViewViewManagerSpec::getAutoEnterPictureInPicture); prototype.registerHybridSetter("autoEnterPictureInPicture", &HybridVideoViewViewManagerSpec::setAutoEnterPictureInPicture); + prototype.registerHybridGetter("onPictureInPictureChange", &HybridVideoViewViewManagerSpec::getOnPictureInPictureChange); + prototype.registerHybridSetter("onPictureInPictureChange", &HybridVideoViewViewManagerSpec::setOnPictureInPictureChange); + prototype.registerHybridGetter("onFullscreenChange", &HybridVideoViewViewManagerSpec::getOnFullscreenChange); + prototype.registerHybridSetter("onFullscreenChange", &HybridVideoViewViewManagerSpec::setOnFullscreenChange); + prototype.registerHybridGetter("willEnterFullscreen", &HybridVideoViewViewManagerSpec::getWillEnterFullscreen); + prototype.registerHybridSetter("willEnterFullscreen", &HybridVideoViewViewManagerSpec::setWillEnterFullscreen); + prototype.registerHybridGetter("willExitFullscreen", &HybridVideoViewViewManagerSpec::getWillExitFullscreen); + prototype.registerHybridSetter("willExitFullscreen", &HybridVideoViewViewManagerSpec::setWillExitFullscreen); + prototype.registerHybridGetter("willEnterPictureInPicture", &HybridVideoViewViewManagerSpec::getWillEnterPictureInPicture); + prototype.registerHybridSetter("willEnterPictureInPicture", &HybridVideoViewViewManagerSpec::setWillEnterPictureInPicture); + prototype.registerHybridGetter("willExitPictureInPicture", &HybridVideoViewViewManagerSpec::getWillExitPictureInPicture); + prototype.registerHybridSetter("willExitPictureInPicture", &HybridVideoViewViewManagerSpec::setWillExitPictureInPicture); prototype.registerHybridMethod("enterFullscreen", &HybridVideoViewViewManagerSpec::enterFullscreen); prototype.registerHybridMethod("exitFullscreen", &HybridVideoViewViewManagerSpec::exitFullscreen); prototype.registerHybridMethod("enterPictureInPicture", &HybridVideoViewViewManagerSpec::enterPictureInPicture); diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.hpp index 7f66bd68..4aee1569 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.hpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/HybridVideoViewViewManagerSpec.hpp @@ -19,6 +19,7 @@ namespace margelo::nitro::video { class HybridVideoPlayerSpec; } #include #include #include "HybridVideoPlayerSpec.hpp" +#include namespace margelo::nitro::video { @@ -55,6 +56,18 @@ namespace margelo::nitro::video { virtual void setPictureInPicture(bool pictureInPicture) = 0; virtual bool getAutoEnterPictureInPicture() = 0; virtual void setAutoEnterPictureInPicture(bool autoEnterPictureInPicture) = 0; + virtual std::optional> getOnPictureInPictureChange() = 0; + virtual void setOnPictureInPictureChange(const std::optional>& onPictureInPictureChange) = 0; + virtual std::optional> getOnFullscreenChange() = 0; + virtual void setOnFullscreenChange(const std::optional>& onFullscreenChange) = 0; + virtual std::optional> getWillEnterFullscreen() = 0; + virtual void setWillEnterFullscreen(const std::optional>& willEnterFullscreen) = 0; + virtual std::optional> getWillExitFullscreen() = 0; + virtual void setWillExitFullscreen(const std::optional>& willExitFullscreen) = 0; + virtual std::optional> getWillEnterPictureInPicture() = 0; + virtual void setWillEnterPictureInPicture(const std::optional>& willEnterPictureInPicture) = 0; + virtual std::optional> getWillExitPictureInPicture() = 0; + virtual void setWillExitPictureInPicture(const std::optional>& willExitPictureInPicture) = 0; public: // Methods diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/NativeVideoConfig.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/NativeVideoConfig.hpp new file mode 100644 index 00000000..6b351e1b --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/NativeVideoConfig.hpp @@ -0,0 +1,82 @@ +/// +/// NativeVideoConfig.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `ExternalSubtitle` to properly resolve imports. +namespace margelo::nitro::video { struct ExternalSubtitle; } + +#include +#include +#include +#include +#include "ExternalSubtitle.hpp" + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (NativeVideoConfig). + */ + struct NativeVideoConfig { + public: + std::string uri SWIFT_PRIVATE; + std::optional> headers SWIFT_PRIVATE; + std::optional> externalSubtitles SWIFT_PRIVATE; + + public: + NativeVideoConfig() = default; + explicit NativeVideoConfig(std::string uri, std::optional> headers, std::optional> externalSubtitles): uri(uri), headers(headers), externalSubtitles(externalSubtitles) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ NativeVideoConfig <> JS NativeVideoConfig (object) + template <> + struct JSIConverter final { + static inline NativeVideoConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return NativeVideoConfig( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "uri")), + JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, "headers")), + JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, "externalSubtitles")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const NativeVideoConfig& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "uri", JSIConverter::toJSI(runtime, arg.uri)); + obj.setProperty(runtime, "headers", JSIConverter>>::toJSI(runtime, arg.headers)); + obj.setProperty(runtime, "externalSubtitles", JSIConverter>>::toJSI(runtime, arg.externalSubtitles)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "uri"))) return false; + if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, "headers"))) return false; + if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, "externalSubtitles"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/SourceType.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/SourceType.hpp new file mode 100644 index 00000000..0035f544 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/SourceType.hpp @@ -0,0 +1,78 @@ +/// +/// SourceType.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +namespace margelo::nitro::video { + + /** + * An enum which can be represented as a JavaScript union (SourceType). + */ + enum class SourceType { + LOCAL SWIFT_NAME(local) = 0, + NETWORK SWIFT_NAME(network) = 1, + } CLOSED_ENUM; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ SourceType <> JS SourceType (union) + template <> + struct JSIConverter final { + static inline SourceType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + std::string unionValue = JSIConverter::fromJSI(runtime, arg); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("local"): return SourceType::LOCAL; + case hashString("network"): return SourceType::NETWORK; + default: [[unlikely]] + throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SourceType - invalid value!"); + } + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, SourceType arg) { + switch (arg) { + case SourceType::LOCAL: return JSIConverter::toJSI(runtime, "local"); + case SourceType::NETWORK: return JSIConverter::toJSI(runtime, "network"); + default: [[unlikely]] + throw std::invalid_argument("Cannot convert SourceType to JS - invalid value: " + + std::to_string(static_cast(arg)) + "!"); + } + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isString()) { + return false; + } + std::string unionValue = JSIConverter::fromJSI(runtime, value); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("local"): + case hashString("network"): + return true; + default: + return false; + } + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadata.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadata.hpp new file mode 100644 index 00000000..83fa6516 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadata.hpp @@ -0,0 +1,71 @@ +/// +/// TimedMetadata.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `TimedMetadataObject` to properly resolve imports. +namespace margelo::nitro::video { struct TimedMetadataObject; } + +#include +#include "TimedMetadataObject.hpp" + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (TimedMetadata). + */ + struct TimedMetadata { + public: + std::vector metadata SWIFT_PRIVATE; + + public: + TimedMetadata() = default; + explicit TimedMetadata(std::vector metadata): metadata(metadata) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ TimedMetadata <> JS TimedMetadata (object) + template <> + struct JSIConverter final { + static inline TimedMetadata fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return TimedMetadata( + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "metadata")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const TimedMetadata& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "metadata", JSIConverter>::toJSI(runtime, arg.metadata)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "metadata"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadataObject.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadataObject.hpp new file mode 100644 index 00000000..a49ebd17 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/TimedMetadataObject.hpp @@ -0,0 +1,73 @@ +/// +/// TimedMetadataObject.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (TimedMetadataObject). + */ + struct TimedMetadataObject { + public: + std::string value SWIFT_PRIVATE; + std::string identifier SWIFT_PRIVATE; + + public: + TimedMetadataObject() = default; + explicit TimedMetadataObject(std::string value, std::string identifier): value(value), identifier(identifier) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ TimedMetadataObject <> JS TimedMetadataObject (object) + template <> + struct JSIConverter final { + static inline TimedMetadataObject fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return TimedMetadataObject( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "value")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "identifier")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const TimedMetadataObject& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "value", JSIConverter::toJSI(runtime, arg.value)); + obj.setProperty(runtime, "identifier", JSIConverter::toJSI(runtime, arg.identifier)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "value"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "identifier"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/VideoOrientation.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/VideoOrientation.hpp index b40a789a..475f039e 100644 --- a/packages/react-native-video/nitrogen/generated/shared/c++/VideoOrientation.hpp +++ b/packages/react-native-video/nitrogen/generated/shared/c++/VideoOrientation.hpp @@ -34,7 +34,8 @@ namespace margelo::nitro::video { PORTRAIT_UPSIDE_DOWN SWIFT_NAME(portraitUpsideDown) = 2, LANDSCAPE_LEFT SWIFT_NAME(landscapeLeft) = 3, LANDSCAPE_RIGHT SWIFT_NAME(landscapeRight) = 4, - UNKNOWN SWIFT_NAME(unknown) = 5, + SQUARE SWIFT_NAME(square) = 5, + UNKNOWN SWIFT_NAME(unknown) = 6, } CLOSED_ENUM; } // namespace margelo::nitro::video @@ -54,6 +55,7 @@ namespace margelo::nitro { case hashString("portrait-upside-down"): return VideoOrientation::PORTRAIT_UPSIDE_DOWN; case hashString("landscape-left"): return VideoOrientation::LANDSCAPE_LEFT; case hashString("landscape-right"): return VideoOrientation::LANDSCAPE_RIGHT; + case hashString("square"): return VideoOrientation::SQUARE; case hashString("unknown"): return VideoOrientation::UNKNOWN; default: [[unlikely]] throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum VideoOrientation - invalid value!"); @@ -66,6 +68,7 @@ namespace margelo::nitro { case VideoOrientation::PORTRAIT_UPSIDE_DOWN: return JSIConverter::toJSI(runtime, "portrait-upside-down"); case VideoOrientation::LANDSCAPE_LEFT: return JSIConverter::toJSI(runtime, "landscape-left"); case VideoOrientation::LANDSCAPE_RIGHT: return JSIConverter::toJSI(runtime, "landscape-right"); + case VideoOrientation::SQUARE: return JSIConverter::toJSI(runtime, "square"); case VideoOrientation::UNKNOWN: return JSIConverter::toJSI(runtime, "unknown"); default: [[unlikely]] throw std::invalid_argument("Cannot convert VideoOrientation to JS - invalid value: " @@ -83,6 +86,7 @@ namespace margelo::nitro { case hashString("portrait-upside-down"): case hashString("landscape-left"): case hashString("landscape-right"): + case hashString("square"): case hashString("unknown"): return true; default: diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/VideoPlayerStatus.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/VideoPlayerStatus.hpp new file mode 100644 index 00000000..33ed515d --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/VideoPlayerStatus.hpp @@ -0,0 +1,86 @@ +/// +/// VideoPlayerStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +namespace margelo::nitro::video { + + /** + * An enum which can be represented as a JavaScript union (VideoPlayerStatus). + */ + enum class VideoPlayerStatus { + IDLE SWIFT_NAME(idle) = 0, + LOADING SWIFT_NAME(loading) = 1, + READYTOPLAY SWIFT_NAME(readytoplay) = 2, + ERROR SWIFT_NAME(error) = 3, + } CLOSED_ENUM; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ VideoPlayerStatus <> JS VideoPlayerStatus (union) + template <> + struct JSIConverter final { + static inline VideoPlayerStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + std::string unionValue = JSIConverter::fromJSI(runtime, arg); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("idle"): return VideoPlayerStatus::IDLE; + case hashString("loading"): return VideoPlayerStatus::LOADING; + case hashString("readyToPlay"): return VideoPlayerStatus::READYTOPLAY; + case hashString("error"): return VideoPlayerStatus::ERROR; + default: [[unlikely]] + throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum VideoPlayerStatus - invalid value!"); + } + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, VideoPlayerStatus arg) { + switch (arg) { + case VideoPlayerStatus::IDLE: return JSIConverter::toJSI(runtime, "idle"); + case VideoPlayerStatus::LOADING: return JSIConverter::toJSI(runtime, "loading"); + case VideoPlayerStatus::READYTOPLAY: return JSIConverter::toJSI(runtime, "readyToPlay"); + case VideoPlayerStatus::ERROR: return JSIConverter::toJSI(runtime, "error"); + default: [[unlikely]] + throw std::invalid_argument("Cannot convert VideoPlayerStatus to JS - invalid value: " + + std::to_string(static_cast(arg)) + "!"); + } + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isString()) { + return false; + } + std::string unionValue = JSIConverter::fromJSI(runtime, value); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("idle"): + case hashString("loading"): + case hashString("readyToPlay"): + case hashString("error"): + return true; + default: + return false; + } + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/onLoadData.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/onLoadData.hpp new file mode 100644 index 00000000..b9059cf2 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/onLoadData.hpp @@ -0,0 +1,86 @@ +/// +/// onLoadData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `VideoOrientation` to properly resolve imports. +namespace margelo::nitro::video { enum class VideoOrientation; } + +#include "VideoOrientation.hpp" + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (onLoadData). + */ + struct onLoadData { + public: + double currentTime SWIFT_PRIVATE; + double duration SWIFT_PRIVATE; + double height SWIFT_PRIVATE; + double width SWIFT_PRIVATE; + VideoOrientation orientation SWIFT_PRIVATE; + + public: + onLoadData() = default; + explicit onLoadData(double currentTime, double duration, double height, double width, VideoOrientation orientation): currentTime(currentTime), duration(duration), height(height), width(width), orientation(orientation) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ onLoadData <> JS onLoadData (object) + template <> + struct JSIConverter final { + static inline onLoadData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return onLoadData( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "currentTime")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "duration")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "height")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "width")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "orientation")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const onLoadData& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "currentTime", JSIConverter::toJSI(runtime, arg.currentTime)); + obj.setProperty(runtime, "duration", JSIConverter::toJSI(runtime, arg.duration)); + obj.setProperty(runtime, "height", JSIConverter::toJSI(runtime, arg.height)); + obj.setProperty(runtime, "width", JSIConverter::toJSI(runtime, arg.width)); + obj.setProperty(runtime, "orientation", JSIConverter::toJSI(runtime, arg.orientation)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "currentTime"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "duration"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "height"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "width"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "orientation"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/onLoadStartData.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/onLoadStartData.hpp new file mode 100644 index 00000000..41bb5b0d --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/onLoadStartData.hpp @@ -0,0 +1,78 @@ +/// +/// onLoadStartData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `SourceType` to properly resolve imports. +namespace margelo::nitro::video { enum class SourceType; } +// Forward declaration of `HybridVideoPlayerSourceSpec` to properly resolve imports. +namespace margelo::nitro::video { class HybridVideoPlayerSourceSpec; } + +#include "SourceType.hpp" +#include +#include "HybridVideoPlayerSourceSpec.hpp" + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (onLoadStartData). + */ + struct onLoadStartData { + public: + SourceType sourceType SWIFT_PRIVATE; + std::shared_ptr source SWIFT_PRIVATE; + + public: + onLoadStartData() = default; + explicit onLoadStartData(SourceType sourceType, std::shared_ptr source): sourceType(sourceType), source(source) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ onLoadStartData <> JS onLoadStartData (object) + template <> + struct JSIConverter final { + static inline onLoadStartData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return onLoadStartData( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "sourceType")), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, "source")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const onLoadStartData& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "sourceType", JSIConverter::toJSI(runtime, arg.sourceType)); + obj.setProperty(runtime, "source", JSIConverter>::toJSI(runtime, arg.source)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "sourceType"))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, "source"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/onPlaybackStateChangeData.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/onPlaybackStateChangeData.hpp new file mode 100644 index 00000000..fdeef636 --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/onPlaybackStateChangeData.hpp @@ -0,0 +1,73 @@ +/// +/// onPlaybackStateChangeData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + + + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (onPlaybackStateChangeData). + */ + struct onPlaybackStateChangeData { + public: + bool isPlaying SWIFT_PRIVATE; + bool isBuffering SWIFT_PRIVATE; + + public: + onPlaybackStateChangeData() = default; + explicit onPlaybackStateChangeData(bool isPlaying, bool isBuffering): isPlaying(isPlaying), isBuffering(isBuffering) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ onPlaybackStateChangeData <> JS onPlaybackStateChangeData (object) + template <> + struct JSIConverter final { + static inline onPlaybackStateChangeData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return onPlaybackStateChangeData( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "isPlaying")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "isBuffering")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const onPlaybackStateChangeData& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "isPlaying", JSIConverter::toJSI(runtime, arg.isPlaying)); + obj.setProperty(runtime, "isBuffering", JSIConverter::toJSI(runtime, arg.isBuffering)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "isPlaying"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "isBuffering"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/nitrogen/generated/shared/c++/onProgressData.hpp b/packages/react-native-video/nitrogen/generated/shared/c++/onProgressData.hpp new file mode 100644 index 00000000..65426fea --- /dev/null +++ b/packages/react-native-video/nitrogen/generated/shared/c++/onProgressData.hpp @@ -0,0 +1,73 @@ +/// +/// onProgressData.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © 2025 Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + + + +namespace margelo::nitro::video { + + /** + * A struct which can be represented as a JavaScript object (onProgressData). + */ + struct onProgressData { + public: + double currentTime SWIFT_PRIVATE; + double bufferDuration SWIFT_PRIVATE; + + public: + onProgressData() = default; + explicit onProgressData(double currentTime, double bufferDuration): currentTime(currentTime), bufferDuration(bufferDuration) {} + }; + +} // namespace margelo::nitro::video + +namespace margelo::nitro { + + using namespace margelo::nitro::video; + + // C++ onProgressData <> JS onProgressData (object) + template <> + struct JSIConverter final { + static inline onProgressData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return onProgressData( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "currentTime")), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, "bufferDuration")) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const onProgressData& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, "currentTime", JSIConverter::toJSI(runtime, arg.currentTime)); + obj.setProperty(runtime, "bufferDuration", JSIConverter::toJSI(runtime, arg.bufferDuration)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "currentTime"))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, "bufferDuration"))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-video/package.json b/packages/react-native-video/package.json index 38c0ebff..bfe00ed5 100644 --- a/packages/react-native-video/package.json +++ b/packages/react-native-video/package.json @@ -1,6 +1,6 @@ { "name": "react-native-video", - "version": "7.0.0-dev.3", + "version": "7.0.0-dev.4", "description": "