mirror of
https://github.com/zoriya/react-native-video.git
synced 2025-12-06 07:16:12 +00:00
415 lines
13 KiB
Swift
Generated
415 lines
13 KiB
Swift
Generated
///
|
|
/// HybridVideoPlayerSpec_cxx.swift
|
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
/// https://github.com/mrousavy/nitro
|
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
///
|
|
|
|
import Foundation
|
|
import NitroModules
|
|
|
|
/**
|
|
* A class implementation that bridges HybridVideoPlayerSpec over to C++.
|
|
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
*
|
|
* Also, some Swift types need to be bridged with special handling:
|
|
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
*/
|
|
open class HybridVideoPlayerSpec_cxx {
|
|
/**
|
|
* The Swift <> C++ bridge's namespace (`margelo::nitro::video::bridge::swift`)
|
|
* from `ReactNativeVideo-Swift-Cxx-Bridge.hpp`.
|
|
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
*/
|
|
public typealias bridge = margelo.nitro.video.bridge.swift
|
|
|
|
/**
|
|
* Holds an instance of the `HybridVideoPlayerSpec` Swift protocol.
|
|
*/
|
|
private var __implementation: any HybridVideoPlayerSpec
|
|
|
|
/**
|
|
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
*/
|
|
private var __cxxPart: bridge.std__weak_ptr_HybridVideoPlayerSpec_
|
|
|
|
/**
|
|
* Create a new `HybridVideoPlayerSpec_cxx` that wraps the given `HybridVideoPlayerSpec`.
|
|
* All properties and methods bridge to C++ types.
|
|
*/
|
|
public init(_ implementation: any HybridVideoPlayerSpec) {
|
|
self.__implementation = implementation
|
|
self.__cxxPart = .init()
|
|
/* no base class */
|
|
}
|
|
|
|
/**
|
|
* Get the actual `HybridVideoPlayerSpec` instance this class wraps.
|
|
*/
|
|
@inline(__always)
|
|
public func getHybridVideoPlayerSpec() -> any HybridVideoPlayerSpec {
|
|
return __implementation
|
|
}
|
|
|
|
/**
|
|
* Casts this instance to a retained unsafe raw pointer.
|
|
* This acquires one additional strong reference on the object!
|
|
*/
|
|
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
return Unmanaged.passRetained(self).toOpaque()
|
|
}
|
|
|
|
/**
|
|
* Casts an unsafe pointer to a `HybridVideoPlayerSpec_cxx`.
|
|
* The pointer has to be a retained opaque `Unmanaged<HybridVideoPlayerSpec_cxx>`.
|
|
* This removes one strong reference from the object!
|
|
*/
|
|
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridVideoPlayerSpec_cxx {
|
|
return Unmanaged<HybridVideoPlayerSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
}
|
|
|
|
/**
|
|
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
* The C++ part is a `std::shared_ptr<HybridVideoPlayerSpec>`.
|
|
*/
|
|
public func getCxxPart() -> bridge.std__shared_ptr_HybridVideoPlayerSpec_ {
|
|
let cachedCxxPart = self.__cxxPart.lock()
|
|
if cachedCxxPart.__convertToBool() {
|
|
return cachedCxxPart
|
|
} else {
|
|
let newCxxPart = bridge.create_std__shared_ptr_HybridVideoPlayerSpec_(self.toUnsafe())
|
|
__cxxPart = bridge.weakify_std__shared_ptr_HybridVideoPlayerSpec_(newCxxPart)
|
|
return newCxxPart
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
*/
|
|
@inline(__always)
|
|
public var memorySize: Int {
|
|
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
}
|
|
|
|
/**
|
|
* Call dispose() on the Swift class.
|
|
* This _may_ be called manually from JS.
|
|
*/
|
|
@inline(__always)
|
|
public func dispose() {
|
|
self.__implementation.dispose()
|
|
}
|
|
|
|
// Properties
|
|
public final var source: bridge.std__shared_ptr_HybridVideoPlayerSourceSpec_ {
|
|
@inline(__always)
|
|
get {
|
|
return { () -> bridge.std__shared_ptr_HybridVideoPlayerSourceSpec_ in
|
|
let __cxxWrapped = self.__implementation.source.getCxxWrapper()
|
|
return __cxxWrapped.getCxxPart()
|
|
}()
|
|
}
|
|
}
|
|
|
|
public final var eventEmitter: bridge.std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ {
|
|
@inline(__always)
|
|
get {
|
|
return { () -> bridge.std__shared_ptr_HybridVideoPlayerEventEmitterSpec_ in
|
|
let __cxxWrapped = self.__implementation.eventEmitter.getCxxWrapper()
|
|
return __cxxWrapped.getCxxPart()
|
|
}()
|
|
}
|
|
}
|
|
|
|
public final var showNotificationControls: Bool {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.showNotificationControls
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.showNotificationControls = newValue
|
|
}
|
|
}
|
|
|
|
public final var status: Int32 {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.status.rawValue
|
|
}
|
|
}
|
|
|
|
public final var duration: Double {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.duration
|
|
}
|
|
}
|
|
|
|
public final var volume: Double {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.volume
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.volume = newValue
|
|
}
|
|
}
|
|
|
|
public final var currentTime: Double {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.currentTime
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.currentTime = newValue
|
|
}
|
|
}
|
|
|
|
public final var muted: Bool {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.muted
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.muted = newValue
|
|
}
|
|
}
|
|
|
|
public final var loop: Bool {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.loop
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.loop = newValue
|
|
}
|
|
}
|
|
|
|
public final var rate: Double {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.rate
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.rate = newValue
|
|
}
|
|
}
|
|
|
|
public final var mixAudioMode: Int32 {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.mixAudioMode.rawValue
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.mixAudioMode = margelo.nitro.video.MixAudioMode(rawValue: newValue)!
|
|
}
|
|
}
|
|
|
|
public final var ignoreSilentSwitchMode: Int32 {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.ignoreSilentSwitchMode.rawValue
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.ignoreSilentSwitchMode = margelo.nitro.video.IgnoreSilentSwitchMode(rawValue: newValue)!
|
|
}
|
|
}
|
|
|
|
public final var playInBackground: Bool {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.playInBackground
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.playInBackground = newValue
|
|
}
|
|
}
|
|
|
|
public final var playWhenInactive: Bool {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.playWhenInactive
|
|
}
|
|
@inline(__always)
|
|
set {
|
|
self.__implementation.playWhenInactive = newValue
|
|
}
|
|
}
|
|
|
|
public final var isPlaying: Bool {
|
|
@inline(__always)
|
|
get {
|
|
return self.__implementation.isPlaying
|
|
}
|
|
}
|
|
|
|
public final var selectedTrack: bridge.std__optional_TextTrack_ {
|
|
@inline(__always)
|
|
get {
|
|
return { () -> bridge.std__optional_TextTrack_ in
|
|
if let __unwrappedValue = self.__implementation.selectedTrack {
|
|
return bridge.create_std__optional_TextTrack_(__unwrappedValue)
|
|
} else {
|
|
return .init()
|
|
}
|
|
}()
|
|
}
|
|
}
|
|
|
|
// Methods
|
|
@inline(__always)
|
|
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 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)
|
|
return __instance.getHybridVideoPlayerSourceSpec()
|
|
}()
|
|
} else {
|
|
return nil
|
|
}
|
|
}())
|
|
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
__result
|
|
.then({ __result in __promiseHolder.resolve() })
|
|
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
return __promise
|
|
}()
|
|
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
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
|
|
}()
|
|
return bridge.create_Result_std__vector_TextTrack__(__resultCpp)
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_std__vector_TextTrack__(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func selectTextTrack(textTrack: bridge.std__optional_TextTrack_) -> bridge.Result_void_ {
|
|
do {
|
|
try self.__implementation.selectTextTrack(textTrack: textTrack.value)
|
|
return bridge.create_Result_void_()
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func initialize() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
do {
|
|
let __result = try self.__implementation.initialize()
|
|
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
__result
|
|
.then({ __result in __promiseHolder.resolve() })
|
|
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
return __promise
|
|
}()
|
|
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func preload() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
do {
|
|
let __result = try self.__implementation.preload()
|
|
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
__result
|
|
.then({ __result in __promiseHolder.resolve() })
|
|
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
return __promise
|
|
}()
|
|
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func play() -> bridge.Result_void_ {
|
|
do {
|
|
try self.__implementation.play()
|
|
return bridge.create_Result_void_()
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func pause() -> bridge.Result_void_ {
|
|
do {
|
|
try self.__implementation.pause()
|
|
return bridge.create_Result_void_()
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func seekBy(time: Double) -> bridge.Result_void_ {
|
|
do {
|
|
try self.__implementation.seekBy(time: time)
|
|
return bridge.create_Result_void_()
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
}
|
|
}
|
|
|
|
@inline(__always)
|
|
public final func seekTo(time: Double) -> bridge.Result_void_ {
|
|
do {
|
|
try self.__implementation.seekTo(time: time)
|
|
return bridge.create_Result_void_()
|
|
} catch (let __error) {
|
|
let __exceptionPtr = __error.toCpp()
|
|
return bridge.create_Result_void_(__exceptionPtr)
|
|
}
|
|
}
|
|
}
|