15 Commits

Author SHA1 Message Date
d27ef21157 Fix package lock 2025-10-04 17:35:45 +02:00
07e48afe01 Map source 2025-10-04 17:29:16 +02:00
6cdb879a8d Implement event handlers for web 2025-10-04 17:29:16 +02:00
abc58600e0 Implement html video properties using headless video 2025-10-04 17:27:05 +02:00
4348c29747 Implement VideoView for web 2025-10-04 17:27:04 +02:00
f7a4f0a99a Scaffold web 2025-10-04 17:25:18 +02:00
c3b922a95c fixup! Add shaka as an optional dependency and fix their type 2025-10-04 17:25:16 +02:00
8062a43a0a wip: Biome config (TO DELETE LATER) 2025-10-04 17:24:58 +02:00
9380428951 Add shaka as an optional dependency and fix their type 2025-10-04 17:24:58 +02:00
f379209bca Add shell.nix & editorconfig 2025-10-04 17:24:58 +02:00
Krzysztof Moch
375fbeb0eb feat: bump nitro modules (#4720) 2025-10-03 16:14:47 +02:00
Krzysztof Moch
4ebc9b7f05 feat(android): add surface type prop (#4719) 2025-10-03 15:58:29 +02:00
Krzysztof Moch
a97581ab8a chore: release 7.0.0-alpha.5 2025-10-02 13:33:03 +02:00
Krzysztof Moch
58a268c022 chore: cleanup events code 2025-10-02 13:31:21 +02:00
07b55755d1 refactor: event handler to use add/remove style (#4708) 2025-10-02 12:53:32 +02:00
61 changed files with 2183 additions and 1486 deletions

9
.editorconfig Normal file
View File

@@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

5
biome.json Normal file
View File

@@ -0,0 +1,5 @@
{
"formatter": {
"useEditorconfig": true
}
}

1499
bun.lock

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ESNext"],
"lib": ["ESNext", "dom"],
"module": "ESNext",
"moduleResolution": "bundler",
"noEmit": true,
@@ -33,4 +33,4 @@
"target": "ESNext",
"verbatimModuleSyntax": true
}
}
}

View File

@@ -87,17 +87,17 @@ import { VideoPlayer } from 'react-native-video';
const player = new VideoPlayer('https://example.com/video.mp4');
player.onLoad = (data) => {
player.addEventListener('onLoad', (data) => {
console.log('Video loaded! Duration:', data.duration);
};
});
player.onProgress = (data) => {
player.addEventListener('onProgress', (data) => {
console.log('Current time:', data.currentTime);
};
});
player.onError = (error) => {
player.addEventListener('onError', (error) => {
console.error('Player Error:', error.code, error.message);
};
});
player.play();
```
@@ -105,4 +105,4 @@ player.play();
## Clearing Events
- The `player.clearEvent(eventName)` method can be used to clear a specific native event handler.
- When a player instance is no longer needed and `player.release()` is called, all event listeners are automatically cleared
- When a player instance is no longer needed and `player.release()` is called, all event listeners are automatically cleared

View File

@@ -53,6 +53,7 @@ export default App;
| `autoEnterPictureInPicture` | `boolean` | No | `false` | Whether the video should automatically enter PiP mode when it starts playing and the app is backgrounded (behavior might vary by platform). |
| `resizeMode` | `'contain' \| 'cover' \| 'stretch' \| 'none'` | No | `'none'` | How the video should be resized to fit the view. |
| `keepScreenAwake` | `boolean` | No | `true` | Whether to keep the device screen awake while the video view is mounted. |
| `surfaceType` | `'surface' \| 'texture'` | No (Android only) | `'surface'` | (Android) Underlying native view type. `'surface'` uses a SurfaceView (better performance, no transforms/overlap), `'texture'` uses a TextureView (supports animations, transforms, overlapping UI) at a small performance cost. Ignored on iOS. |
## Events
@@ -104,4 +105,26 @@ Available methods on the `VideoViewRef`:
| `exitFullscreen()` | `() => void` | Programmatically requests the video view to exit fullscreen mode. |
| `enterPictureInPicture()` | `() => void` | Programmatically requests the video view to enter picture-in-picture mode. |
| `exitPictureInPicture()` | `() => void` | Programmatically requests the video view to exit picture-in-picture mode. |
| `canEnterPictureInPicture()` | `() => boolean` | Checks if picture-in-picture mode is currently available and supported. Returns `true` if PiP can be entered, `false` otherwise. |
| `canEnterPictureInPicture()` | `() => boolean` | Checks if picture-in-picture mode is currently available and supported. Returns `true` if PiP can be entered, `false` otherwise. |
## Android: Choosing a surface type
On Android the default rendering path uses a `SurfaceView` (set via `surfaceType="surface"`) for optimal decoding performance and lower latency. However `SurfaceView` lives in a separate window and can't be:
- Animated with transforms (scale, rotate, opacity fade)
- Clipped by parent views (rounded corners, masks)
- Overlapped reliably with sibling views (z-order issues)
If you need those UI effects, switch to `TextureView`:
```tsx
<VideoView
player={player}
surfaceType="texture"
style={{ width: 300, height: 170, borderRadius: 16, overflow: 'hidden' }}
resizeMode="cover"
controls
/>
```
Use `TextureView` only when required, as it can be slightly less performant and may increase power consumption on some devices.

View File

@@ -8,7 +8,7 @@ PODS:
- hermes-engine (0.77.2):
- hermes-engine/Pre-built (= 0.77.2)
- hermes-engine/Pre-built (0.77.2)
- NitroModules (0.28.0):
- NitroModules (0.29.8):
- DoubleConversion
- glog
- hermes-engine
@@ -1565,7 +1565,7 @@ PODS:
- React-logger (= 0.77.2)
- React-perflogger (= 0.77.2)
- React-utils (= 0.77.2)
- ReactNativeVideo (7.0.0-alpha.4):
- ReactNativeVideo (7.0.0-alpha.5):
- DoubleConversion
- glog
- hermes-engine
@@ -1844,7 +1844,7 @@ SPEC CHECKSUMS:
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8
hermes-engine: 8eb265241fa1d7095d3a40d51fd90f7dce68217c
NitroModules: 1e4150c3e3676e05209234a8a5e0e8886fc0311a
NitroModules: b4cd8f92604355343f12fc93772ff5a19571d41f
RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82
RCTDeprecation: 85b72250b63cfb54f29ca96ceb108cb9ef3c2079
RCTRequired: 567cb8f5d42b990331bfd93faad1d8999b1c1736
@@ -1904,7 +1904,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: f334cebc0beed0a72490492e978007082c03d533
ReactCodegen: 474fbb3e4bb0f1ee6c255d1955db76e13d509269
ReactCommon: 7763e59534d58e15f8f22121cdfe319040e08888
ReactNativeVideo: f365bc4f1a57ab50ddb655cda2f47bc06698a53b
ReactNativeVideo: 705a2a90d9f04afff9afd90d4ef194e1bc1135d5
ReactNativeVideoDrm: 62840ae0e184f711a2e6495c18e342a74cb598f8
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 31a098f74c16780569aebd614a0f37a907de0189

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-video-example",
"version": "7.0.0-alpha.4",
"version": "7.0.0-alpha.5",
"private": true,
"scripts": {
"android": "react-native run-android",
@@ -13,7 +13,7 @@
"@react-native-community/slider": "^4.5.6",
"react": "18.3.1",
"react-native": "^0.77.0",
"react-native-nitro-modules": "^0.28.0",
"react-native-nitro-modules": "^0.29.0",
"react-native-video": "*",
"@twg/react-native-video-drm": "*"
},

View File

@@ -1,7 +1,7 @@
{
"name": "react-native-video-monorepo",
"packageManager": "bun@1.1.42",
"version": "7.0.0-alpha.4",
"version": "7.0.0-alpha.5",
"private": true,
"repository": "https://github.com/TheWidlarzGroup/react-native-video",
"author": "TheWidlarzGroup <hi@thewidlarzgroup.com> (https://github.com/TheWidlarzGroup)",

View File

@@ -13,6 +13,12 @@
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/ReactNativeVideoDrm+autolinking.cmake)
# ```
# Define a flag to check if we are building properly
add_definitions(-DBUILDING_REACTNATIVEVIDEODRM_WITH_GENERATED_CMAKE_PROJECT)
# Enable Raw Props parsing in react-native (for Nitro Views)
add_definitions(-DRN_SERIALIZABLE_STATE)
# Add all headers that were generated by Nitrogen
include_directories(
"../nitrogen/generated/shared/c++"
@@ -32,12 +38,9 @@ target_sources(
../nitrogen/generated/android/c++/JHybridPluginManagerSpec.cpp
)
# Define a flag to check if we are building properly
add_definitions(-DBUILDING_REACTNATIVEVIDEODRM_WITH_GENERATED_CMAKE_PROJECT)
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
target_compile_definitions(
target_compile_definitions(
ReactNativeVideoDrm PRIVATE
-DFOLLY_NO_CONFIG=1
-DFOLLY_HAVE_CLOCK_GETTIME=1

View File

@@ -35,8 +35,7 @@ int initialize(JavaVM* vm) {
[]() -> std::shared_ptr<HybridObject> {
static DefaultConstructableObject<JHybridPluginManagerSpec::javaobject> object("com/margelo/nitro/videodrm/PluginManager");
auto instance = object.create();
auto globalRef = jni::make_global(instance);
return globalRef->cthis()->shared();
return instance->cthis()->shared();
}
);
});

View File

@@ -14,11 +14,11 @@
namespace margelo::nitro::videodrm::bridge::swift {
// pragma MARK: std::shared_ptr<HybridPluginManagerSpec>
std::shared_ptr<HybridPluginManagerSpec> create_std__shared_ptr_HybridPluginManagerSpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridPluginManagerSpec> create_std__shared_ptr_HybridPluginManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideoDrm::HybridPluginManagerSpec_cxx swiftPart = ReactNativeVideoDrm::HybridPluginManagerSpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::videodrm::HybridPluginManagerSpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridPluginManagerSpec_(std__shared_ptr_HybridPluginManagerSpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridPluginManagerSpec_(std__shared_ptr_HybridPluginManagerSpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::videodrm::HybridPluginManagerSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::videodrm::HybridPluginManagerSpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {

View File

@@ -32,19 +32,19 @@ namespace margelo::nitro::videodrm::bridge::swift {
* Specialized version of `std::shared_ptr<HybridPluginManagerSpec>`.
*/
using std__shared_ptr_HybridPluginManagerSpec_ = std::shared_ptr<HybridPluginManagerSpec>;
std::shared_ptr<HybridPluginManagerSpec> create_std__shared_ptr_HybridPluginManagerSpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridPluginManagerSpec_(std__shared_ptr_HybridPluginManagerSpec_ cppType);
std::shared_ptr<HybridPluginManagerSpec> create_std__shared_ptr_HybridPluginManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridPluginManagerSpec_(std__shared_ptr_HybridPluginManagerSpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridPluginManagerSpec>
using std__weak_ptr_HybridPluginManagerSpec_ = std::weak_ptr<HybridPluginManagerSpec>;
inline std__weak_ptr_HybridPluginManagerSpec_ weakify_std__shared_ptr_HybridPluginManagerSpec_(const std::shared_ptr<HybridPluginManagerSpec>& strong) { return strong; }
inline std__weak_ptr_HybridPluginManagerSpec_ weakify_std__shared_ptr_HybridPluginManagerSpec_(const std::shared_ptr<HybridPluginManagerSpec>& strong) noexcept { return strong; }
// pragma MARK: Result<void>
using Result_void_ = Result<void>;
inline Result_void_ create_Result_void_() {
inline Result_void_ create_Result_void_() noexcept {
return Result<void>::withValue();
}
inline Result_void_ create_Result_void_(const std::exception_ptr& error) {
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
return Result<void>::withError(error);
}

View File

@@ -40,7 +40,7 @@
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bun run build",
"build": "bob build",
"specs": "nitro-codegen",
"specs": "nitrogen",
"release": "release-it --only-version"
},
"keywords": [
@@ -71,12 +71,12 @@
"eslint": "^8.51.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"nitro-codegen": "^0.28.0",
"nitrogen": "^0.29.0",
"prettier": "^3.0.3",
"react": "18.3.1",
"react-native": "^0.77.0",
"react-native-builder-bob": "^0.40.13",
"react-native-nitro-modules": "^0.28.0",
"react-native-nitro-modules": "^0.29.0",
"release-it": "^17.10.0",
"typescript": "^5.8.3",
"react-native-video": "*"

View File

@@ -78,6 +78,12 @@ class HybridVideoViewViewManager(nitroId: Int): HybridVideoViewViewManagerSpec()
videoView.get()?.keepScreenAwake = value
}
override var surfaceType: SurfaceType
get() = videoView.get()?.surfaceType ?: SurfaceType.SURFACE
set(value) {
videoView.get()?.surfaceType = value
}
// View callbacks
override var onPictureInPictureChange: ((Boolean) -> Unit)? = null
set(value) {

View File

@@ -8,6 +8,7 @@ import android.os.Build
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
@@ -22,6 +23,7 @@ import com.facebook.react.bridge.ReactApplicationContext
import com.margelo.nitro.NitroModules
import com.margelo.nitro.video.HybridVideoPlayer
import com.margelo.nitro.video.ResizeMode
import com.margelo.nitro.video.SurfaceType
import com.margelo.nitro.video.VideoViewEvents
import com.twg.video.core.LibraryError
import com.twg.video.core.VideoManager
@@ -36,6 +38,8 @@ import com.twg.video.core.extensions.toAspectRatioFrameLayout
import com.twg.video.core.utils.PictureInPictureUtils
import com.twg.video.core.utils.PictureInPictureUtils.createDisabledPictureInPictureParams
import com.twg.video.core.utils.SmallVideoPlayerOptimizer
import com.twg.video.R.layout.player_view_surface
import com.twg.video.R.layout.player_view_texture
@UnstableApi
class VideoView @JvmOverloads constructor(
@@ -90,6 +94,20 @@ class VideoView @JvmOverloads constructor(
var pictureInPictureEnabled: Boolean = false
var surfaceType: SurfaceType = SurfaceType.SURFACE
set(value) {
if (field == value) return
field = value
runOnMainThread {
removeView(playerView)
playerView.player = null
playerView = createPlayerView()
playerView.player = hybridPlayer?.player
addView(playerView)
}
}
var resizeMode: ResizeMode = ResizeMode.NONE
set(value) {
field = value
@@ -101,7 +119,9 @@ class VideoView @JvmOverloads constructor(
var keepScreenAwake: Boolean
get() = playerView.keepScreenOn
set(value) {
playerView.keepScreenOn = value
runOnMainThread {
playerView.keepScreenOn = value
}
}
var events = object : VideoViewEvents {
@@ -114,15 +134,7 @@ class VideoView @JvmOverloads constructor(
}
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
// Apply optimizations based on video player size if needed
configureForSmallPlayer()
}
var playerView = createPlayerView()
var isInFullscreen: Boolean = false
set(value) {
field = value
@@ -153,6 +165,22 @@ class VideoView @JvmOverloads constructor(
playerView.resizeMode = resizeMode.toAspectRatioFrameLayout()
}
@SuppressLint("InflateParams")
private fun createPlayerView(): PlayerView {
return when (surfaceType) {
SurfaceType.SURFACE -> LayoutInflater.from(context).inflate(player_view_surface, null) as PlayerView
SurfaceType.TEXTURE -> LayoutInflater.from(context).inflate(player_view_texture, null) as PlayerView
}.apply {
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
setShutterBackgroundColor(Color.TRANSPARENT)
setShowSubtitleButton(true)
useController = false
// Apply optimizations based on video player size if needed
configureForSmallPlayer()
}
}
private val layoutRunnable = Runnable {
measure(
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),

View File

@@ -0,0 +1,7 @@
<androidx.media3.ui.PlayerView
android:id="@+id/player_view_surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:surface_type="surface_view" />

View File

@@ -0,0 +1,7 @@
<androidx.media3.ui.PlayerView
android:id="@+id/player_view_texture"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:surface_type="texture_view" />

View File

@@ -138,6 +138,9 @@ class HybridVideoViewViewManager: HybridVideoViewViewManagerSpec {
}
}
// Android only - no-op on iOS
var surfaceType: SurfaceType = .surface
func enterFullscreen() throws {
guard let view else {
throw VideoViewError.viewIsDeallocated.error()

View File

@@ -13,6 +13,12 @@
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/ReactNativeVideo+autolinking.cmake)
# ```
# Define a flag to check if we are building properly
add_definitions(-DBUILDING_REACTNATIVEVIDEO_WITH_GENERATED_CMAKE_PROJECT)
# Enable Raw Props parsing in react-native (for Nitro Views)
add_definitions(-DRN_SERIALIZABLE_STATE)
# Add all headers that were generated by Nitrogen
include_directories(
"../nitrogen/generated/shared/c++"
@@ -44,12 +50,9 @@ target_sources(
../nitrogen/generated/android/c++/JHybridVideoViewViewManagerFactorySpec.cpp
)
# Define a flag to check if we are building properly
add_definitions(-DBUILDING_REACTNATIVEVIDEO_WITH_GENERATED_CMAKE_PROJECT)
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
target_compile_definitions(
target_compile_definitions(
ReactNativeVideo PRIVATE
-DFOLLY_NO_CONFIG=1
-DFOLLY_HAVE_CLOCK_GETTIME=1

View File

@@ -75,8 +75,7 @@ int initialize(JavaVM* vm) {
[]() -> std::shared_ptr<HybridObject> {
static DefaultConstructableObject<JHybridVideoPlayerFactorySpec::javaobject> object("com/margelo/nitro/video/HybridVideoPlayerFactory");
auto instance = object.create();
auto globalRef = jni::make_global(instance);
return globalRef->cthis()->shared();
return instance->cthis()->shared();
}
);
HybridObjectRegistry::registerHybridObjectConstructor(
@@ -84,8 +83,7 @@ int initialize(JavaVM* vm) {
[]() -> std::shared_ptr<HybridObject> {
static DefaultConstructableObject<JHybridVideoPlayerSourceFactorySpec::javaobject> object("com/margelo/nitro/video/HybridVideoPlayerSourceFactory");
auto instance = object.create();
auto globalRef = jni::make_global(instance);
return globalRef->cthis()->shared();
return instance->cthis()->shared();
}
);
HybridObjectRegistry::registerHybridObjectConstructor(
@@ -93,8 +91,7 @@ int initialize(JavaVM* vm) {
[]() -> std::shared_ptr<HybridObject> {
static DefaultConstructableObject<JHybridVideoViewViewManagerFactorySpec::javaobject> object("com/margelo/nitro/video/HybridVideoViewViewManagerFactory");
auto instance = object.create();
auto globalRef = jni::make_global(instance);
return globalRef->cthis()->shared();
return instance->cthis()->shared();
}
);
});

View File

@@ -11,6 +11,8 @@
namespace margelo::nitro::video { class HybridVideoPlayerSpec; }
// Forward declaration of `ResizeMode` to properly resolve imports.
namespace margelo::nitro::video { enum class ResizeMode; }
// Forward declaration of `SurfaceType` to properly resolve imports.
namespace margelo::nitro::video { enum class SurfaceType; }
#include <memory>
#include "HybridVideoPlayerSpec.hpp"
@@ -18,6 +20,8 @@ namespace margelo::nitro::video { enum class ResizeMode; }
#include "JHybridVideoPlayerSpec.hpp"
#include "ResizeMode.hpp"
#include "JResizeMode.hpp"
#include "SurfaceType.hpp"
#include "JSurfaceType.hpp"
#include <functional>
#include "JFunc_void_bool.hpp"
#include "JFunc_void.hpp"
@@ -99,6 +103,15 @@ namespace margelo::nitro::video {
static const auto method = javaClassStatic()->getMethod<void(jboolean /* keepScreenAwake */)>("setKeepScreenAwake");
method(_javaPart, keepScreenAwake);
}
SurfaceType JHybridVideoViewViewManagerSpec::getSurfaceType() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JSurfaceType>()>("getSurfaceType");
auto __result = method(_javaPart);
return __result->toCpp();
}
void JHybridVideoViewViewManagerSpec::setSurfaceType(SurfaceType surfaceType) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSurfaceType> /* surfaceType */)>("setSurfaceType");
method(_javaPart, JSurfaceType::fromCpp(surfaceType));
}
std::optional<std::function<void(bool /* isInPictureInPicture */)>> JHybridVideoViewViewManagerSpec::getOnPictureInPictureChange() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_bool::javaobject>()>("getOnPictureInPictureChange_cxx");
auto __result = method(_javaPart);

View File

@@ -61,6 +61,8 @@ namespace margelo::nitro::video {
void setResizeMode(ResizeMode resizeMode) override;
bool getKeepScreenAwake() override;
void setKeepScreenAwake(bool keepScreenAwake) override;
SurfaceType getSurfaceType() override;
void setSurfaceType(SurfaceType surfaceType) override;
std::optional<std::function<void(bool /* isInPictureInPicture */)>> getOnPictureInPictureChange() override;
void setOnPictureInPictureChange(const std::optional<std::function<void(bool /* isInPictureInPicture */)>>& onPictureInPictureChange) override;
std::optional<std::function<void(bool /* fullscreen */)>> getOnFullscreenChange() override;

View File

@@ -0,0 +1,59 @@
///
/// JSurfaceType.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 <fbjni/fbjni.h>
#include "SurfaceType.hpp"
namespace margelo::nitro::video {
using namespace facebook;
/**
* The C++ JNI bridge between the C++ enum "SurfaceType" and the the Kotlin enum "SurfaceType".
*/
struct JSurfaceType final: public jni::JavaClass<JSurfaceType> {
public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/SurfaceType;";
public:
/**
* Convert this Java/Kotlin-based enum to the C++ enum SurfaceType.
*/
[[maybe_unused]]
[[nodiscard]]
SurfaceType toCpp() const {
static const auto clazz = javaClassStatic();
static const auto fieldOrdinal = clazz->getField<int>("value");
int ordinal = this->getFieldValue(fieldOrdinal);
return static_cast<SurfaceType>(ordinal);
}
public:
/**
* Create a Java/Kotlin-based enum with the given C++ enum's value.
*/
[[maybe_unused]]
static jni::alias_ref<JSurfaceType> fromCpp(SurfaceType value) {
static const auto clazz = javaClassStatic();
static const auto fieldSURFACE = clazz->getStaticField<JSurfaceType>("SURFACE");
static const auto fieldTEXTURE = clazz->getStaticField<JSurfaceType>("TEXTURE");
switch (value) {
case SurfaceType::SURFACE:
return clazz->getStaticFieldValue(fieldSURFACE);
case SurfaceType::TEXTURE:
return clazz->getStaticFieldValue(fieldTEXTURE);
default:
std::string stringValue = std::to_string(static_cast<int>(value));
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
}
}
};
} // namespace margelo::nitro::video

View File

@@ -73,6 +73,12 @@ abstract class HybridVideoViewViewManagerSpec: HybridObject() {
@set:Keep
abstract var keepScreenAwake: Boolean
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var surfaceType: SurfaceType
abstract var onPictureInPictureChange: ((isInPictureInPicture: Boolean) -> Unit)?
private var onPictureInPictureChange_cxx: Func_void_bool?

View File

@@ -0,0 +1,21 @@
///
/// SurfaceType.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 "SurfaceType".
*/
@DoNotStrip
@Keep
enum class SurfaceType(@DoNotStrip @Keep val value: Int) {
SURFACE(0),
TEXTURE(1);
}

View File

@@ -20,11 +20,11 @@
namespace margelo::nitro::video::bridge::swift {
// pragma MARK: std::shared_ptr<HybridVideoPlayerSourceSpec>
std::shared_ptr<HybridVideoPlayerSourceSpec> create_std__shared_ptr_HybridVideoPlayerSourceSpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoPlayerSourceSpec> create_std__shared_ptr_HybridVideoPlayerSourceSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoPlayerSourceSpec_cxx swiftPart = ReactNativeVideo::HybridVideoPlayerSourceSpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoPlayerSourceSpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerSourceSpec_(std__shared_ptr_HybridVideoPlayerSourceSpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerSourceSpec_(std__shared_ptr_HybridVideoPlayerSourceSpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoPlayerSourceSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoPlayerSourceSpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {
@@ -36,11 +36,11 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::shared_ptr<HybridVideoPlayerEventEmitterSpec>
std::shared_ptr<HybridVideoPlayerEventEmitterSpec> create_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoPlayerEventEmitterSpec> create_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx swiftPart = ReactNativeVideo::HybridVideoPlayerEventEmitterSpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoPlayerEventEmitterSpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoPlayerEventEmitterSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoPlayerEventEmitterSpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {
@@ -52,7 +52,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void()>
Func_void create_Func_void(void* _Nonnull swiftClosureWrapper) {
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
swiftClosure.call();
@@ -60,7 +60,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) {
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
swiftClosure.call(error);
@@ -68,11 +68,11 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::shared_ptr<HybridVideoPlayerSpec>
std::shared_ptr<HybridVideoPlayerSpec> create_std__shared_ptr_HybridVideoPlayerSpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoPlayerSpec> create_std__shared_ptr_HybridVideoPlayerSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoPlayerSpec_cxx swiftPart = ReactNativeVideo::HybridVideoPlayerSpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoPlayerSpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerSpec_(std__shared_ptr_HybridVideoPlayerSpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerSpec_(std__shared_ptr_HybridVideoPlayerSpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoPlayerSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoPlayerSpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {
@@ -84,11 +84,11 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::shared_ptr<HybridVideoPlayerFactorySpec>
std::shared_ptr<HybridVideoPlayerFactorySpec> create_std__shared_ptr_HybridVideoPlayerFactorySpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoPlayerFactorySpec> create_std__shared_ptr_HybridVideoPlayerFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoPlayerFactorySpec_cxx swiftPart = ReactNativeVideo::HybridVideoPlayerFactorySpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoPlayerFactorySpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerFactorySpec_(std__shared_ptr_HybridVideoPlayerFactorySpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerFactorySpec_(std__shared_ptr_HybridVideoPlayerFactorySpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoPlayerFactorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoPlayerFactorySpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {
@@ -100,7 +100,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(bool /* hasAudioFocus */)>
Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper) {
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_bool::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](bool hasAudioFocus) mutable -> void {
swiftClosure.call(hasAudioFocus);
@@ -108,7 +108,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const BandwidthData& /* data */)>
Func_void_BandwidthData create_Func_void_BandwidthData(void* _Nonnull swiftClosureWrapper) {
Func_void_BandwidthData create_Func_void_BandwidthData(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_BandwidthData::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const BandwidthData& data) mutable -> void {
swiftClosure.call(data);
@@ -116,7 +116,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const onLoadData& /* data */)>
Func_void_onLoadData create_Func_void_onLoadData(void* _Nonnull swiftClosureWrapper) {
Func_void_onLoadData create_Func_void_onLoadData(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_onLoadData::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const onLoadData& data) mutable -> void {
swiftClosure.call(data);
@@ -124,7 +124,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const onLoadStartData& /* data */)>
Func_void_onLoadStartData create_Func_void_onLoadStartData(void* _Nonnull swiftClosureWrapper) {
Func_void_onLoadStartData create_Func_void_onLoadStartData(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_onLoadStartData::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const onLoadStartData& data) mutable -> void {
swiftClosure.call(data);
@@ -132,7 +132,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const onPlaybackStateChangeData& /* data */)>
Func_void_onPlaybackStateChangeData create_Func_void_onPlaybackStateChangeData(void* _Nonnull swiftClosureWrapper) {
Func_void_onPlaybackStateChangeData create_Func_void_onPlaybackStateChangeData(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_onPlaybackStateChangeData::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const onPlaybackStateChangeData& data) mutable -> void {
swiftClosure.call(data);
@@ -140,7 +140,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(double /* rate */)>
Func_void_double create_Func_void_double(void* _Nonnull swiftClosureWrapper) {
Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_double::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](double rate) mutable -> void {
swiftClosure.call(rate);
@@ -148,7 +148,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const onProgressData& /* data */)>
Func_void_onProgressData create_Func_void_onProgressData(void* _Nonnull swiftClosureWrapper) {
Func_void_onProgressData create_Func_void_onProgressData(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_onProgressData::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const onProgressData& data) mutable -> void {
swiftClosure.call(data);
@@ -156,7 +156,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const TimedMetadata& /* metadata */)>
Func_void_TimedMetadata create_Func_void_TimedMetadata(void* _Nonnull swiftClosureWrapper) {
Func_void_TimedMetadata create_Func_void_TimedMetadata(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_TimedMetadata::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const TimedMetadata& metadata) mutable -> void {
swiftClosure.call(metadata);
@@ -164,7 +164,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const std::vector<std::string>& /* texts */)>
Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* _Nonnull swiftClosureWrapper) {
Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_std__vector_std__string_::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const std::vector<std::string>& texts) mutable -> void {
swiftClosure.call(texts);
@@ -172,7 +172,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const std::optional<TextTrack>& /* track */)>
Func_void_std__optional_TextTrack_ create_Func_void_std__optional_TextTrack_(void* _Nonnull swiftClosureWrapper) {
Func_void_std__optional_TextTrack_ create_Func_void_std__optional_TextTrack_(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_std__optional_TextTrack_::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const std::optional<TextTrack>& track) mutable -> void {
swiftClosure.call(track);
@@ -180,7 +180,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const onVolumeChangeData& /* data */)>
Func_void_onVolumeChangeData create_Func_void_onVolumeChangeData(void* _Nonnull swiftClosureWrapper) {
Func_void_onVolumeChangeData create_Func_void_onVolumeChangeData(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_onVolumeChangeData::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const onVolumeChangeData& data) mutable -> void {
swiftClosure.call(data);
@@ -188,7 +188,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(VideoPlayerStatus /* status */)>
Func_void_VideoPlayerStatus create_Func_void_VideoPlayerStatus(void* _Nonnull swiftClosureWrapper) {
Func_void_VideoPlayerStatus create_Func_void_VideoPlayerStatus(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_VideoPlayerStatus::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](VideoPlayerStatus status) mutable -> void {
swiftClosure.call(static_cast<int>(status));
@@ -196,7 +196,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const std::string& /* result */)>
Func_void_std__string create_Func_void_std__string(void* _Nonnull swiftClosureWrapper) {
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
swiftClosure.call(result);
@@ -204,7 +204,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>
Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(void* _Nonnull swiftClosureWrapper) {
Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const OnGetLicensePayload& payload) mutable -> std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> {
auto __result = swiftClosure.call(payload);
@@ -213,7 +213,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const std::shared_ptr<Promise<std::string>>& /* result */)>
Func_void_std__shared_ptr_Promise_std__string__ create_Func_void_std__shared_ptr_Promise_std__string__(void* _Nonnull swiftClosureWrapper) {
Func_void_std__shared_ptr_Promise_std__string__ create_Func_void_std__shared_ptr_Promise_std__string__(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_std__shared_ptr_Promise_std__string__::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<Promise<std::string>>& result) mutable -> void {
swiftClosure.call(result);
@@ -221,7 +221,7 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::function<void(const VideoInformation& /* result */)>
Func_void_VideoInformation create_Func_void_VideoInformation(void* _Nonnull swiftClosureWrapper) {
Func_void_VideoInformation create_Func_void_VideoInformation(void* NON_NULL swiftClosureWrapper) noexcept {
auto swiftClosure = ReactNativeVideo::Func_void_VideoInformation::fromUnsafe(swiftClosureWrapper);
return [swiftClosure = std::move(swiftClosure)](const VideoInformation& result) mutable -> void {
swiftClosure.call(result);
@@ -229,11 +229,11 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::shared_ptr<HybridVideoPlayerSourceFactorySpec>
std::shared_ptr<HybridVideoPlayerSourceFactorySpec> create_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoPlayerSourceFactorySpec> create_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoPlayerSourceFactorySpec_cxx swiftPart = ReactNativeVideo::HybridVideoPlayerSourceFactorySpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoPlayerSourceFactorySpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(std__shared_ptr_HybridVideoPlayerSourceFactorySpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(std__shared_ptr_HybridVideoPlayerSourceFactorySpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoPlayerSourceFactorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoPlayerSourceFactorySpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {
@@ -245,11 +245,11 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::shared_ptr<HybridVideoViewViewManagerSpec>
std::shared_ptr<HybridVideoViewViewManagerSpec> create_std__shared_ptr_HybridVideoViewViewManagerSpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoViewViewManagerSpec> create_std__shared_ptr_HybridVideoViewViewManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoViewViewManagerSpec_cxx swiftPart = ReactNativeVideo::HybridVideoViewViewManagerSpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoViewViewManagerSpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoViewViewManagerSpec_(std__shared_ptr_HybridVideoViewViewManagerSpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoViewViewManagerSpec_(std__shared_ptr_HybridVideoViewViewManagerSpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoViewViewManagerSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoViewViewManagerSpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {
@@ -261,11 +261,11 @@ namespace margelo::nitro::video::bridge::swift {
}
// pragma MARK: std::shared_ptr<HybridVideoViewViewManagerFactorySpec>
std::shared_ptr<HybridVideoViewViewManagerFactorySpec> create_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(void* _Nonnull swiftUnsafePointer) {
std::shared_ptr<HybridVideoViewViewManagerFactorySpec> create_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
ReactNativeVideo::HybridVideoViewViewManagerFactorySpec_cxx swiftPart = ReactNativeVideo::HybridVideoViewViewManagerFactorySpec_cxx::fromUnsafe(swiftUnsafePointer);
return std::make_shared<margelo::nitro::video::HybridVideoViewViewManagerFactorySpecSwift>(swiftPart);
}
void* _Nonnull get_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(std__shared_ptr_HybridVideoViewViewManagerFactorySpec_ cppType) {
void* NON_NULL get_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(std__shared_ptr_HybridVideoViewViewManagerFactorySpec_ cppType) noexcept {
std::shared_ptr<margelo::nitro::video::HybridVideoViewViewManagerFactorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::video::HybridVideoViewViewManagerFactorySpecSwift>(cppType);
#ifdef NITRO_DEBUG
if (swiftWrapper == nullptr) [[unlikely]] {

View File

@@ -107,6 +107,7 @@ namespace ReactNativeVideo { class HybridVideoViewViewManagerSpec_cxx; }
#include "onPlaybackStateChangeData.hpp"
#include "onProgressData.hpp"
#include "onVolumeChangeData.hpp"
#include <NitroModules/FastVectorCopy.hpp>
#include <NitroModules/Promise.hpp>
#include <NitroModules/PromiseHolder.hpp>
#include <NitroModules/Result.hpp>
@@ -129,34 +130,34 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::shared_ptr<HybridVideoPlayerSourceSpec>`.
*/
using std__shared_ptr_HybridVideoPlayerSourceSpec_ = std::shared_ptr<HybridVideoPlayerSourceSpec>;
std::shared_ptr<HybridVideoPlayerSourceSpec> create_std__shared_ptr_HybridVideoPlayerSourceSpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerSourceSpec_(std__shared_ptr_HybridVideoPlayerSourceSpec_ cppType);
std::shared_ptr<HybridVideoPlayerSourceSpec> create_std__shared_ptr_HybridVideoPlayerSourceSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerSourceSpec_(std__shared_ptr_HybridVideoPlayerSourceSpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoPlayerSourceSpec>
using std__weak_ptr_HybridVideoPlayerSourceSpec_ = std::weak_ptr<HybridVideoPlayerSourceSpec>;
inline std__weak_ptr_HybridVideoPlayerSourceSpec_ weakify_std__shared_ptr_HybridVideoPlayerSourceSpec_(const std::shared_ptr<HybridVideoPlayerSourceSpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoPlayerSourceSpec_ weakify_std__shared_ptr_HybridVideoPlayerSourceSpec_(const std::shared_ptr<HybridVideoPlayerSourceSpec>& strong) noexcept { return strong; }
// pragma MARK: std::shared_ptr<HybridVideoPlayerEventEmitterSpec>
/**
* Specialized version of `std::shared_ptr<HybridVideoPlayerEventEmitterSpec>`.
*/
using std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ = std::shared_ptr<HybridVideoPlayerEventEmitterSpec>;
std::shared_ptr<HybridVideoPlayerEventEmitterSpec> create_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ cppType);
std::shared_ptr<HybridVideoPlayerEventEmitterSpec> create_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoPlayerEventEmitterSpec>
using std__weak_ptr_HybridVideoPlayerEventEmitterSpec_ = std::weak_ptr<HybridVideoPlayerEventEmitterSpec>;
inline std__weak_ptr_HybridVideoPlayerEventEmitterSpec_ weakify_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(const std::shared_ptr<HybridVideoPlayerEventEmitterSpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoPlayerEventEmitterSpec_ weakify_std__shared_ptr_HybridVideoPlayerEventEmitterSpec_(const std::shared_ptr<HybridVideoPlayerEventEmitterSpec>& strong) noexcept { return strong; }
// pragma MARK: std::shared_ptr<Promise<void>>
/**
* Specialized version of `std::shared_ptr<Promise<void>>`.
*/
using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() {
inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
return Promise<void>::create();
}
inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) {
inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
return PromiseHolder<void>(std::move(promise));
}
@@ -171,14 +172,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_Wrapper final {
public:
explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
inline void call() const {
inline void call() const noexcept {
_function->operator()();
}
private:
std::unique_ptr<std::function<void()>> _function;
} SWIFT_NONCOPYABLE;
Func_void create_Func_void(void* _Nonnull swiftClosureWrapper);
inline Func_void_Wrapper wrap_Func_void(Func_void value) {
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
return Func_void_Wrapper(std::move(value));
}
@@ -193,14 +194,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_std__exception_ptr_Wrapper final {
public:
explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
inline void call(std::exception_ptr error) const {
inline void call(std::exception_ptr error) const noexcept {
_function->operator()(error);
}
private:
std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper);
inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) {
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
return Func_void_std__exception_ptr_Wrapper(std::move(value));
}
@@ -209,28 +210,41 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>>`.
*/
using std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__ = std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>>;
inline std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>> create_std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::shared_ptr<HybridVideoPlayerSourceSpec>& value) {
inline std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>> create_std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::shared_ptr<HybridVideoPlayerSourceSpec>& value) noexcept {
return std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>>(value);
}
inline bool has_value_std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>>& optional) noexcept {
return optional.has_value();
}
inline std::shared_ptr<HybridVideoPlayerSourceSpec> get_std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<std::string>
/**
* Specialized version of `std::optional<std::string>`.
*/
using std__optional_std__string_ = std::optional<std::string>;
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) {
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
return std::optional<std::string>(value);
}
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
return optional.has_value();
}
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
return *optional;
}
// pragma MARK: std::vector<TextTrack>
/**
* Specialized version of `std::vector<TextTrack>`.
*/
using std__vector_TextTrack_ = std::vector<TextTrack>;
inline std::vector<TextTrack> create_std__vector_TextTrack_(size_t size) {
std::vector<TextTrack> vector;
vector.reserve(size);
return vector;
inline std::vector<TextTrack> copy_std__vector_TextTrack_(const TextTrack* CONTIGUOUS_MEMORY NON_NULL data, size_t size) noexcept {
return margelo::nitro::FastVectorCopy<TextTrack>(data, size);
}
inline const TextTrack* CONTIGUOUS_MEMORY NON_NULL get_data_std__vector_TextTrack_(const std::vector<TextTrack>& vector) noexcept {
return vector.data();
}
// pragma MARK: std::optional<TextTrack>
@@ -238,46 +252,52 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<TextTrack>`.
*/
using std__optional_TextTrack_ = std::optional<TextTrack>;
inline std::optional<TextTrack> create_std__optional_TextTrack_(const TextTrack& value) {
inline std::optional<TextTrack> create_std__optional_TextTrack_(const TextTrack& value) noexcept {
return std::optional<TextTrack>(value);
}
inline bool has_value_std__optional_TextTrack_(const std::optional<TextTrack>& optional) noexcept {
return optional.has_value();
}
inline TextTrack get_std__optional_TextTrack_(const std::optional<TextTrack>& optional) noexcept {
return *optional;
}
// pragma MARK: std::shared_ptr<HybridVideoPlayerSpec>
/**
* Specialized version of `std::shared_ptr<HybridVideoPlayerSpec>`.
*/
using std__shared_ptr_HybridVideoPlayerSpec_ = std::shared_ptr<HybridVideoPlayerSpec>;
std::shared_ptr<HybridVideoPlayerSpec> create_std__shared_ptr_HybridVideoPlayerSpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerSpec_(std__shared_ptr_HybridVideoPlayerSpec_ cppType);
std::shared_ptr<HybridVideoPlayerSpec> create_std__shared_ptr_HybridVideoPlayerSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerSpec_(std__shared_ptr_HybridVideoPlayerSpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoPlayerSpec>
using std__weak_ptr_HybridVideoPlayerSpec_ = std::weak_ptr<HybridVideoPlayerSpec>;
inline std__weak_ptr_HybridVideoPlayerSpec_ weakify_std__shared_ptr_HybridVideoPlayerSpec_(const std::shared_ptr<HybridVideoPlayerSpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoPlayerSpec_ weakify_std__shared_ptr_HybridVideoPlayerSpec_(const std::shared_ptr<HybridVideoPlayerSpec>& strong) noexcept { return strong; }
// pragma MARK: Result<std::shared_ptr<Promise<void>>>
using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) {
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
return Result<std::shared_ptr<Promise<void>>>::withValue(value);
}
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) {
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
return Result<std::shared_ptr<Promise<void>>>::withError(error);
}
// pragma MARK: Result<std::vector<TextTrack>>
using Result_std__vector_TextTrack__ = Result<std::vector<TextTrack>>;
inline Result_std__vector_TextTrack__ create_Result_std__vector_TextTrack__(const std::vector<TextTrack>& value) {
inline Result_std__vector_TextTrack__ create_Result_std__vector_TextTrack__(const std::vector<TextTrack>& value) noexcept {
return Result<std::vector<TextTrack>>::withValue(value);
}
inline Result_std__vector_TextTrack__ create_Result_std__vector_TextTrack__(const std::exception_ptr& error) {
inline Result_std__vector_TextTrack__ create_Result_std__vector_TextTrack__(const std::exception_ptr& error) noexcept {
return Result<std::vector<TextTrack>>::withError(error);
}
// pragma MARK: Result<void>
using Result_void_ = Result<void>;
inline Result_void_ create_Result_void_() {
inline Result_void_ create_Result_void_() noexcept {
return Result<void>::withValue();
}
inline Result_void_ create_Result_void_(const std::exception_ptr& error) {
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
return Result<void>::withError(error);
}
@@ -286,19 +306,19 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::shared_ptr<HybridVideoPlayerFactorySpec>`.
*/
using std__shared_ptr_HybridVideoPlayerFactorySpec_ = std::shared_ptr<HybridVideoPlayerFactorySpec>;
std::shared_ptr<HybridVideoPlayerFactorySpec> create_std__shared_ptr_HybridVideoPlayerFactorySpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerFactorySpec_(std__shared_ptr_HybridVideoPlayerFactorySpec_ cppType);
std::shared_ptr<HybridVideoPlayerFactorySpec> create_std__shared_ptr_HybridVideoPlayerFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerFactorySpec_(std__shared_ptr_HybridVideoPlayerFactorySpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoPlayerFactorySpec>
using std__weak_ptr_HybridVideoPlayerFactorySpec_ = std::weak_ptr<HybridVideoPlayerFactorySpec>;
inline std__weak_ptr_HybridVideoPlayerFactorySpec_ weakify_std__shared_ptr_HybridVideoPlayerFactorySpec_(const std::shared_ptr<HybridVideoPlayerFactorySpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoPlayerFactorySpec_ weakify_std__shared_ptr_HybridVideoPlayerFactorySpec_(const std::shared_ptr<HybridVideoPlayerFactorySpec>& strong) noexcept { return strong; }
// pragma MARK: Result<std::shared_ptr<HybridVideoPlayerSpec>>
using Result_std__shared_ptr_HybridVideoPlayerSpec__ = Result<std::shared_ptr<HybridVideoPlayerSpec>>;
inline Result_std__shared_ptr_HybridVideoPlayerSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSpec__(const std::shared_ptr<HybridVideoPlayerSpec>& value) {
inline Result_std__shared_ptr_HybridVideoPlayerSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSpec__(const std::shared_ptr<HybridVideoPlayerSpec>& value) noexcept {
return Result<std::shared_ptr<HybridVideoPlayerSpec>>::withValue(value);
}
inline Result_std__shared_ptr_HybridVideoPlayerSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSpec__(const std::exception_ptr& error) {
inline Result_std__shared_ptr_HybridVideoPlayerSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSpec__(const std::exception_ptr& error) noexcept {
return Result<std::shared_ptr<HybridVideoPlayerSpec>>::withError(error);
}
@@ -313,14 +333,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_bool_Wrapper final {
public:
explicit Func_void_bool_Wrapper(std::function<void(bool /* hasAudioFocus */)>&& func): _function(std::make_unique<std::function<void(bool /* hasAudioFocus */)>>(std::move(func))) {}
inline void call(bool hasAudioFocus) const {
inline void call(bool hasAudioFocus) const noexcept {
_function->operator()(hasAudioFocus);
}
private:
std::unique_ptr<std::function<void(bool /* hasAudioFocus */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper);
inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) {
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) noexcept {
return Func_void_bool_Wrapper(std::move(value));
}
@@ -329,9 +349,15 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<double>`.
*/
using std__optional_double_ = std::optional<double>;
inline std::optional<double> create_std__optional_double_(const double& value) {
inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
return std::optional<double>(value);
}
inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
return optional.has_value();
}
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
return *optional;
}
// pragma MARK: std::function<void(const BandwidthData& /* data */)>
/**
@@ -344,14 +370,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_BandwidthData_Wrapper final {
public:
explicit Func_void_BandwidthData_Wrapper(std::function<void(const BandwidthData& /* data */)>&& func): _function(std::make_unique<std::function<void(const BandwidthData& /* data */)>>(std::move(func))) {}
inline void call(BandwidthData data) const {
inline void call(BandwidthData data) const noexcept {
_function->operator()(data);
}
private:
std::unique_ptr<std::function<void(const BandwidthData& /* data */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_BandwidthData create_Func_void_BandwidthData(void* _Nonnull swiftClosureWrapper);
inline Func_void_BandwidthData_Wrapper wrap_Func_void_BandwidthData(Func_void_BandwidthData value) {
Func_void_BandwidthData create_Func_void_BandwidthData(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_BandwidthData_Wrapper wrap_Func_void_BandwidthData(Func_void_BandwidthData value) noexcept {
return Func_void_BandwidthData_Wrapper(std::move(value));
}
@@ -366,14 +392,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_onLoadData_Wrapper final {
public:
explicit Func_void_onLoadData_Wrapper(std::function<void(const onLoadData& /* data */)>&& func): _function(std::make_unique<std::function<void(const onLoadData& /* data */)>>(std::move(func))) {}
inline void call(onLoadData data) const {
inline void call(onLoadData data) const noexcept {
_function->operator()(data);
}
private:
std::unique_ptr<std::function<void(const onLoadData& /* data */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_onLoadData create_Func_void_onLoadData(void* _Nonnull swiftClosureWrapper);
inline Func_void_onLoadData_Wrapper wrap_Func_void_onLoadData(Func_void_onLoadData value) {
Func_void_onLoadData create_Func_void_onLoadData(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_onLoadData_Wrapper wrap_Func_void_onLoadData(Func_void_onLoadData value) noexcept {
return Func_void_onLoadData_Wrapper(std::move(value));
}
@@ -388,14 +414,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_onLoadStartData_Wrapper final {
public:
explicit Func_void_onLoadStartData_Wrapper(std::function<void(const onLoadStartData& /* data */)>&& func): _function(std::make_unique<std::function<void(const onLoadStartData& /* data */)>>(std::move(func))) {}
inline void call(onLoadStartData data) const {
inline void call(onLoadStartData data) const noexcept {
_function->operator()(data);
}
private:
std::unique_ptr<std::function<void(const onLoadStartData& /* data */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_onLoadStartData create_Func_void_onLoadStartData(void* _Nonnull swiftClosureWrapper);
inline Func_void_onLoadStartData_Wrapper wrap_Func_void_onLoadStartData(Func_void_onLoadStartData value) {
Func_void_onLoadStartData create_Func_void_onLoadStartData(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_onLoadStartData_Wrapper wrap_Func_void_onLoadStartData(Func_void_onLoadStartData value) noexcept {
return Func_void_onLoadStartData_Wrapper(std::move(value));
}
@@ -410,14 +436,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_onPlaybackStateChangeData_Wrapper final {
public:
explicit Func_void_onPlaybackStateChangeData_Wrapper(std::function<void(const onPlaybackStateChangeData& /* data */)>&& func): _function(std::make_unique<std::function<void(const onPlaybackStateChangeData& /* data */)>>(std::move(func))) {}
inline void call(onPlaybackStateChangeData data) const {
inline void call(onPlaybackStateChangeData data) const noexcept {
_function->operator()(data);
}
private:
std::unique_ptr<std::function<void(const onPlaybackStateChangeData& /* data */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_onPlaybackStateChangeData create_Func_void_onPlaybackStateChangeData(void* _Nonnull swiftClosureWrapper);
inline Func_void_onPlaybackStateChangeData_Wrapper wrap_Func_void_onPlaybackStateChangeData(Func_void_onPlaybackStateChangeData value) {
Func_void_onPlaybackStateChangeData create_Func_void_onPlaybackStateChangeData(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_onPlaybackStateChangeData_Wrapper wrap_Func_void_onPlaybackStateChangeData(Func_void_onPlaybackStateChangeData value) noexcept {
return Func_void_onPlaybackStateChangeData_Wrapper(std::move(value));
}
@@ -432,14 +458,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_double_Wrapper final {
public:
explicit Func_void_double_Wrapper(std::function<void(double /* rate */)>&& func): _function(std::make_unique<std::function<void(double /* rate */)>>(std::move(func))) {}
inline void call(double rate) const {
inline void call(double rate) const noexcept {
_function->operator()(rate);
}
private:
std::unique_ptr<std::function<void(double /* rate */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_double create_Func_void_double(void* _Nonnull swiftClosureWrapper);
inline Func_void_double_Wrapper wrap_Func_void_double(Func_void_double value) {
Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_double_Wrapper wrap_Func_void_double(Func_void_double value) noexcept {
return Func_void_double_Wrapper(std::move(value));
}
@@ -454,14 +480,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_onProgressData_Wrapper final {
public:
explicit Func_void_onProgressData_Wrapper(std::function<void(const onProgressData& /* data */)>&& func): _function(std::make_unique<std::function<void(const onProgressData& /* data */)>>(std::move(func))) {}
inline void call(onProgressData data) const {
inline void call(onProgressData data) const noexcept {
_function->operator()(data);
}
private:
std::unique_ptr<std::function<void(const onProgressData& /* data */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_onProgressData create_Func_void_onProgressData(void* _Nonnull swiftClosureWrapper);
inline Func_void_onProgressData_Wrapper wrap_Func_void_onProgressData(Func_void_onProgressData value) {
Func_void_onProgressData create_Func_void_onProgressData(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_onProgressData_Wrapper wrap_Func_void_onProgressData(Func_void_onProgressData value) noexcept {
return Func_void_onProgressData_Wrapper(std::move(value));
}
@@ -470,10 +496,11 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::vector<TimedMetadataObject>`.
*/
using std__vector_TimedMetadataObject_ = std::vector<TimedMetadataObject>;
inline std::vector<TimedMetadataObject> create_std__vector_TimedMetadataObject_(size_t size) {
std::vector<TimedMetadataObject> vector;
vector.reserve(size);
return vector;
inline std::vector<TimedMetadataObject> copy_std__vector_TimedMetadataObject_(const TimedMetadataObject* CONTIGUOUS_MEMORY NON_NULL data, size_t size) noexcept {
return margelo::nitro::FastVectorCopy<TimedMetadataObject>(data, size);
}
inline const TimedMetadataObject* CONTIGUOUS_MEMORY NON_NULL get_data_std__vector_TimedMetadataObject_(const std::vector<TimedMetadataObject>& vector) noexcept {
return vector.data();
}
// pragma MARK: std::function<void(const TimedMetadata& /* metadata */)>
@@ -487,14 +514,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_TimedMetadata_Wrapper final {
public:
explicit Func_void_TimedMetadata_Wrapper(std::function<void(const TimedMetadata& /* metadata */)>&& func): _function(std::make_unique<std::function<void(const TimedMetadata& /* metadata */)>>(std::move(func))) {}
inline void call(TimedMetadata metadata) const {
inline void call(TimedMetadata metadata) const noexcept {
_function->operator()(metadata);
}
private:
std::unique_ptr<std::function<void(const TimedMetadata& /* metadata */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_TimedMetadata create_Func_void_TimedMetadata(void* _Nonnull swiftClosureWrapper);
inline Func_void_TimedMetadata_Wrapper wrap_Func_void_TimedMetadata(Func_void_TimedMetadata value) {
Func_void_TimedMetadata create_Func_void_TimedMetadata(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_TimedMetadata_Wrapper wrap_Func_void_TimedMetadata(Func_void_TimedMetadata value) noexcept {
return Func_void_TimedMetadata_Wrapper(std::move(value));
}
@@ -503,7 +530,7 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::vector<std::string>`.
*/
using std__vector_std__string_ = std::vector<std::string>;
inline std::vector<std::string> create_std__vector_std__string_(size_t size) {
inline std::vector<std::string> create_std__vector_std__string_(size_t size) noexcept {
std::vector<std::string> vector;
vector.reserve(size);
return vector;
@@ -520,14 +547,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_std__vector_std__string__Wrapper final {
public:
explicit Func_void_std__vector_std__string__Wrapper(std::function<void(const std::vector<std::string>& /* texts */)>&& func): _function(std::make_unique<std::function<void(const std::vector<std::string>& /* texts */)>>(std::move(func))) {}
inline void call(std::vector<std::string> texts) const {
inline void call(std::vector<std::string> texts) const noexcept {
_function->operator()(texts);
}
private:
std::unique_ptr<std::function<void(const std::vector<std::string>& /* texts */)>> _function;
} SWIFT_NONCOPYABLE;
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) {
Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_std__vector_std__string__Wrapper wrap_Func_void_std__vector_std__string_(Func_void_std__vector_std__string_ value) noexcept {
return Func_void_std__vector_std__string__Wrapper(std::move(value));
}
@@ -542,14 +569,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_std__optional_TextTrack__Wrapper final {
public:
explicit Func_void_std__optional_TextTrack__Wrapper(std::function<void(const std::optional<TextTrack>& /* track */)>&& func): _function(std::make_unique<std::function<void(const std::optional<TextTrack>& /* track */)>>(std::move(func))) {}
inline void call(std::optional<TextTrack> track) const {
inline void call(std::optional<TextTrack> track) const noexcept {
_function->operator()(track);
}
private:
std::unique_ptr<std::function<void(const std::optional<TextTrack>& /* track */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_std__optional_TextTrack_ create_Func_void_std__optional_TextTrack_(void* _Nonnull swiftClosureWrapper);
inline Func_void_std__optional_TextTrack__Wrapper wrap_Func_void_std__optional_TextTrack_(Func_void_std__optional_TextTrack_ value) {
Func_void_std__optional_TextTrack_ create_Func_void_std__optional_TextTrack_(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_std__optional_TextTrack__Wrapper wrap_Func_void_std__optional_TextTrack_(Func_void_std__optional_TextTrack_ value) noexcept {
return Func_void_std__optional_TextTrack__Wrapper(std::move(value));
}
@@ -564,14 +591,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_onVolumeChangeData_Wrapper final {
public:
explicit Func_void_onVolumeChangeData_Wrapper(std::function<void(const onVolumeChangeData& /* data */)>&& func): _function(std::make_unique<std::function<void(const onVolumeChangeData& /* data */)>>(std::move(func))) {}
inline void call(onVolumeChangeData data) const {
inline void call(onVolumeChangeData data) const noexcept {
_function->operator()(data);
}
private:
std::unique_ptr<std::function<void(const onVolumeChangeData& /* data */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_onVolumeChangeData create_Func_void_onVolumeChangeData(void* _Nonnull swiftClosureWrapper);
inline Func_void_onVolumeChangeData_Wrapper wrap_Func_void_onVolumeChangeData(Func_void_onVolumeChangeData value) {
Func_void_onVolumeChangeData create_Func_void_onVolumeChangeData(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_onVolumeChangeData_Wrapper wrap_Func_void_onVolumeChangeData(Func_void_onVolumeChangeData value) noexcept {
return Func_void_onVolumeChangeData_Wrapper(std::move(value));
}
@@ -586,14 +613,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_VideoPlayerStatus_Wrapper final {
public:
explicit Func_void_VideoPlayerStatus_Wrapper(std::function<void(VideoPlayerStatus /* status */)>&& func): _function(std::make_unique<std::function<void(VideoPlayerStatus /* status */)>>(std::move(func))) {}
inline void call(int status) const {
inline void call(int status) const noexcept {
_function->operator()(static_cast<VideoPlayerStatus>(status));
}
private:
std::unique_ptr<std::function<void(VideoPlayerStatus /* status */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_VideoPlayerStatus create_Func_void_VideoPlayerStatus(void* _Nonnull swiftClosureWrapper);
inline Func_void_VideoPlayerStatus_Wrapper wrap_Func_void_VideoPlayerStatus(Func_void_VideoPlayerStatus value) {
Func_void_VideoPlayerStatus create_Func_void_VideoPlayerStatus(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_VideoPlayerStatus_Wrapper wrap_Func_void_VideoPlayerStatus(Func_void_VideoPlayerStatus value) noexcept {
return Func_void_VideoPlayerStatus_Wrapper(std::move(value));
}
@@ -602,10 +629,11 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::vector<NativeExternalSubtitle>`.
*/
using std__vector_NativeExternalSubtitle_ = std::vector<NativeExternalSubtitle>;
inline std::vector<NativeExternalSubtitle> create_std__vector_NativeExternalSubtitle_(size_t size) {
std::vector<NativeExternalSubtitle> vector;
vector.reserve(size);
return vector;
inline std::vector<NativeExternalSubtitle> copy_std__vector_NativeExternalSubtitle_(const NativeExternalSubtitle* CONTIGUOUS_MEMORY NON_NULL data, size_t size) noexcept {
return margelo::nitro::FastVectorCopy<NativeExternalSubtitle>(data, size);
}
inline const NativeExternalSubtitle* CONTIGUOUS_MEMORY NON_NULL get_data_std__vector_NativeExternalSubtitle_(const std::vector<NativeExternalSubtitle>& vector) noexcept {
return vector.data();
}
// pragma MARK: std::optional<std::vector<NativeExternalSubtitle>>
@@ -613,21 +641,27 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<std::vector<NativeExternalSubtitle>>`.
*/
using std__optional_std__vector_NativeExternalSubtitle__ = std::optional<std::vector<NativeExternalSubtitle>>;
inline std::optional<std::vector<NativeExternalSubtitle>> create_std__optional_std__vector_NativeExternalSubtitle__(const std::vector<NativeExternalSubtitle>& value) {
inline std::optional<std::vector<NativeExternalSubtitle>> create_std__optional_std__vector_NativeExternalSubtitle__(const std::vector<NativeExternalSubtitle>& value) noexcept {
return std::optional<std::vector<NativeExternalSubtitle>>(value);
}
inline bool has_value_std__optional_std__vector_NativeExternalSubtitle__(const std::optional<std::vector<NativeExternalSubtitle>>& optional) noexcept {
return optional.has_value();
}
inline std::vector<NativeExternalSubtitle> get_std__optional_std__vector_NativeExternalSubtitle__(const std::optional<std::vector<NativeExternalSubtitle>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::unordered_map<std::string, std::string>
/**
* Specialized version of `std::unordered_map<std::string, std::string>`.
*/
using std__unordered_map_std__string__std__string_ = std::unordered_map<std::string, std::string>;
inline std::unordered_map<std::string, std::string> create_std__unordered_map_std__string__std__string_(size_t size) {
inline std::unordered_map<std::string, std::string> create_std__unordered_map_std__string__std__string_(size_t size) noexcept {
std::unordered_map<std::string, std::string> map;
map.reserve(size);
return map;
}
inline std::vector<std::string> get_std__unordered_map_std__string__std__string__keys(const std__unordered_map_std__string__std__string_& map) {
inline std::vector<std::string> get_std__unordered_map_std__string__std__string__keys(const std__unordered_map_std__string__std__string_& map) noexcept {
std::vector<std::string> keys;
keys.reserve(map.size());
for (const auto& entry : map) {
@@ -635,10 +669,10 @@ namespace margelo::nitro::video::bridge::swift {
}
return keys;
}
inline std::string get_std__unordered_map_std__string__std__string__value(const std__unordered_map_std__string__std__string_& map, const std::string& key) {
return map.at(key);
inline std::string get_std__unordered_map_std__string__std__string__value(const std__unordered_map_std__string__std__string_& map, const std::string& key) noexcept {
return map.find(key)->second;
}
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) {
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) noexcept {
map.emplace(key, value);
}
@@ -647,28 +681,40 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<std::unordered_map<std::string, std::string>>`.
*/
using std__optional_std__unordered_map_std__string__std__string__ = std::optional<std::unordered_map<std::string, std::string>>;
inline std::optional<std::unordered_map<std::string, std::string>> create_std__optional_std__unordered_map_std__string__std__string__(const std::unordered_map<std::string, std::string>& value) {
inline std::optional<std::unordered_map<std::string, std::string>> create_std__optional_std__unordered_map_std__string__std__string__(const std::unordered_map<std::string, std::string>& value) noexcept {
return std::optional<std::unordered_map<std::string, std::string>>(value);
}
inline bool has_value_std__optional_std__unordered_map_std__string__std__string__(const std::optional<std::unordered_map<std::string, std::string>>& optional) noexcept {
return optional.has_value();
}
inline std::unordered_map<std::string, std::string> get_std__optional_std__unordered_map_std__string__std__string__(const std::optional<std::unordered_map<std::string, std::string>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<bool>
/**
* Specialized version of `std::optional<bool>`.
*/
using std__optional_bool_ = std::optional<bool>;
inline std::optional<bool> create_std__optional_bool_(const bool& value) {
inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
return std::optional<bool>(value);
}
inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
return optional.has_value();
}
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
return *optional;
}
// pragma MARK: std::shared_ptr<Promise<std::string>>
/**
* Specialized version of `std::shared_ptr<Promise<std::string>>`.
*/
using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() {
inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
return Promise<std::string>::create();
}
inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) {
inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
return PromiseHolder<std::string>(std::move(promise));
}
@@ -683,14 +729,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_std__string_Wrapper final {
public:
explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* result */)>>(std::move(func))) {}
inline void call(std::string result) const {
inline void call(std::string result) const noexcept {
_function->operator()(result);
}
private:
std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_std__string create_Func_void_std__string(void* _Nonnull swiftClosureWrapper);
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) {
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
return Func_void_std__string_Wrapper(std::move(value));
}
@@ -705,15 +751,15 @@ namespace margelo::nitro::video::bridge::swift {
class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload_Wrapper final {
public:
explicit Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload_Wrapper(std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>&& func): _function(std::make_unique<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>>(std::move(func))) {}
inline std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> call(OnGetLicensePayload payload) const {
inline std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> call(OnGetLicensePayload payload) const noexcept {
auto __result = _function->operator()(payload);
return __result;
}
private:
std::unique_ptr<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>> _function;
} SWIFT_NONCOPYABLE;
Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(void* _Nonnull swiftClosureWrapper);
inline Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload_Wrapper wrap_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload value) {
Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload create_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload_Wrapper wrap_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload value) noexcept {
return Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload_Wrapper(std::move(value));
}
@@ -722,10 +768,10 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>`.
*/
using std__shared_ptr_Promise_std__shared_ptr_Promise_std__string____ = std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>;
inline std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> create_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string____() {
inline std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> create_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string____() noexcept {
return Promise<std::shared_ptr<Promise<std::string>>>::create();
}
inline PromiseHolder<std::shared_ptr<Promise<std::string>>> wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string____(std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> promise) {
inline PromiseHolder<std::shared_ptr<Promise<std::string>>> wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string____(std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>> promise) noexcept {
return PromiseHolder<std::shared_ptr<Promise<std::string>>>(std::move(promise));
}
@@ -740,14 +786,14 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_std__shared_ptr_Promise_std__string___Wrapper final {
public:
explicit Func_void_std__shared_ptr_Promise_std__string___Wrapper(std::function<void(const std::shared_ptr<Promise<std::string>>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::shared_ptr<Promise<std::string>>& /* result */)>>(std::move(func))) {}
inline void call(std::shared_ptr<Promise<std::string>> result) const {
inline void call(std::shared_ptr<Promise<std::string>> result) const noexcept {
_function->operator()(result);
}
private:
std::unique_ptr<std::function<void(const std::shared_ptr<Promise<std::string>>& /* result */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_std__shared_ptr_Promise_std__string__ create_Func_void_std__shared_ptr_Promise_std__string__(void* _Nonnull swiftClosureWrapper);
inline Func_void_std__shared_ptr_Promise_std__string___Wrapper wrap_Func_void_std__shared_ptr_Promise_std__string__(Func_void_std__shared_ptr_Promise_std__string__ value) {
Func_void_std__shared_ptr_Promise_std__string__ create_Func_void_std__shared_ptr_Promise_std__string__(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_std__shared_ptr_Promise_std__string___Wrapper wrap_Func_void_std__shared_ptr_Promise_std__string__(Func_void_std__shared_ptr_Promise_std__string__ value) noexcept {
return Func_void_std__shared_ptr_Promise_std__string___Wrapper(std::move(value));
}
@@ -756,55 +802,85 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& / * payload * /)>>`.
*/
using std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______ = std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>>;
inline std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>> create_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>& value) {
inline std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>> create_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>& value) noexcept {
return std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>>(value);
}
inline bool has_value_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______(const std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>>& optional) noexcept {
return optional.has_value();
}
inline std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)> get_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______(const std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::string>>>>(const OnGetLicensePayload& /* payload */)>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<NativeDrmParams>
/**
* Specialized version of `std::optional<NativeDrmParams>`.
*/
using std__optional_NativeDrmParams_ = std::optional<NativeDrmParams>;
inline std::optional<NativeDrmParams> create_std__optional_NativeDrmParams_(const NativeDrmParams& value) {
inline std::optional<NativeDrmParams> create_std__optional_NativeDrmParams_(const NativeDrmParams& value) noexcept {
return std::optional<NativeDrmParams>(value);
}
inline bool has_value_std__optional_NativeDrmParams_(const std::optional<NativeDrmParams>& optional) noexcept {
return optional.has_value();
}
inline NativeDrmParams get_std__optional_NativeDrmParams_(const std::optional<NativeDrmParams>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<LivePlaybackParams>
/**
* Specialized version of `std::optional<LivePlaybackParams>`.
*/
using std__optional_LivePlaybackParams_ = std::optional<LivePlaybackParams>;
inline std::optional<LivePlaybackParams> create_std__optional_LivePlaybackParams_(const LivePlaybackParams& value) {
inline std::optional<LivePlaybackParams> create_std__optional_LivePlaybackParams_(const LivePlaybackParams& value) noexcept {
return std::optional<LivePlaybackParams>(value);
}
inline bool has_value_std__optional_LivePlaybackParams_(const std::optional<LivePlaybackParams>& optional) noexcept {
return optional.has_value();
}
inline LivePlaybackParams get_std__optional_LivePlaybackParams_(const std::optional<LivePlaybackParams>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<Resolution>
/**
* Specialized version of `std::optional<Resolution>`.
*/
using std__optional_Resolution_ = std::optional<Resolution>;
inline std::optional<Resolution> create_std__optional_Resolution_(const Resolution& value) {
inline std::optional<Resolution> create_std__optional_Resolution_(const Resolution& value) noexcept {
return std::optional<Resolution>(value);
}
inline bool has_value_std__optional_Resolution_(const std::optional<Resolution>& optional) noexcept {
return optional.has_value();
}
inline Resolution get_std__optional_Resolution_(const std::optional<Resolution>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<BufferConfig>
/**
* Specialized version of `std::optional<BufferConfig>`.
*/
using std__optional_BufferConfig_ = std::optional<BufferConfig>;
inline std::optional<BufferConfig> create_std__optional_BufferConfig_(const BufferConfig& value) {
inline std::optional<BufferConfig> create_std__optional_BufferConfig_(const BufferConfig& value) noexcept {
return std::optional<BufferConfig>(value);
}
inline bool has_value_std__optional_BufferConfig_(const std::optional<BufferConfig>& optional) noexcept {
return optional.has_value();
}
inline BufferConfig get_std__optional_BufferConfig_(const std::optional<BufferConfig>& optional) noexcept {
return *optional;
}
// pragma MARK: std::shared_ptr<Promise<VideoInformation>>
/**
* Specialized version of `std::shared_ptr<Promise<VideoInformation>>`.
*/
using std__shared_ptr_Promise_VideoInformation__ = std::shared_ptr<Promise<VideoInformation>>;
inline std::shared_ptr<Promise<VideoInformation>> create_std__shared_ptr_Promise_VideoInformation__() {
inline std::shared_ptr<Promise<VideoInformation>> create_std__shared_ptr_Promise_VideoInformation__() noexcept {
return Promise<VideoInformation>::create();
}
inline PromiseHolder<VideoInformation> wrap_std__shared_ptr_Promise_VideoInformation__(std::shared_ptr<Promise<VideoInformation>> promise) {
inline PromiseHolder<VideoInformation> wrap_std__shared_ptr_Promise_VideoInformation__(std::shared_ptr<Promise<VideoInformation>> promise) noexcept {
return PromiseHolder<VideoInformation>(std::move(promise));
}
@@ -819,23 +895,23 @@ namespace margelo::nitro::video::bridge::swift {
class Func_void_VideoInformation_Wrapper final {
public:
explicit Func_void_VideoInformation_Wrapper(std::function<void(const VideoInformation& /* result */)>&& func): _function(std::make_unique<std::function<void(const VideoInformation& /* result */)>>(std::move(func))) {}
inline void call(VideoInformation result) const {
inline void call(VideoInformation result) const noexcept {
_function->operator()(result);
}
private:
std::unique_ptr<std::function<void(const VideoInformation& /* result */)>> _function;
} SWIFT_NONCOPYABLE;
Func_void_VideoInformation create_Func_void_VideoInformation(void* _Nonnull swiftClosureWrapper);
inline Func_void_VideoInformation_Wrapper wrap_Func_void_VideoInformation(Func_void_VideoInformation value) {
Func_void_VideoInformation create_Func_void_VideoInformation(void* NON_NULL swiftClosureWrapper) noexcept;
inline Func_void_VideoInformation_Wrapper wrap_Func_void_VideoInformation(Func_void_VideoInformation value) noexcept {
return Func_void_VideoInformation_Wrapper(std::move(value));
}
// pragma MARK: Result<std::shared_ptr<Promise<VideoInformation>>>
using Result_std__shared_ptr_Promise_VideoInformation___ = Result<std::shared_ptr<Promise<VideoInformation>>>;
inline Result_std__shared_ptr_Promise_VideoInformation___ create_Result_std__shared_ptr_Promise_VideoInformation___(const std::shared_ptr<Promise<VideoInformation>>& value) {
inline Result_std__shared_ptr_Promise_VideoInformation___ create_Result_std__shared_ptr_Promise_VideoInformation___(const std::shared_ptr<Promise<VideoInformation>>& value) noexcept {
return Result<std::shared_ptr<Promise<VideoInformation>>>::withValue(value);
}
inline Result_std__shared_ptr_Promise_VideoInformation___ create_Result_std__shared_ptr_Promise_VideoInformation___(const std::exception_ptr& error) {
inline Result_std__shared_ptr_Promise_VideoInformation___ create_Result_std__shared_ptr_Promise_VideoInformation___(const std::exception_ptr& error) noexcept {
return Result<std::shared_ptr<Promise<VideoInformation>>>::withError(error);
}
@@ -844,19 +920,19 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::shared_ptr<HybridVideoPlayerSourceFactorySpec>`.
*/
using std__shared_ptr_HybridVideoPlayerSourceFactorySpec_ = std::shared_ptr<HybridVideoPlayerSourceFactorySpec>;
std::shared_ptr<HybridVideoPlayerSourceFactorySpec> create_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(std__shared_ptr_HybridVideoPlayerSourceFactorySpec_ cppType);
std::shared_ptr<HybridVideoPlayerSourceFactorySpec> create_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(std__shared_ptr_HybridVideoPlayerSourceFactorySpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoPlayerSourceFactorySpec>
using std__weak_ptr_HybridVideoPlayerSourceFactorySpec_ = std::weak_ptr<HybridVideoPlayerSourceFactorySpec>;
inline std__weak_ptr_HybridVideoPlayerSourceFactorySpec_ weakify_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(const std::shared_ptr<HybridVideoPlayerSourceFactorySpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoPlayerSourceFactorySpec_ weakify_std__shared_ptr_HybridVideoPlayerSourceFactorySpec_(const std::shared_ptr<HybridVideoPlayerSourceFactorySpec>& strong) noexcept { return strong; }
// pragma MARK: Result<std::shared_ptr<HybridVideoPlayerSourceSpec>>
using Result_std__shared_ptr_HybridVideoPlayerSourceSpec__ = Result<std::shared_ptr<HybridVideoPlayerSourceSpec>>;
inline Result_std__shared_ptr_HybridVideoPlayerSourceSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::shared_ptr<HybridVideoPlayerSourceSpec>& value) {
inline Result_std__shared_ptr_HybridVideoPlayerSourceSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::shared_ptr<HybridVideoPlayerSourceSpec>& value) noexcept {
return Result<std::shared_ptr<HybridVideoPlayerSourceSpec>>::withValue(value);
}
inline Result_std__shared_ptr_HybridVideoPlayerSourceSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::exception_ptr& error) {
inline Result_std__shared_ptr_HybridVideoPlayerSourceSpec__ create_Result_std__shared_ptr_HybridVideoPlayerSourceSpec__(const std::exception_ptr& error) noexcept {
return Result<std::shared_ptr<HybridVideoPlayerSourceSpec>>::withError(error);
}
@@ -865,55 +941,79 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::optional<std::shared_ptr<HybridVideoPlayerSpec>>`.
*/
using std__optional_std__shared_ptr_HybridVideoPlayerSpec__ = std::optional<std::shared_ptr<HybridVideoPlayerSpec>>;
inline std::optional<std::shared_ptr<HybridVideoPlayerSpec>> create_std__optional_std__shared_ptr_HybridVideoPlayerSpec__(const std::shared_ptr<HybridVideoPlayerSpec>& value) {
inline std::optional<std::shared_ptr<HybridVideoPlayerSpec>> create_std__optional_std__shared_ptr_HybridVideoPlayerSpec__(const std::shared_ptr<HybridVideoPlayerSpec>& value) noexcept {
return std::optional<std::shared_ptr<HybridVideoPlayerSpec>>(value);
}
inline bool has_value_std__optional_std__shared_ptr_HybridVideoPlayerSpec__(const std::optional<std::shared_ptr<HybridVideoPlayerSpec>>& optional) noexcept {
return optional.has_value();
}
inline std::shared_ptr<HybridVideoPlayerSpec> get_std__optional_std__shared_ptr_HybridVideoPlayerSpec__(const std::optional<std::shared_ptr<HybridVideoPlayerSpec>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<std::function<void(bool /* isInPictureInPicture */)>>
/**
* Specialized version of `std::optional<std::function<void(bool / * isInPictureInPicture * /)>>`.
*/
using std__optional_std__function_void_bool____isInPictureInPicture______ = std::optional<std::function<void(bool /* isInPictureInPicture */)>>;
inline std::optional<std::function<void(bool /* isInPictureInPicture */)>> create_std__optional_std__function_void_bool____isInPictureInPicture______(const std::function<void(bool /* isInPictureInPicture */)>& value) {
inline std::optional<std::function<void(bool /* isInPictureInPicture */)>> create_std__optional_std__function_void_bool____isInPictureInPicture______(const std::function<void(bool /* isInPictureInPicture */)>& value) noexcept {
return std::optional<std::function<void(bool /* isInPictureInPicture */)>>(value);
}
inline bool has_value_std__optional_std__function_void_bool____isInPictureInPicture______(const std::optional<std::function<void(bool /* isInPictureInPicture */)>>& optional) noexcept {
return optional.has_value();
}
inline std::function<void(bool /* isInPictureInPicture */)> get_std__optional_std__function_void_bool____isInPictureInPicture______(const std::optional<std::function<void(bool /* isInPictureInPicture */)>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<std::function<void(bool /* fullscreen */)>>
/**
* Specialized version of `std::optional<std::function<void(bool / * fullscreen * /)>>`.
*/
using std__optional_std__function_void_bool____fullscreen______ = std::optional<std::function<void(bool /* fullscreen */)>>;
inline std::optional<std::function<void(bool /* fullscreen */)>> create_std__optional_std__function_void_bool____fullscreen______(const std::function<void(bool /* fullscreen */)>& value) {
inline std::optional<std::function<void(bool /* fullscreen */)>> create_std__optional_std__function_void_bool____fullscreen______(const std::function<void(bool /* fullscreen */)>& value) noexcept {
return std::optional<std::function<void(bool /* fullscreen */)>>(value);
}
inline bool has_value_std__optional_std__function_void_bool____fullscreen______(const std::optional<std::function<void(bool /* fullscreen */)>>& optional) noexcept {
return optional.has_value();
}
inline std::function<void(bool /* fullscreen */)> get_std__optional_std__function_void_bool____fullscreen______(const std::optional<std::function<void(bool /* fullscreen */)>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::optional<std::function<void()>>
/**
* Specialized version of `std::optional<std::function<void()>>`.
*/
using std__optional_std__function_void____ = std::optional<std::function<void()>>;
inline std::optional<std::function<void()>> create_std__optional_std__function_void____(const std::function<void()>& value) {
inline std::optional<std::function<void()>> create_std__optional_std__function_void____(const std::function<void()>& value) noexcept {
return std::optional<std::function<void()>>(value);
}
inline bool has_value_std__optional_std__function_void____(const std::optional<std::function<void()>>& optional) noexcept {
return optional.has_value();
}
inline std::function<void()> get_std__optional_std__function_void____(const std::optional<std::function<void()>>& optional) noexcept {
return *optional;
}
// pragma MARK: std::shared_ptr<HybridVideoViewViewManagerSpec>
/**
* Specialized version of `std::shared_ptr<HybridVideoViewViewManagerSpec>`.
*/
using std__shared_ptr_HybridVideoViewViewManagerSpec_ = std::shared_ptr<HybridVideoViewViewManagerSpec>;
std::shared_ptr<HybridVideoViewViewManagerSpec> create_std__shared_ptr_HybridVideoViewViewManagerSpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoViewViewManagerSpec_(std__shared_ptr_HybridVideoViewViewManagerSpec_ cppType);
std::shared_ptr<HybridVideoViewViewManagerSpec> create_std__shared_ptr_HybridVideoViewViewManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoViewViewManagerSpec_(std__shared_ptr_HybridVideoViewViewManagerSpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoViewViewManagerSpec>
using std__weak_ptr_HybridVideoViewViewManagerSpec_ = std::weak_ptr<HybridVideoViewViewManagerSpec>;
inline std__weak_ptr_HybridVideoViewViewManagerSpec_ weakify_std__shared_ptr_HybridVideoViewViewManagerSpec_(const std::shared_ptr<HybridVideoViewViewManagerSpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoViewViewManagerSpec_ weakify_std__shared_ptr_HybridVideoViewViewManagerSpec_(const std::shared_ptr<HybridVideoViewViewManagerSpec>& strong) noexcept { return strong; }
// pragma MARK: Result<bool>
using Result_bool_ = Result<bool>;
inline Result_bool_ create_Result_bool_(bool value) {
inline Result_bool_ create_Result_bool_(bool value) noexcept {
return Result<bool>::withValue(std::move(value));
}
inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) {
inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) noexcept {
return Result<bool>::withError(error);
}
@@ -922,19 +1022,19 @@ namespace margelo::nitro::video::bridge::swift {
* Specialized version of `std::shared_ptr<HybridVideoViewViewManagerFactorySpec>`.
*/
using std__shared_ptr_HybridVideoViewViewManagerFactorySpec_ = std::shared_ptr<HybridVideoViewViewManagerFactorySpec>;
std::shared_ptr<HybridVideoViewViewManagerFactorySpec> create_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(void* _Nonnull swiftUnsafePointer);
void* _Nonnull get_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(std__shared_ptr_HybridVideoViewViewManagerFactorySpec_ cppType);
std::shared_ptr<HybridVideoViewViewManagerFactorySpec> create_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept;
void* NON_NULL get_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(std__shared_ptr_HybridVideoViewViewManagerFactorySpec_ cppType) noexcept;
// pragma MARK: std::weak_ptr<HybridVideoViewViewManagerFactorySpec>
using std__weak_ptr_HybridVideoViewViewManagerFactorySpec_ = std::weak_ptr<HybridVideoViewViewManagerFactorySpec>;
inline std__weak_ptr_HybridVideoViewViewManagerFactorySpec_ weakify_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(const std::shared_ptr<HybridVideoViewViewManagerFactorySpec>& strong) { return strong; }
inline std__weak_ptr_HybridVideoViewViewManagerFactorySpec_ weakify_std__shared_ptr_HybridVideoViewViewManagerFactorySpec_(const std::shared_ptr<HybridVideoViewViewManagerFactorySpec>& strong) noexcept { return strong; }
// pragma MARK: Result<std::shared_ptr<HybridVideoViewViewManagerSpec>>
using Result_std__shared_ptr_HybridVideoViewViewManagerSpec__ = Result<std::shared_ptr<HybridVideoViewViewManagerSpec>>;
inline Result_std__shared_ptr_HybridVideoViewViewManagerSpec__ create_Result_std__shared_ptr_HybridVideoViewViewManagerSpec__(const std::shared_ptr<HybridVideoViewViewManagerSpec>& value) {
inline Result_std__shared_ptr_HybridVideoViewViewManagerSpec__ create_Result_std__shared_ptr_HybridVideoViewViewManagerSpec__(const std::shared_ptr<HybridVideoViewViewManagerSpec>& value) noexcept {
return Result<std::shared_ptr<HybridVideoViewViewManagerSpec>>::withValue(value);
}
inline Result_std__shared_ptr_HybridVideoViewViewManagerSpec__ create_Result_std__shared_ptr_HybridVideoViewViewManagerSpec__(const std::exception_ptr& error) {
inline Result_std__shared_ptr_HybridVideoViewViewManagerSpec__ create_Result_std__shared_ptr_HybridVideoViewViewManagerSpec__(const std::exception_ptr& error) noexcept {
return Result<std::shared_ptr<HybridVideoViewViewManagerSpec>>::withError(error);
}

View File

@@ -48,6 +48,8 @@ namespace margelo::nitro::video { struct Resolution; }
namespace margelo::nitro::video { enum class SourceType; }
// Forward declaration of `SubtitleType` to properly resolve imports.
namespace margelo::nitro::video { enum class SubtitleType; }
// Forward declaration of `SurfaceType` to properly resolve imports.
namespace margelo::nitro::video { enum class SurfaceType; }
// Forward declaration of `TextTrack` to properly resolve imports.
namespace margelo::nitro::video { struct TextTrack; }
// Forward declaration of `TimedMetadataObject` to properly resolve imports.
@@ -92,6 +94,7 @@ namespace margelo::nitro::video { struct onVolumeChangeData; }
#include "Resolution.hpp"
#include "SourceType.hpp"
#include "SubtitleType.hpp"
#include "SurfaceType.hpp"
#include "TextTrack.hpp"
#include "TimedMetadata.hpp"
#include "TimedMetadataObject.hpp"

View File

@@ -98,7 +98,7 @@ namespace margelo::nitro::video {
return __value;
}
inline std::shared_ptr<HybridVideoPlayerSourceSpec> fromVideoConfig(const NativeVideoConfig& config) override {
auto __result = _swiftPart.fromVideoConfig(config);
auto __result = _swiftPart.fromVideoConfig(std::forward<decltype(config)>(config));
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}

View File

@@ -92,8 +92,7 @@ namespace margelo::nitro::video {
return __result;
}
inline NativeVideoConfig getConfig() noexcept override {
auto __result = _swiftPart.getConfig();
return __result;
return _swiftPart.getConfig();
}
public:

View File

@@ -16,11 +16,14 @@ namespace ReactNativeVideo { class HybridVideoViewViewManagerSpec_cxx; }
namespace margelo::nitro::video { class HybridVideoPlayerSpec; }
// Forward declaration of `ResizeMode` to properly resolve imports.
namespace margelo::nitro::video { enum class ResizeMode; }
// Forward declaration of `SurfaceType` to properly resolve imports.
namespace margelo::nitro::video { enum class SurfaceType; }
#include <memory>
#include "HybridVideoPlayerSpec.hpp"
#include <optional>
#include "ResizeMode.hpp"
#include "SurfaceType.hpp"
#include <functional>
#include "ReactNativeVideo-Swift-Cxx-Umbrella.hpp"
@@ -98,6 +101,13 @@ namespace margelo::nitro::video {
inline void setKeepScreenAwake(bool keepScreenAwake) noexcept override {
_swiftPart.setKeepScreenAwake(std::forward<decltype(keepScreenAwake)>(keepScreenAwake));
}
inline SurfaceType getSurfaceType() noexcept override {
auto __result = _swiftPart.getSurfaceType();
return static_cast<SurfaceType>(__result);
}
inline void setSurfaceType(SurfaceType surfaceType) noexcept override {
_swiftPart.setSurfaceType(static_cast<int>(surfaceType));
}
inline std::optional<std::function<void(bool /* isInPictureInPicture */)>> getOnPictureInPictureChange() noexcept override {
auto __result = _swiftPart.getOnPictureInPictureChange();
return __result;

View File

@@ -91,13 +91,7 @@ public extension BufferConfig {
var livePlayback: LivePlaybackParams? {
@inline(__always)
get {
return { () -> LivePlaybackParams? in
if let __unwrapped = self.__livePlayback.value {
return __unwrapped
} else {
return nil
}
}()
return self.__livePlayback.value
}
@inline(__always)
set {
@@ -233,13 +227,7 @@ public extension BufferConfig {
var preferredMaximumResolution: Resolution? {
@inline(__always)
get {
return { () -> Resolution? in
if let __unwrapped = self.__preferredMaximumResolution.value {
return __unwrapped
} else {
return nil
}
}()
return self.__preferredMaximumResolution.value
}
@inline(__always)
set {
@@ -273,13 +261,7 @@ public extension BufferConfig {
var preferredMaximumResolutionForExpensiveNetworks: Resolution? {
@inline(__always)
get {
return { () -> Resolution? in
if let __unwrapped = self.__preferredMaximumResolutionForExpensiveNetworks.value {
return __unwrapped
} else {
return nil
}
}()
return self.__preferredMaximumResolutionForExpensiveNetworks.value
}
@inline(__always)
set {

View File

@@ -23,13 +23,7 @@ public final class Func_void_std__optional_TextTrack_ {
@inline(__always)
public func call(track: bridge.std__optional_TextTrack_) -> Void {
self.closure({ () -> TextTrack? in
if let __unwrapped = track.value {
return __unwrapped
} else {
return nil
}
}())
self.closure(track.value)
}
/**

View File

@@ -264,7 +264,8 @@ open class HybridVideoPlayerSpec_cxx {
public final func replaceSourceAsync(source: bridge.std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__) -> bridge.Result_std__shared_ptr_Promise_void___ {
do {
let __result = try self.__implementation.replaceSourceAsync(source: { () -> (any HybridVideoPlayerSourceSpec)? in
if let __unwrapped = source.value {
if bridge.has_value_std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__(source) {
let __unwrapped = bridge.get_std__optional_std__shared_ptr_HybridVideoPlayerSourceSpec__(source)
return { () -> HybridVideoPlayerSourceSpec in
let __unsafePointer = bridge.get_std__shared_ptr_HybridVideoPlayerSourceSpec_(__unwrapped)
let __instance = HybridVideoPlayerSourceSpec_cxx.fromUnsafe(__unsafePointer)
@@ -293,13 +294,9 @@ open class HybridVideoPlayerSpec_cxx {
public final func getAvailableTextTracks() -> bridge.Result_std__vector_TextTrack__ {
do {
let __result = try self.__implementation.getAvailableTextTracks()
let __resultCpp = { () -> bridge.std__vector_TextTrack_ in
var __vector = bridge.create_std__vector_TextTrack_(__result.count)
for __item in __result {
__vector.push_back(__item)
}
return __vector
}()
let __resultCpp = __result.withUnsafeBufferPointer { __pointer -> bridge.std__vector_TextTrack_ in
return bridge.copy_std__vector_TextTrack_(__pointer.baseAddress!, __result.count)
}
return bridge.create_Result_std__vector_TextTrack__(__resultCpp)
} catch (let __error) {
let __exceptionPtr = __error.toCpp()
@@ -310,13 +307,7 @@ open class HybridVideoPlayerSpec_cxx {
@inline(__always)
public final func selectTextTrack(textTrack: bridge.std__optional_TextTrack_) -> bridge.Result_void_ {
do {
try self.__implementation.selectTextTrack(textTrack: { () -> TextTrack? in
if let __unwrapped = textTrack.value {
return __unwrapped
} else {
return nil
}
}())
try self.__implementation.selectTextTrack(textTrack: textTrack.value)
return bridge.create_Result_void_()
} catch (let __error) {
let __exceptionPtr = __error.toCpp()

View File

@@ -17,6 +17,7 @@ public protocol HybridVideoViewViewManagerSpec_protocol: HybridObject {
var autoEnterPictureInPicture: Bool { get set }
var resizeMode: ResizeMode { get set }
var keepScreenAwake: Bool { get set }
var surfaceType: SurfaceType { get set }
var onPictureInPictureChange: ((_ isInPictureInPicture: Bool) -> Void)? { get set }
var onFullscreenChange: ((_ fullscreen: Bool) -> Void)? { get set }
var willEnterFullscreen: (() -> Void)? { get set }

View File

@@ -123,7 +123,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.player = { () -> (any HybridVideoPlayerSpec)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__shared_ptr_HybridVideoPlayerSpec__(newValue) {
let __unwrapped = bridge.get_std__optional_std__shared_ptr_HybridVideoPlayerSpec__(newValue)
return { () -> HybridVideoPlayerSpec in
let __unsafePointer = bridge.get_std__shared_ptr_HybridVideoPlayerSpec_(__unwrapped)
let __instance = HybridVideoPlayerSpec_cxx.fromUnsafe(__unsafePointer)
@@ -191,6 +192,17 @@ open class HybridVideoViewViewManagerSpec_cxx {
}
}
public final var surfaceType: Int32 {
@inline(__always)
get {
return self.__implementation.surfaceType.rawValue
}
@inline(__always)
set {
self.__implementation.surfaceType = margelo.nitro.video.SurfaceType(rawValue: newValue)!
}
}
public final var onPictureInPictureChange: bridge.std__optional_std__function_void_bool____isInPictureInPicture______ {
@inline(__always)
get {
@@ -208,7 +220,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.onPictureInPictureChange = { () -> ((_ isInPictureInPicture: Bool) -> Void)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__function_void_bool____isInPictureInPicture______(newValue) {
let __unwrapped = bridge.get_std__optional_std__function_void_bool____isInPictureInPicture______(newValue)
return { () -> (Bool) -> Void in
let __wrappedFunction = bridge.wrap_Func_void_bool(__unwrapped)
return { (__isInPictureInPicture: Bool) -> Void in
@@ -239,7 +252,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.onFullscreenChange = { () -> ((_ fullscreen: Bool) -> Void)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__function_void_bool____fullscreen______(newValue) {
let __unwrapped = bridge.get_std__optional_std__function_void_bool____fullscreen______(newValue)
return { () -> (Bool) -> Void in
let __wrappedFunction = bridge.wrap_Func_void_bool(__unwrapped)
return { (__fullscreen: Bool) -> Void in
@@ -270,7 +284,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.willEnterFullscreen = { () -> (() -> Void)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__function_void____(newValue) {
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
return { () -> () -> Void in
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
return { () -> Void in
@@ -301,7 +316,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.willExitFullscreen = { () -> (() -> Void)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__function_void____(newValue) {
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
return { () -> () -> Void in
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
return { () -> Void in
@@ -332,7 +348,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.willEnterPictureInPicture = { () -> (() -> Void)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__function_void____(newValue) {
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
return { () -> () -> Void in
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
return { () -> Void in
@@ -363,7 +380,8 @@ open class HybridVideoViewViewManagerSpec_cxx {
@inline(__always)
set {
self.__implementation.willExitPictureInPicture = { () -> (() -> Void)? in
if let __unwrapped = newValue.value {
if bridge.has_value_std__optional_std__function_void____(newValue) {
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
return { () -> () -> Void in
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
return { () -> Void in

View File

@@ -77,7 +77,8 @@ public extension NativeDrmParams {
@inline(__always)
get {
return { () -> String? in
if let __unwrapped = self.__type.value {
if bridge.has_value_std__optional_std__string_(self.__type) {
let __unwrapped = bridge.get_std__optional_std__string_(self.__type)
return String(__unwrapped)
} else {
return nil
@@ -100,7 +101,8 @@ public extension NativeDrmParams {
@inline(__always)
get {
return { () -> String? in
if let __unwrapped = self.__licenseUrl.value {
if bridge.has_value_std__optional_std__string_(self.__licenseUrl) {
let __unwrapped = bridge.get_std__optional_std__string_(self.__licenseUrl)
return String(__unwrapped)
} else {
return nil
@@ -123,7 +125,8 @@ public extension NativeDrmParams {
@inline(__always)
get {
return { () -> String? in
if let __unwrapped = self.__certificateUrl.value {
if bridge.has_value_std__optional_std__string_(self.__certificateUrl) {
let __unwrapped = bridge.get_std__optional_std__string_(self.__certificateUrl)
return String(__unwrapped)
} else {
return nil
@@ -146,7 +149,8 @@ public extension NativeDrmParams {
@inline(__always)
get {
return { () -> String? in
if let __unwrapped = self.__contentId.value {
if bridge.has_value_std__optional_std__string_(self.__contentId) {
let __unwrapped = bridge.get_std__optional_std__string_(self.__contentId)
return String(__unwrapped)
} else {
return nil
@@ -169,7 +173,8 @@ public extension NativeDrmParams {
@inline(__always)
get {
return { () -> Dictionary<String, String>? in
if let __unwrapped = self.__licenseHeaders.value {
if bridge.has_value_std__optional_std__unordered_map_std__string__std__string__(self.__licenseHeaders) {
let __unwrapped = bridge.get_std__optional_std__unordered_map_std__string__std__string__(self.__licenseHeaders)
return { () -> Dictionary<String, String> in
var __dictionary = Dictionary<String, String>(minimumCapacity: __unwrapped.size())
let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(__unwrapped)
@@ -223,7 +228,8 @@ public extension NativeDrmParams {
@inline(__always)
get {
return { () -> ((_ payload: OnGetLicensePayload) -> Promise<Promise<String>>)? in
if let __unwrapped = self.__getLicense.value {
if bridge.has_value_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______(self.__getLicense) {
let __unwrapped = bridge.get_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____const_OnGetLicensePayload_____payload______(self.__getLicense)
return { () -> (OnGetLicensePayload) -> Promise<Promise<String>> in
let __wrappedFunction = bridge.wrap_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__string_____OnGetLicensePayload(__unwrapped)
return { (__payload: OnGetLicensePayload) -> Promise<Promise<String>> in

View File

@@ -21,13 +21,9 @@ public extension NativeVideoConfig {
init(uri: String, externalSubtitles: [NativeExternalSubtitle]?, drm: NativeDrmParams?, headers: Dictionary<String, String>?, bufferConfig: BufferConfig?, initializeOnCreation: Bool?) {
self.init(std.string(uri), { () -> bridge.std__optional_std__vector_NativeExternalSubtitle__ in
if let __unwrappedValue = externalSubtitles {
return bridge.create_std__optional_std__vector_NativeExternalSubtitle__({ () -> bridge.std__vector_NativeExternalSubtitle_ in
var __vector = bridge.create_std__vector_NativeExternalSubtitle_(__unwrappedValue.count)
for __item in __unwrappedValue {
__vector.push_back(__item)
}
return __vector
}())
return bridge.create_std__optional_std__vector_NativeExternalSubtitle__(__unwrappedValue.withUnsafeBufferPointer { __pointer -> bridge.std__vector_NativeExternalSubtitle_ in
return bridge.copy_std__vector_NativeExternalSubtitle_(__pointer.baseAddress!, __unwrappedValue.count)
})
} else {
return .init()
}
@@ -79,8 +75,13 @@ public extension NativeVideoConfig {
@inline(__always)
get {
return { () -> [NativeExternalSubtitle]? in
if let __unwrapped = self.__externalSubtitles.value {
return __unwrapped.map({ __item in __item })
if bridge.has_value_std__optional_std__vector_NativeExternalSubtitle__(self.__externalSubtitles) {
let __unwrapped = bridge.get_std__optional_std__vector_NativeExternalSubtitle__(self.__externalSubtitles)
return { () -> [NativeExternalSubtitle] in
let __data = bridge.get_data_std__vector_NativeExternalSubtitle_(__unwrapped)
let __size = __unwrapped.size()
return Array(UnsafeBufferPointer(start: __data, count: __size))
}()
} else {
return nil
}
@@ -90,13 +91,9 @@ public extension NativeVideoConfig {
set {
self.__externalSubtitles = { () -> bridge.std__optional_std__vector_NativeExternalSubtitle__ in
if let __unwrappedValue = newValue {
return bridge.create_std__optional_std__vector_NativeExternalSubtitle__({ () -> bridge.std__vector_NativeExternalSubtitle_ in
var __vector = bridge.create_std__vector_NativeExternalSubtitle_(__unwrappedValue.count)
for __item in __unwrappedValue {
__vector.push_back(__item)
}
return __vector
}())
return bridge.create_std__optional_std__vector_NativeExternalSubtitle__(__unwrappedValue.withUnsafeBufferPointer { __pointer -> bridge.std__vector_NativeExternalSubtitle_ in
return bridge.copy_std__vector_NativeExternalSubtitle_(__pointer.baseAddress!, __unwrappedValue.count)
})
} else {
return .init()
}
@@ -107,13 +104,7 @@ public extension NativeVideoConfig {
var drm: NativeDrmParams? {
@inline(__always)
get {
return { () -> NativeDrmParams? in
if let __unwrapped = self.__drm.value {
return __unwrapped
} else {
return nil
}
}()
return self.__drm.value
}
@inline(__always)
set {
@@ -131,7 +122,8 @@ public extension NativeVideoConfig {
@inline(__always)
get {
return { () -> Dictionary<String, String>? in
if let __unwrapped = self.__headers.value {
if bridge.has_value_std__optional_std__unordered_map_std__string__std__string__(self.__headers) {
let __unwrapped = bridge.get_std__optional_std__unordered_map_std__string__std__string__(self.__headers)
return { () -> Dictionary<String, String> in
var __dictionary = Dictionary<String, String>(minimumCapacity: __unwrapped.size())
let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(__unwrapped)
@@ -167,13 +159,7 @@ public extension NativeVideoConfig {
var bufferConfig: BufferConfig? {
@inline(__always)
get {
return { () -> BufferConfig? in
if let __unwrapped = self.__bufferConfig.value {
return __unwrapped
} else {
return nil
}
}()
return self.__bufferConfig.value
}
@inline(__always)
set {

View File

@@ -0,0 +1,40 @@
///
/// SurfaceType.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 `SurfaceType`, backed by a C++ enum.
*/
public typealias SurfaceType = margelo.nitro.video.SurfaceType
public extension SurfaceType {
/**
* Get a SurfaceType for the given String value, or
* return `nil` if the given value was invalid/unknown.
*/
init?(fromString string: String) {
switch string {
case "surface":
self = .surface
case "texture":
self = .texture
default:
return nil
}
}
/**
* Get the String value this SurfaceType represents.
*/
var stringValue: String {
switch self {
case .surface:
return "surface"
case .texture:
return "texture"
}
}
}

View File

@@ -54,7 +54,8 @@ public extension TextTrack {
@inline(__always)
get {
return { () -> String? in
if let __unwrapped = self.__language.value {
if bridge.has_value_std__optional_std__string_(self.__language) {
let __unwrapped = bridge.get_std__optional_std__string_(self.__language)
return String(__unwrapped)
} else {
return nil

View File

@@ -19,29 +19,25 @@ public extension TimedMetadata {
* 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
}())
self.init(metadata.withUnsafeBufferPointer { __pointer -> bridge.std__vector_TimedMetadataObject_ in
return bridge.copy_std__vector_TimedMetadataObject_(__pointer.baseAddress!, metadata.count)
})
}
var metadata: [TimedMetadataObject] {
@inline(__always)
get {
return self.__metadata.map({ __item in __item })
return { () -> [TimedMetadataObject] in
let __data = bridge.get_data_std__vector_TimedMetadataObject_(self.__metadata)
let __size = self.__metadata.size()
return Array(UnsafeBufferPointer(start: __data, count: __size))
}()
}
@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
}()
self.__metadata = newValue.withUnsafeBufferPointer { __pointer -> bridge.std__vector_TimedMetadataObject_ in
return bridge.copy_std__vector_TimedMetadataObject_(__pointer.baseAddress!, newValue.count)
}
}
}
}

View File

@@ -26,6 +26,8 @@ namespace margelo::nitro::video {
prototype.registerHybridSetter("resizeMode", &HybridVideoViewViewManagerSpec::setResizeMode);
prototype.registerHybridGetter("keepScreenAwake", &HybridVideoViewViewManagerSpec::getKeepScreenAwake);
prototype.registerHybridSetter("keepScreenAwake", &HybridVideoViewViewManagerSpec::setKeepScreenAwake);
prototype.registerHybridGetter("surfaceType", &HybridVideoViewViewManagerSpec::getSurfaceType);
prototype.registerHybridSetter("surfaceType", &HybridVideoViewViewManagerSpec::setSurfaceType);
prototype.registerHybridGetter("onPictureInPictureChange", &HybridVideoViewViewManagerSpec::getOnPictureInPictureChange);
prototype.registerHybridSetter("onPictureInPictureChange", &HybridVideoViewViewManagerSpec::setOnPictureInPictureChange);
prototype.registerHybridGetter("onFullscreenChange", &HybridVideoViewViewManagerSpec::getOnFullscreenChange);

View File

@@ -17,11 +17,14 @@
namespace margelo::nitro::video { class HybridVideoPlayerSpec; }
// Forward declaration of `ResizeMode` to properly resolve imports.
namespace margelo::nitro::video { enum class ResizeMode; }
// Forward declaration of `SurfaceType` to properly resolve imports.
namespace margelo::nitro::video { enum class SurfaceType; }
#include <memory>
#include "HybridVideoPlayerSpec.hpp"
#include <optional>
#include "ResizeMode.hpp"
#include "SurfaceType.hpp"
#include <functional>
namespace margelo::nitro::video {
@@ -63,6 +66,8 @@ namespace margelo::nitro::video {
virtual void setResizeMode(ResizeMode resizeMode) = 0;
virtual bool getKeepScreenAwake() = 0;
virtual void setKeepScreenAwake(bool keepScreenAwake) = 0;
virtual SurfaceType getSurfaceType() = 0;
virtual void setSurfaceType(SurfaceType surfaceType) = 0;
virtual std::optional<std::function<void(bool /* isInPictureInPicture */)>> getOnPictureInPictureChange() = 0;
virtual void setOnPictureInPictureChange(const std::optional<std::function<void(bool /* isInPictureInPicture */)>>& onPictureInPictureChange) = 0;
virtual std::optional<std::function<void(bool /* fullscreen */)>> getOnFullscreenChange() = 0;

View File

@@ -0,0 +1,76 @@
///
/// SurfaceType.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(<NitroModules/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#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 (SurfaceType).
*/
enum class SurfaceType {
SURFACE SWIFT_NAME(surface) = 0,
TEXTURE SWIFT_NAME(texture) = 1,
} CLOSED_ENUM;
} // namespace margelo::nitro::video
namespace margelo::nitro {
// C++ SurfaceType <> JS SurfaceType (union)
template <>
struct JSIConverter<margelo::nitro::video::SurfaceType> final {
static inline margelo::nitro::video::SurfaceType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
switch (hashString(unionValue.c_str(), unionValue.size())) {
case hashString("surface"): return margelo::nitro::video::SurfaceType::SURFACE;
case hashString("texture"): return margelo::nitro::video::SurfaceType::TEXTURE;
default: [[unlikely]]
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SurfaceType - invalid value!");
}
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::video::SurfaceType arg) {
switch (arg) {
case margelo::nitro::video::SurfaceType::SURFACE: return JSIConverter<std::string>::toJSI(runtime, "surface");
case margelo::nitro::video::SurfaceType::TEXTURE: return JSIConverter<std::string>::toJSI(runtime, "texture");
default: [[unlikely]]
throw std::invalid_argument("Cannot convert SurfaceType to JS - invalid value: "
+ std::to_string(static_cast<int>(arg)) + "!");
}
}
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
if (!value.isString()) {
return false;
}
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
switch (hashString(unionValue.c_str(), unionValue.size())) {
case hashString("surface"):
case hashString("texture"):
return true;
default:
return false;
}
}
};
} // namespace margelo::nitro

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-video",
"version": "7.0.0-alpha.4",
"version": "7.0.0-alpha.5",
"description": "<Video /> Component for React Native",
"source": "./src/index.tsx",
"main": "./lib/commonjs/index.js",
@@ -52,7 +52,7 @@
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bun run build",
"build": "bob build",
"specs": "nitro-codegen",
"specs": "nitrogen",
"release": "release-it --preRelease alpha --npm.tag=next"
},
"keywords": [
@@ -75,18 +75,19 @@
},
"devDependencies": {
"@expo/config-plugins": "^10.0.2",
"@react-native/eslint-config": "^0.77.0",
"@types/react": "^18.2.44",
"del-cli": "^5.1.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"nitro-codegen": "^0.28.0",
"nitrogen": "^0.29.0",
"prettier": "^3.0.3",
"react": "18.3.1",
"react-native": "^0.77.0",
"@react-native/eslint-config": "^0.77.0",
"shaka-player": "^4.15.9",
"react-native-builder-bob": "^0.40.0",
"react-native-nitro-modules": "^0.28.0",
"react-native-nitro-modules": "^0.29.0",
"typescript": "^5.2.2"
},
"peerDependencies": {
@@ -149,5 +150,11 @@
"type": "view-legacy",
"languages": "kotlin-swift",
"version": "0.41.2"
},
"optionalDependencies": {
"shaka-player": "^4.15.9"
},
"dependencies": {
"@types/react-native-web": "^0.19.2"
}
}

View File

@@ -20,8 +20,6 @@ import { VideoPlayerEvents } from './VideoPlayerEvents';
class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
protected player: VideoPlayerImpl;
public onError?: (error: VideoRuntimeError) => void = undefined;
constructor(source: VideoSource | VideoConfig | VideoPlayerSource) {
const hybridSource = createSource(source);
const player = createPlayer(hybridSource);
@@ -57,8 +55,10 @@ class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
private throwError(error: unknown) {
const parsedError = tryParseNativeVideoError(error);
if (parsedError instanceof VideoRuntimeError && this.onError) {
this.onError(parsedError);
if (
parsedError instanceof VideoRuntimeError &&
this.triggerEvent('onError', parsedError)
) {
// We don't throw errors if onError is provided
return;
}

View File

@@ -0,0 +1,263 @@
import shaka from "shaka-player";
import type { VideoPlayerSource } from "../spec/nitro/VideoPlayerSource.nitro";
import type { IgnoreSilentSwitchMode } from "./types/IgnoreSilentSwitchMode";
import type { MixAudioMode } from "./types/MixAudioMode";
import type { TextTrack } from "./types/TextTrack";
import type { NoAutocomplete } from "./types/Utils";
import type { VideoConfig, VideoSource } from "./types/VideoConfig";
import {
tryParseNativeVideoError,
VideoRuntimeError,
} from "./types/VideoError";
import type { VideoPlayerBase } from "./types/VideoPlayerBase";
import type { VideoPlayerStatus } from "./types/VideoPlayerStatus";
import { VideoPlayerEvents } from "./VideoPlayerEvents";
import { WebEventEmiter } from "./WebEventEmiter";
class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
protected player = new shaka.Player();
protected video: HTMLVideoElement;
constructor(source: VideoSource | VideoConfig | VideoPlayerSource) {
const video = document.createElement("video");
super(new WebEventEmiter(video));
this.video = video;
this.player.attach(this.video);
this.replaceSourceAsync(source);
}
/**
* Cleans up player's native resources and releases native state.
* After calling this method, the player is no longer usable.
* @internal
*/
__destroy() {
this.player.destroy();
}
__getNativeRef() {
return this.video;
}
/**
* Handles parsing native errors to VideoRuntimeError and calling onError if provided
* @internal
*/
private throwError(error: unknown) {
const parsedError = tryParseNativeVideoError(error);
if (
parsedError instanceof VideoRuntimeError &&
this.triggerEvent("onError", parsedError)
) {
// We don't throw errors if onError is provided
return;
}
throw parsedError;
}
// Source
get source(): VideoPlayerSource {
return this.player.source;
}
// Status
get status(): VideoPlayerStatus {
if (this.video.error) return "error";
if (this.video.readyState === HTMLMediaElement.HAVE_NOTHING) return "idle";
if (
this.video.readyState === HTMLMediaElement.HAVE_ENOUGH_DATA ||
this.video.readyState === HTMLMediaElement.HAVE_FUTURE_DATA
)
return "readyToPlay";
return "loading";
}
// Duration
get duration(): number {
return this.video.duration;
}
// Volume
get volume(): number {
return this.video.volume;
}
set volume(value: number) {
this.video.volume = value;
}
// Current Time
get currentTime(): number {
return this.video.currentTime;
}
set currentTime(value: number) {
this.video.currentTime = value;
}
// Muted
get muted(): boolean {
return this.video.muted;
}
set muted(value: boolean) {
this.video.muted = value;
}
// Loop
get loop(): boolean {
return this.video.loop;
}
set loop(value: boolean) {
this.video.loop = value;
}
// Rate
get rate(): number {
return this.video.playbackRate;
}
set rate(value: number) {
this.video.playbackRate = value;
}
// Mix Audio Mode
get mixAudioMode(): MixAudioMode {
return "auto";
}
set mixAudioMode(_: MixAudioMode) {
if (__DEV__) {
console.warn(
"mixAudioMode is not supported on this platform, it wont have any effect",
);
}
}
// Ignore Silent Switch Mode
get ignoreSilentSwitchMode(): IgnoreSilentSwitchMode {
return "auto";
}
set ignoreSilentSwitchMode(_: IgnoreSilentSwitchMode) {
if (__DEV__) {
console.warn(
"ignoreSilentSwitchMode is not supported on this platform, it wont have any effect",
);
}
}
// Play In Background
get playInBackground(): boolean {
return true;
}
set playInBackground(value: boolean) {
this.player.playInBackground = value;
}
// Play When Inactive
get playWhenInactive(): boolean {
return this.player.playWhenInactive;
}
set playWhenInactive(value: boolean) {
this.player.playWhenInactive = value;
}
// Is Playing
get isPlaying(): boolean {
return this.player.isPlaying;
}
async initialize(): Promise<void> {
await this.wrapPromise(this.player.initialize());
}
async preload(): Promise<void> {
this.player.load(this.media, this.startTime);
}
/**
* Releases the player's native resources and releases native state.
* After calling this method, the player is no longer usable.
* Accessing any properties or methods of the player after calling this method will throw an error.
* If you want to clean player resource use `replaceSourceAsync` with `null` instead.
*/
release(): void {
this.__destroy();
}
play(): void {
try {
this.video.play();
} catch (error) {
this.throwError(error);
}
}
pause(): void {
try {
this.video.pause();
} catch (error) {
this.throwError(error);
}
}
seekBy(time: number): void {
try {
this.video.currentTime += time;
} catch (error) {
this.throwError(error);
}
}
seekTo(time: number): void {
try {
this.video.currentTime = time;
} catch (error) {
this.throwError(error);
}
}
async replaceSourceAsync(
source:
| VideoSource
| VideoConfig
| NoAutocomplete<VideoPlayerSource>
| null,
): Promise<void> {
this.video.src =
typeof source === "object" && "uri" in source
? source.uri
: source;
}
// Text Track Management
getAvailableTextTracks(): TextTrack[] {
try {
return this.player.getAvailableTextTracks();
} catch (error) {
this.throwError(error);
return [];
}
}
selectTextTrack(textTrack: TextTrack | null): void {
try {
this.player.selectTextTrack(textTrack);
} catch (error) {
this.throwError(error);
}
}
// Selected Text Track
get selectedTrack(): TextTrack | undefined {
return this.player.selectedTrack;
}
}
export { VideoPlayer };

View File

@@ -1,33 +1,50 @@
import type { VideoPlayerEventEmitter } from '../spec/nitro/VideoPlayerEventEmitter.nitro';
import type { VideoPlayerEvents as VideoPlayerEventsInterface } from './types/Events';
import {
ALL_PLAYER_EVENTS,
type AllPlayerEvents as PlayerEvents,
} from './types/Events';
export class VideoPlayerEvents implements VideoPlayerEventsInterface {
export class VideoPlayerEvents {
protected eventEmitter: VideoPlayerEventEmitter;
protected eventListeners: Partial<
Record<keyof PlayerEvents, Set<(...params: any[]) => void>>
> = {};
protected readonly supportedEvents: (keyof VideoPlayerEventsInterface)[] = [
'onAudioBecomingNoisy',
'onAudioFocusChange',
'onBandwidthUpdate',
'onBuffer',
'onControlsVisibleChange',
'onEnd',
'onExternalPlaybackChange',
'onLoad',
'onLoadStart',
'onPlaybackRateChange',
'onPlaybackStateChange',
'onProgress',
'onReadyToDisplay',
'onSeek',
'onStatusChange',
'onTextTrackDataChanged',
'onTimedMetadata',
'onTrackChange',
'onVolumeChange',
];
protected readonly supportedEvents: (keyof PlayerEvents)[] =
ALL_PLAYER_EVENTS;
constructor(eventEmitter: VideoPlayerEventEmitter) {
constructor(eventEmitter: PlayerEvents) {
this.eventEmitter = eventEmitter;
for (const event of this.supportedEvents) {
// @ts-expect-error we narrow the type of the event
this.eventEmitter[event] = this.triggerEvent.bind(this, event);
}
}
protected triggerEvent<Event extends keyof PlayerEvents>(
event: Event,
...params: Parameters<PlayerEvents[Event]>
): boolean {
if (!this.eventListeners[event]?.size) return false;
for (const fn of this.eventListeners[event]) {
fn(...params);
}
return true;
}
addEventListener<Event extends keyof PlayerEvents>(
event: Event,
callback: PlayerEvents[Event],
) {
this.eventListeners[event] ??= new Set<PlayerEvents[Event]>();
this.eventListeners[event].add(callback);
}
removeEventListener<Event extends keyof PlayerEvents>(
event: Event,
callback: PlayerEvents[Event],
) {
this.eventListeners[event]?.delete(callback);
}
/**
@@ -43,177 +60,7 @@ export class VideoPlayerEvents implements VideoPlayerEventsInterface {
* Clears a specific event from the event emitter.
* @param event - The name of the event to clear.
*/
clearEvent(event: keyof VideoPlayerEventsInterface) {
this.eventEmitter[event] = VideoPlayerEvents.NOOP;
}
static NOOP = () => {};
set onAudioBecomingNoisy(
value: VideoPlayerEventsInterface['onAudioBecomingNoisy']
) {
this.eventEmitter.onAudioBecomingNoisy = value;
}
get onAudioBecomingNoisy(): VideoPlayerEventsInterface['onAudioBecomingNoisy'] {
return this.eventEmitter.onAudioBecomingNoisy;
}
set onAudioFocusChange(
value: VideoPlayerEventsInterface['onAudioFocusChange']
) {
this.eventEmitter.onAudioFocusChange = value;
}
get onAudioFocusChange(): VideoPlayerEventsInterface['onAudioFocusChange'] {
return this.eventEmitter.onAudioFocusChange;
}
set onBandwidthUpdate(
value: VideoPlayerEventsInterface['onBandwidthUpdate']
) {
this.eventEmitter.onBandwidthUpdate = value;
}
get onBandwidthUpdate(): VideoPlayerEventsInterface['onBandwidthUpdate'] {
return this.eventEmitter.onBandwidthUpdate;
}
set onBuffer(value: VideoPlayerEventsInterface['onBuffer']) {
this.eventEmitter.onBuffer = value;
}
get onBuffer(): VideoPlayerEventsInterface['onBuffer'] {
return this.eventEmitter.onBuffer;
}
set onControlsVisibleChange(
value: VideoPlayerEventsInterface['onControlsVisibleChange']
) {
this.eventEmitter.onControlsVisibleChange = value;
}
get onControlsVisibleChange(): VideoPlayerEventsInterface['onControlsVisibleChange'] {
return this.eventEmitter.onControlsVisibleChange;
}
set onEnd(value: VideoPlayerEventsInterface['onEnd']) {
this.eventEmitter.onEnd = value;
}
get onEnd(): VideoPlayerEventsInterface['onEnd'] {
return this.eventEmitter.onEnd;
}
set onExternalPlaybackChange(
value: VideoPlayerEventsInterface['onExternalPlaybackChange']
) {
this.eventEmitter.onExternalPlaybackChange = value;
}
get onExternalPlaybackChange(): VideoPlayerEventsInterface['onExternalPlaybackChange'] {
return this.eventEmitter.onExternalPlaybackChange;
}
set onLoad(value: VideoPlayerEventsInterface['onLoad']) {
this.eventEmitter.onLoad = value;
}
get onLoad(): VideoPlayerEventsInterface['onLoad'] {
return this.eventEmitter.onLoad;
}
set onLoadStart(value: VideoPlayerEventsInterface['onLoadStart']) {
this.eventEmitter.onLoadStart = value;
}
get onLoadStart(): VideoPlayerEventsInterface['onLoadStart'] {
return this.eventEmitter.onLoadStart;
}
set onPlaybackStateChange(
value: VideoPlayerEventsInterface['onPlaybackStateChange']
) {
this.eventEmitter.onPlaybackStateChange = value;
}
get onPlaybackStateChange(): VideoPlayerEventsInterface['onPlaybackStateChange'] {
return this.eventEmitter.onPlaybackStateChange;
}
set onPlaybackRateChange(
value: VideoPlayerEventsInterface['onPlaybackRateChange']
) {
this.eventEmitter.onPlaybackRateChange = value;
}
get onPlaybackRateChange(): VideoPlayerEventsInterface['onPlaybackRateChange'] {
return this.eventEmitter.onPlaybackRateChange;
}
set onProgress(value: VideoPlayerEventsInterface['onProgress']) {
this.eventEmitter.onProgress = value;
}
get onProgress(): VideoPlayerEventsInterface['onProgress'] {
return this.eventEmitter.onProgress;
}
set onReadyToDisplay(value: VideoPlayerEventsInterface['onReadyToDisplay']) {
this.eventEmitter.onReadyToDisplay = value;
}
get onReadyToDisplay(): VideoPlayerEventsInterface['onReadyToDisplay'] {
return this.eventEmitter.onReadyToDisplay;
}
set onSeek(value: VideoPlayerEventsInterface['onSeek']) {
this.eventEmitter.onSeek = value;
}
get onSeek(): VideoPlayerEventsInterface['onSeek'] {
return this.eventEmitter.onSeek;
}
set onStatusChange(value: VideoPlayerEventsInterface['onStatusChange']) {
this.eventEmitter.onStatusChange = value;
}
get onStatusChange(): VideoPlayerEventsInterface['onStatusChange'] {
return this.eventEmitter.onStatusChange;
}
set onTimedMetadata(value: VideoPlayerEventsInterface['onTimedMetadata']) {
this.eventEmitter.onTimedMetadata = value;
}
get onTimedMetadata(): VideoPlayerEventsInterface['onTimedMetadata'] {
return this.eventEmitter.onTimedMetadata;
}
set onTextTrackDataChanged(
value: VideoPlayerEventsInterface['onTextTrackDataChanged']
) {
this.eventEmitter.onTextTrackDataChanged = value;
}
get onTextTrackDataChanged(): VideoPlayerEventsInterface['onTextTrackDataChanged'] {
return this.eventEmitter.onTextTrackDataChanged;
}
set onTrackChange(value: VideoPlayerEventsInterface['onTrackChange']) {
this.eventEmitter.onTrackChange = value;
}
get onTrackChange(): VideoPlayerEventsInterface['onTrackChange'] {
return this.eventEmitter.onTrackChange;
}
set onVolumeChange(value: VideoPlayerEventsInterface['onVolumeChange']) {
this.eventEmitter.onVolumeChange = value;
}
get onVolumeChange(): VideoPlayerEventsInterface['onVolumeChange'] {
return this.eventEmitter.onVolumeChange;
clearEvent(event: keyof PlayerEvents) {
this.eventListeners[event]?.clear();
}
}

View File

@@ -0,0 +1,198 @@
import type {
BandwidthData,
onLoadData,
onLoadStartData,
onPlaybackStateChangeData,
onProgressData,
onVolumeChangeData,
AllPlayerEvents as PlayerEvents,
TimedMetadata,
} from "./types/Events";
import type { TextTrack } from "./types/TextTrack";
import type { VideoRuntimeError } from "./types/VideoError";
import type { VideoPlayerStatus } from "./types/VideoPlayerStatus";
export class WebEventEmiter implements PlayerEvents {
private _isBuferring = false;
constructor(private video: HTMLVideoElement) {
// TODO: add `onBandwithUpdate`
// on buffer
this.video.addEventListener("canplay", this._onCanPlay);
this.video.addEventListener("waiting", this._onWaiting);
// on end
this.video.addEventListener("ended", this._onEnded);
// on load
this.video.addEventListener("durationchange", this._onDurationChange);
// on load start
this.video.addEventListener("loadstart", this._onLoadStart);
// on playback state change
this.video.addEventListener("play", this._onPlay);
this.video.addEventListener("pause", this._onPause);
// on playback rate change
this.video.addEventListener("ratechange", this._onRateChange);
// on progress
this.video.addEventListener("timeupdate", this._onTimeUpdate);
// on ready to play
this.video.addEventListener("loadeddata", this._onLoadedData);
// on seek
this.video.addEventListener("seeked", this._onSeeked);
// on volume change
this.video.addEventListener("volumechange", this._onVolumeChange);
// on status change
this.video.addEventListener("error", this._onError);
}
destroy() {
this.video.removeEventListener("canplay", this._onCanPlay);
this.video.removeEventListener("waiting", this._onWaiting);
this.video.removeEventListener("ended", this._onEnded);
this.video.removeEventListener("durationchange", this._onDurationChange);
this.video.removeEventListener("play", this._onPlay);
this.video.removeEventListener("pause", this._onPause);
this.video.removeEventListener("ratechange", this._onRateChange);
this.video.removeEventListener("timeupdate", this._onTimeUpdate);
this.video.removeEventListener("loadeddata", this._onLoadedData);
this.video.removeEventListener("seeked", this._onSeeked);
this.video.removeEventListener("volumechange", this._onVolumeChange);
this.video.removeEventListener("error", this._onError);
}
_onTimeUpdate() {
this.onProgress({
currentTime: this.video.currentTime,
bufferDuration: this.video.buffered.length
? this.video.buffered.end(this.video.buffered.length - 1)
: 0,
});
}
_onCanPlay() {
this._isBuferring = false;
this.onBuffer(false);
this.onStatusChange("readyToPlay");
}
_onWaiting() {
this._isBuferring = true;
this.onBuffer(true);
this.onStatusChange("loading");
}
_onDurationChange() {
this.onLoad({
currentTime: this.video.currentTime,
duration: this.video.duration,
width: this.video.width,
height: this.video.height,
orientation: "unknown",
});
}
_onEnded() {
this.onEnd();
this.onStatusChange("idle");
}
_onLoadStart() {
this.onLoadStart({
sourceType: "network",
source: {
uri: this.video.currentSrc,
config: {
uri: this.video.currentSrc,
externalSubtitles: [],
},
getAssetInformationAsync: async () => {
return {
duration: BigInt(this.video.duration),
height: this.video.height,
width: this.video.width,
orientation: "unknown",
bitrate: NaN,
fileSize: BigInt(NaN),
isHDR: false,
isLive: false,
};
},
},
});
}
_onPlay() {
this.onPlaybackStateChange({
isPlaying: true,
isBuffering: this._isBuferring,
});
}
_onPause() {
this.onPlaybackStateChange({
isPlaying: false,
isBuffering: this._isBuferring,
});
}
_onRateChange() {
this.onPlaybackRateChange(this.video.playbackRate);
}
_onLoadedData() {
this.onReadyToDisplay();
}
_onSeeked() {
this.onSeek(this.video.currentTime);
}
_onVolumeChange() {
this.onVolumeChange({ muted: this.video.muted, volume: this.video.volume });
}
_onError() {
this.onStatusChange("error");
}
NOOP = () => {};
onError: (error: VideoRuntimeError) => void = this.NOOP;
onAudioBecomingNoisy: () => void = this.NOOP;
onAudioFocusChange: (hasAudioFocus: boolean) => void = this.NOOP;
onBandwidthUpdate: (data: BandwidthData) => void = this.NOOP;
onBuffer: (buffering: boolean) => void = this.NOOP;
onControlsVisibleChange: (visible: boolean) => void = this.NOOP;
onEnd: () => void = this.NOOP;
onExternalPlaybackChange: (externalPlaybackActive: boolean) => void =
this.NOOP;
onLoad: (data: onLoadData) => void = this.NOOP;
onLoadStart: (data: onLoadStartData) => void = this.NOOP;
onPlaybackStateChange: (data: onPlaybackStateChangeData) => void = this.NOOP;
onPlaybackRateChange: (rate: number) => void = this.NOOP;
onProgress: (data: onProgressData) => void = this.NOOP;
onReadyToDisplay: () => void = this.NOOP;
onSeek: (seekTime: number) => void = this.NOOP;
onTimedMetadata: (metadata: TimedMetadata) => void = this.NOOP;
onTextTrackDataChanged: (texts: string[]) => void = this.NOOP;
onTrackChange: (track: TextTrack | null) => void = this.NOOP;
onVolumeChange: (data: onVolumeChangeData) => void = this.NOOP;
onStatusChange: (status: VideoPlayerStatus) => void = this.NOOP;
}

View File

@@ -1,19 +1,6 @@
import { useEffect } from 'react';
import { VideoPlayer } from '../VideoPlayer';
import { type VideoPlayerEvents } from '../types/Events';
// Omit undefined from events
type NonUndefined<T> = T extends undefined ? never : T;
// Valid events names
type Events = keyof VideoPlayerEvents | 'onError';
// Valid events params
type EventsParams<T extends Events> = T extends keyof VideoPlayerEvents
? // (Native) Events from VideoPlayerEvents
Parameters<VideoPlayerEvents[T]>
: // (JS) Events from Video Player
Parameters<NonUndefined<VideoPlayer[T]>>;
import type { AllPlayerEvents } from '../types/Events';
import type { VideoPlayer } from '../VideoPlayer';
/**
* Attaches an event listener to a `VideoPlayer` instance for a specified event.
@@ -22,22 +9,14 @@ type EventsParams<T extends Events> = T extends keyof VideoPlayerEvents
* @param event - The name of the event to attach the callback to
* @param callback - The callback for the event
*/
export const useEvent = <T extends Events>(
export const useEvent = <T extends keyof AllPlayerEvents>(
player: VideoPlayer,
event: T,
callback: (...args: EventsParams<T>) => void
callback: AllPlayerEvents[T]
) => {
useEffect(() => {
// @ts-expect-error we narrow the type of the event
player[event] = callback;
player.addEventListener(event, callback);
return () => {
if (event === 'onError') {
// onError is not native event, so we can set it to undefined
player.onError = undefined;
} else {
player.clearEvent(event);
}
};
return () => player.removeEventListener(event, callback);
}, [player, event, callback]);
};

View File

@@ -0,0 +1,44 @@
import type { VideoPlayerSource } from '../../spec/nitro/VideoPlayerSource.nitro';
import type { NoAutocomplete } from '../types/Utils';
import type { VideoConfig, VideoSource } from '../types/VideoConfig';
import { isVideoPlayerSource } from '../utils/sourceFactory';
import { VideoPlayer } from '../VideoPlayer';
import { useManagedInstance } from './useManagedInstance';
const sourceEqual = <T extends VideoConfig | VideoSource | VideoPlayerSource>(
a: T,
b?: T
) => {
if (isVideoPlayerSource(a) && isVideoPlayerSource(b)) {
return a.equals(b);
}
return JSON.stringify(a) === JSON.stringify(b);
};
/**
* Creates a `VideoPlayer` instance and manages its lifecycle.
*
* @param source - The source of the video to play
* @param setup - A function to setup the player
* @returns The `VideoPlayer` instance
*/
export const useVideoPlayer = (
source: VideoConfig | VideoSource | NoAutocomplete<VideoPlayerSource>,
setup?: (player: VideoPlayer) => void
) => {
return useManagedInstance(
{
factory: () => {
const player = new VideoPlayer(source);
setup?.(player);
return player;
},
cleanup: (player) => {
player.__destroy();
},
dependenciesEqualFn: sourceEqual,
},
[JSON.stringify(source)]
);
};

View File

@@ -0,0 +1,7 @@
declare module 'shaka-player' {
export = shaka;
}
declare module 'shaka-player/dist/shaka-player.compiled' {
export = shaka;
}

View File

@@ -1,6 +1,7 @@
import type { VideoPlayerSource } from '../../spec/nitro/VideoPlayerSource.nitro';
import type { TextTrack } from './TextTrack';
import type { VideoRuntimeError } from './VideoError';
import type { VideoOrientation } from './VideoOrientation';
import type { VideoPlayerSourceBase } from './VideoPlayerSourceBase';
import type { VideoPlayerStatus } from './VideoPlayerStatus';
export interface VideoPlayerEvents {
@@ -27,6 +28,7 @@ export interface VideoPlayerEvents {
/**
* Called when the video view's controls visibility changes.
* @param visible Whether the video view's controls are visible.
* @platform Android, Ios
*/
onControlsVisibleChange: (visible: boolean) => void;
/**
@@ -71,15 +73,18 @@ export interface VideoPlayerEvents {
onSeek: (seekTime: number) => void;
/**
* Called when player receives timed metadata.
* @platform Android, Ios
*/
onTimedMetadata: (metadata: TimedMetadata) => void;
/**
* Called when the text track (currently displayed subtitle) data changes.
* @platform Android, Ios
*/
onTextTrackDataChanged: (texts: string[]) => void;
/**
* Called when the selected text track changes.
* @param track - The newly selected text track, or null if no track is selected
* @platform Android, Ios
*/
onTrackChange: (track: TextTrack | null) => void;
/**
@@ -92,6 +97,10 @@ export interface VideoPlayerEvents {
onStatusChange: (status: VideoPlayerStatus) => void;
}
export interface AllPlayerEvents extends VideoPlayerEvents {
onError: (error: VideoRuntimeError) => void;
}
export interface VideoViewEvents {
/**
* Called when the video view's picture in picture state changes.
@@ -173,7 +182,7 @@ export interface onLoadStartData {
/**
* The source of the video.
*/
source: VideoPlayerSource;
source: VideoPlayerSourceBase;
}
export interface onPlaybackStateChangeData {
@@ -220,3 +229,42 @@ export interface onVolumeChangeData {
*/
muted: boolean;
}
type CheckAllAndOnly<T, A extends readonly (keyof T)[]> =
// Missing keys?
Exclude<keyof T, A[number]> extends never
? // Extra keys?
Exclude<A[number], keyof T> extends never
? A
: ['Extra keys', Exclude<A[number], keyof T>]
: ['Missing keys', Exclude<keyof T, A[number]>];
function allKeysOf<T>() {
return <A extends readonly (keyof T)[]>(...arr: A): CheckAllAndOnly<T, A> => {
return arr as CheckAllAndOnly<T, A>;
};
}
export const ALL_PLAYER_EVENTS: (keyof AllPlayerEvents)[] =
allKeysOf<AllPlayerEvents>()(
'onAudioBecomingNoisy',
'onAudioFocusChange',
'onBandwidthUpdate',
'onBuffer',
'onControlsVisibleChange',
'onEnd',
'onError',
'onExternalPlaybackChange',
'onLoad',
'onLoadStart',
'onPlaybackStateChange',
'onPlaybackRateChange',
'onProgress',
'onReadyToDisplay',
'onSeek',
'onTimedMetadata',
'onTextTrackDataChanged',
'onTrackChange',
'onVolumeChange',
'onStatusChange'
);

View File

@@ -1,74 +1,15 @@
import * as React from 'react';
import type { ViewProps, ViewStyle } from 'react-native';
import type { ViewStyle } from 'react-native';
import { NitroModules } from 'react-native-nitro-modules';
import type {
SurfaceType,
VideoViewViewManager,
VideoViewViewManagerFactory,
} from '../../spec/nitro/VideoViewViewManager.nitro';
import type { VideoViewEvents } from '../types/Events';
import type { ResizeMode } from '../types/ResizeMode';
import { tryParseNativeVideoError, VideoError } from '../types/VideoError';
import type { VideoPlayer } from '../VideoPlayer';
import { NativeVideoView } from './NativeVideoView';
export interface VideoViewProps extends Partial<VideoViewEvents>, ViewProps {
/**
* The player to play the video - {@link VideoPlayer}
*/
player: VideoPlayer;
/**
* The style of the video view - {@link ViewStyle}
*/
style?: ViewStyle;
/**
* Whether to show the controls. Defaults to false.
*/
controls?: boolean;
/**
* Whether to enable & show the picture in picture button in native controls. Defaults to false.
*/
pictureInPicture?: boolean;
/**
* Whether to automatically enter picture in picture mode when the video is playing. Defaults to false.
*/
autoEnterPictureInPicture?: boolean;
/**
* How the video should be resized to fit the view. Defaults to 'none'.
* - 'contain': Scale the video uniformly (maintain aspect ratio) so that it fits entirely within the view
* - 'cover': Scale the video uniformly (maintain aspect ratio) so that it fills the entire view (may crop)
* - 'stretch': Scale the video to fill the entire view without maintaining aspect ratio
* - 'none': Do not resize the video
*/
resizeMode?: ResizeMode;
/**
* Whether to keep the screen awake while the video view is mounted. Defaults to true.
*/
keepScreenAwake?: boolean;
}
export interface VideoViewRef {
/**
* Enter fullscreen mode
*/
enterFullscreen: () => void;
/**
* Exit fullscreen mode
*/
exitFullscreen: () => void;
/**
* Enter picture in picture mode
*/
enterPictureInPicture: () => void;
/**
* Exit picture in picture mode
*/
exitPictureInPicture: () => void;
/**
* Check if picture in picture mode is supported
* @returns true if picture in picture mode is supported, false otherwise
*/
canEnterPictureInPicture: () => boolean;
}
import type { VideoViewProps, VideoViewRef } from './ViewViewProps';
let nitroIdCounter = 1;
const VideoViewViewManagerFactory =
@@ -104,6 +45,7 @@ const updateProps = (manager: VideoViewViewManager, props: VideoViewProps) => {
manager.willEnterPictureInPicture = props.willEnterPictureInPicture;
manager.willExitPictureInPicture = props.willExitPictureInPicture;
manager.keepScreenAwake = props.keepScreenAwake ?? true;
manager.surfaceType = props.surfaceType ?? 'surface';
};
/**

View File

@@ -0,0 +1,85 @@
import {
forwardRef,
memo,
useEffect,
useImperativeHandle,
useRef,
} from "react";
import { View, type ViewStyle } from "react-native";
import { VideoError } from "../types/VideoError";
import type { VideoPlayer } from "../VideoPlayer.web";
import type { VideoViewProps, VideoViewRef } from "./ViewViewProps";
/**
* VideoView is a component that allows you to display a video from a {@link VideoPlayer}.
*
* @param player - The player to play the video - {@link VideoPlayer}
* @param controls - Whether to show the controls. Defaults to false.
* @param style - The style of the video view - {@link ViewStyle}
* @param pictureInPicture - Whether to show the picture in picture button. Defaults to false.
* @param autoEnterPictureInPicture - Whether to automatically enter picture in picture mode
* when the video is playing. Defaults to false.
* @param resizeMode - How the video should be resized to fit the view. Defaults to 'none'.
*/
const VideoView = forwardRef<VideoViewRef, VideoViewProps>(
(
{
player: nPlayer,
controls = false,
resizeMode = "none",
// auto pip is unsupported
pictureInPicture = false,
autoEnterPictureInPicture = false,
keepScreenAwake = true,
...props
},
ref,
) => {
const player = nPlayer as unknown as VideoPlayer;
const vRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const videoElement = player.__getNativeRef();
vRef.current?.appendChild(videoElement);
return () => {
vRef.current?.removeChild(videoElement);
};
}, [player]);
useImperativeHandle(
ref,
() => ({
enterFullscreen: () => {
player.__getNativeRef().requestFullscreen({ navigationUI: "hide" });
},
exitFullscreen: () => {
document.exitFullscreen();
},
enterPictureInPicture: () => {
player.__getNativeRef().requestPictureInPicture();
},
exitPictureInPicture: () => {
document.exitPictureInPicture();
},
canEnterPictureInPicture: () => document.pictureInPictureEnabled,
}),
[player],
);
useEffect(() => {
player.__getNativeRef().controls = controls;
}, [player, controls]);
return (
<View {...props}>
<div
ref={vRef}
style={{ objectFit: resizeMode === "stretch" ? "fill" : resizeMode }}
/>
</View>
);
},
);
VideoView.displayName = "VideoView";
export default memo(VideoView);

View File

@@ -0,0 +1,75 @@
import type { ViewProps, ViewStyle } from "react-native";
import type { VideoViewEvents } from "../types/Events";
import type { ResizeMode } from "../types/ResizeMode";
import type { VideoPlayer } from "../VideoPlayer";
export interface VideoViewProps extends Partial<VideoViewEvents>, ViewProps {
/**
* The player to play the video - {@link VideoPlayer}
*/
player: VideoPlayer;
/**
* The style of the video view - {@link ViewStyle}
*/
style?: ViewStyle;
/**
* Whether to show the controls. Defaults to false.
*/
controls?: boolean;
/**
* Whether to enable & show the picture in picture button in native controls. Defaults to false.
*/
pictureInPicture?: boolean;
/**
* Whether to automatically enter picture in picture mode when the video is playing. Defaults to false.
*/
autoEnterPictureInPicture?: boolean;
/**
* How the video should be resized to fit the view. Defaults to 'none'.
* - 'contain': Scale the video uniformly (maintain aspect ratio) so that it fits entirely within the view
* - 'cover': Scale the video uniformly (maintain aspect ratio) so that it fills the entire view (may crop)
* - 'stretch': Scale the video to fill the entire view without maintaining aspect ratio
* - 'none': Do not resize the video
*/
resizeMode?: ResizeMode;
/**
* Whether to keep the screen awake while the video view is mounted. Defaults to true.
*/
keepScreenAwake?: boolean;
/**
* The type of underlying native view. Defaults to 'surface'.
* - 'surface': Uses a SurfaceView on Android. More performant, but cannot be animated or transformed.
* - 'texture': Uses a TextureView on Android. Less performant, but can be animated and transformed.
*
* Only applicable on Android
*
* @default 'surface'
* @platform android
*/
surfaceType?: SurfaceType;
}
export interface VideoViewRef {
/**
* Enter fullscreen mode
*/
enterFullscreen: () => void;
/**
* Exit fullscreen mode
*/
exitFullscreen: () => void;
/**
* Enter picture in picture mode
*/
enterPictureInPicture: () => void;
/**
* Exit picture in picture mode
*/
exitPictureInPicture: () => void;
/**
* Check if picture in picture mode is supported
* @returns true if picture in picture mode is supported, false otherwise
*/
canEnterPictureInPicture: () => boolean;
}

View File

@@ -1,26 +1,27 @@
export { useEvent } from './core/hooks/useEvent';
export { useVideoPlayer } from './core/hooks/useVideoPlayer';
export * from './core/types/Events';
export type * from './core/types/Events';
export type { IgnoreSilentSwitchMode } from './core/types/IgnoreSilentSwitchMode';
export type { MixAudioMode } from './core/types/MixAudioMode';
export type { ResizeMode } from './core/types/ResizeMode';
export type { TextTrack } from './core/types/TextTrack';
export type { VideoConfig, VideoSource } from './core/types/VideoConfig';
export {
type LibraryError,
type PlayerError,
type SourceError,
type UnknownError,
type VideoComponentError,
type VideoError,
type VideoErrorCode,
type VideoRuntimeError,
type VideoViewError,
export type {
LibraryError,
PlayerError,
SourceError,
UnknownError,
VideoComponentError,
VideoError,
VideoErrorCode,
VideoRuntimeError,
VideoViewError,
} from './core/types/VideoError';
export type { VideoPlayerStatus } from './core/types/VideoPlayerStatus';
export { VideoPlayer } from './core/VideoPlayer';
export {
default as VideoView,
type VideoViewProps,
type VideoViewRef,
} from './core/video-view/VideoView';
export { VideoPlayer } from './core/VideoPlayer';

View File

@@ -3,6 +3,8 @@ import type { VideoViewEvents } from '../../core/types/Events';
import type { ResizeMode } from '../../core/types/ResizeMode';
import type { VideoPlayer } from './VideoPlayer.nitro';
export type SurfaceType = 'surface' | 'texture';
// @internal
export interface VideoViewViewManager
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }>,
@@ -18,6 +20,7 @@ export interface VideoViewViewManager
exitPictureInPicture(): void;
canEnterPictureInPicture(): boolean;
keepScreenAwake: boolean;
surfaceType: SurfaceType;
}
// @internal

6
shell.nix Normal file
View File

@@ -0,0 +1,6 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
packages = with pkgs; [
bun
];
}