feat(android): support chromecast

This commit is contained in:
2026-07-26 19:27:41 +02:00
parent 6423ed0bc5
commit 06efcbf1aa
32 changed files with 902 additions and 57 deletions
@@ -0,0 +1,51 @@
///
/// CastOptions.kt
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
package com.margelo.nitro.omni
import androidx.annotation.Keep
import com.facebook.proguard.annotations.DoNotStrip
import java.util.Objects
/**
* Represents the JavaScript object/struct "CastOptions".
*/
@DoNotStrip
@Keep
data class CastOptions(
@DoNotStrip
@Keep
val receiverApplicationId: String?
) {
/* primary constructor */
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is CastOptions) return false
return Objects.deepEquals(this.receiverApplicationId, other.receiverApplicationId)
}
override fun hashCode(): Int {
return arrayOf<Any?>(
receiverApplicationId
).contentDeepHashCode()
}
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(receiverApplicationId: String?): CastOptions {
return CastOptions(receiverApplicationId)
}
}
}
@@ -0,0 +1,80 @@
///
/// Func_void_CastStatus.kt
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
package com.margelo.nitro.omni
import androidx.annotation.Keep
import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
import dalvik.annotation.optimization.FastNative
/**
* Represents the JavaScript callback `(value: enum) => void`.
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
* or in Kotlin/Java (in which case it is a native callback).
*/
@DoNotStrip
@Keep
@Suppress("ClassName", "RedundantUnitReturnType")
fun interface Func_void_CastStatus: (CastStatus) -> Unit {
/**
* Call the given JS callback.
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
*/
@DoNotStrip
@Keep
override fun invoke(value: CastStatus): Unit
}
/**
* Represents the JavaScript callback `(value: enum) => void`.
* This is implemented in C++, via a `std::function<...>`.
* The callback might be coming from JS.
*/
@DoNotStrip
@Keep
@Suppress(
"KotlinJniMissingFunction", "unused",
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
)
class Func_void_CastStatus_cxx: Func_void_CastStatus {
@DoNotStrip
@Keep
private val mHybridData: HybridData
@DoNotStrip
@Keep
private constructor(hybridData: HybridData) {
mHybridData = hybridData
}
@DoNotStrip
@Keep
override fun invoke(value: CastStatus): Unit
= invoke_cxx(value)
@FastNative
private external fun invoke_cxx(value: CastStatus): Unit
}
/**
* Represents the JavaScript callback `(value: enum) => void`.
* This is implemented in Java/Kotlin, via a `(CastStatus) -> Unit`.
* The callback is always coming from native.
*/
@DoNotStrip
@Keep
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
class Func_void_CastStatus_java(private val function: (CastStatus) -> Unit): Func_void_CastStatus {
@DoNotStrip
@Keep
override fun invoke(value: CastStatus): Unit {
return this.function(value)
}
}
@@ -82,6 +82,24 @@ abstract class HybridOmniEventMapSpec: HybridObject() {
return __result
}
abstract fun addCastStatusListener(cb: (value: CastStatus) -> Unit): Unit
@DoNotStrip
@Keep
private fun addCastStatusListener_cxx(cb: Func_void_CastStatus): Unit {
val __result = addCastStatusListener(cb)
return __result
}
abstract fun removeCastStatusListener(cb: (value: CastStatus) -> Unit): Unit
@DoNotStrip
@Keep
private fun removeCastStatusListener_cxx(cb: Func_void_CastStatus): Unit {
val __result = removeCastStatusListener(cb)
return __result
}
abstract fun addOnEndListener(cb: () -> Unit): Unit
@DoNotStrip
@@ -30,7 +30,7 @@ abstract class HybridOmniPlayerFactorySpec: HybridObject() {
// Methods
@DoNotStrip
@Keep
abstract fun createPlayer(props: Source?, backend: PlayerBackend?): HybridOmniPlayerSpec
abstract fun createPlayer(props: Source?, backend: PlayerBackend?, cast: CastOptions?): HybridOmniPlayerSpec
// Default implementation of `HybridObject.toString()`
override fun toString(): String {