Create types for player & view

This commit is contained in:
2026-04-09 12:52:54 +02:00
parent c71c8fb8f9
commit e1e2fa3f3b
70 changed files with 3499 additions and 369 deletions
@@ -0,0 +1,54 @@
///
/// HybridOmniPlayerFactorySpec.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 com.margelo.nitro.core.HybridObject
/**
* A Kotlin class representing the OmniPlayerFactory HybridObject.
* Implement this abstract class to create Kotlin-based instances of OmniPlayerFactory.
*/
@DoNotStrip
@Keep
@Suppress(
"KotlinJniMissingFunction", "unused",
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
)
abstract class HybridOmniPlayerFactorySpec: HybridObject() {
// Properties
// Methods
@DoNotStrip
@Keep
abstract fun createPlayer(props: HybridOmniPlayerPropsSpec): HybridOmniPlayerSpec
// Default implementation of `HybridObject.toString()`
override fun toString(): String {
return "[HybridObject OmniPlayerFactory]"
}
// C++ backing class
@DoNotStrip
@Keep
protected open class CxxPart(javaPart: HybridOmniPlayerFactorySpec): HybridObject.CxxPart(javaPart) {
// C++ JHybridOmniPlayerFactorySpec::CxxPart::initHybrid(...)
external override fun initHybrid(): HybridData
}
override fun createCxxPart(): CxxPart {
return CxxPart(this)
}
companion object {
protected const val TAG = "HybridOmniPlayerFactorySpec"
}
}
@@ -0,0 +1,80 @@
///
/// HybridOmniPlayerPropsSpec.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 com.margelo.nitro.core.HybridObject
/**
* A Kotlin class representing the OmniPlayerProps HybridObject.
* Implement this abstract class to create Kotlin-based instances of OmniPlayerProps.
*/
@DoNotStrip
@Keep
@Suppress(
"KotlinJniMissingFunction", "unused",
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
)
abstract class HybridOmniPlayerPropsSpec: HybridObject() {
// Properties
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var src: Array<VideoSrc>
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var startTime: Double?
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var subtitles: Array<Subtitle>
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var metadata: Metadata?
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var mixAudio: MixAudioMode?
// Methods
// Default implementation of `HybridObject.toString()`
override fun toString(): String {
return "[HybridObject OmniPlayerProps]"
}
// C++ backing class
@DoNotStrip
@Keep
protected open class CxxPart(javaPart: HybridOmniPlayerPropsSpec): HybridObject.CxxPart(javaPart) {
// C++ JHybridOmniPlayerPropsSpec::CxxPart::initHybrid(...)
external override fun initHybrid(): HybridData
}
override fun createCxxPart(): CxxPart {
return CxxPart(this)
}
companion object {
protected const val TAG = "HybridOmniPlayerPropsSpec"
}
}
@@ -0,0 +1,143 @@
///
/// HybridOmniPlayerSpec.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 com.margelo.nitro.core.NullType
import com.margelo.nitro.core.HybridObject
/**
* A Kotlin class representing the OmniPlayer HybridObject.
* Implement this abstract class to create Kotlin-based instances of OmniPlayer.
*/
@DoNotStrip
@Keep
@Suppress(
"KotlinJniMissingFunction", "unused",
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
)
abstract class HybridOmniPlayerSpec: HybridObject() {
// Properties
@get:DoNotStrip
@get:Keep
abstract val hasPrev: Boolean
@get:DoNotStrip
@get:Keep
abstract val hasNext: Boolean
@get:DoNotStrip
@get:Keep
abstract val status: PlayerStatus
@get:DoNotStrip
@get:Keep
abstract val isPlaying: Boolean
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var currentTime: Double
@get:DoNotStrip
@get:Keep
abstract val buffered: Double
@get:DoNotStrip
@get:Keep
abstract val duration: Double
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var playbackRate: Double
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var volume: Double
@get:DoNotStrip
@get:Keep
abstract val videos: Array<Track>
@get:DoNotStrip
@get:Keep
abstract val audios: Array<Track>
@get:DoNotStrip
@get:Keep
abstract val subtitles: Array<Track>
@get:DoNotStrip
@get:Keep
abstract val rendition: Array<Rendition>
// Methods
@DoNotStrip
@Keep
abstract fun play(): Unit
@DoNotStrip
@Keep
abstract fun pause(): Unit
@DoNotStrip
@Keep
abstract fun seekBy(offset: Double): Unit
@DoNotStrip
@Keep
abstract fun playPrev(): Unit
@DoNotStrip
@Keep
abstract fun playNext(): Unit
@DoNotStrip
@Keep
abstract fun selectVideo(video: Track): Unit
@DoNotStrip
@Keep
abstract fun selectAudio(audio: Track): Unit
@DoNotStrip
@Keep
abstract fun selectSubtitle(subtitle: Track): Unit
@DoNotStrip
@Keep
abstract fun selectRendition(rendition: Variant_NullType_Rendition?): Unit
// Default implementation of `HybridObject.toString()`
override fun toString(): String {
return "[HybridObject OmniPlayer]"
}
// C++ backing class
@DoNotStrip
@Keep
protected open class CxxPart(javaPart: HybridOmniPlayerSpec): HybridObject.CxxPart(javaPart) {
// C++ JHybridOmniPlayerSpec::CxxPart::initHybrid(...)
external override fun initHybrid(): HybridData
}
override fun createCxxPart(): CxxPart {
return CxxPart(this)
}
companion object {
protected const val TAG = "HybridOmniPlayerSpec"
}
}
@@ -1,5 +1,5 @@
///
/// HybridOmniSpec.kt
/// HybridOmniViewSpec.kt
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
@@ -14,8 +14,8 @@ import com.margelo.nitro.core.HybridObject
import com.margelo.nitro.views.HybridView
/**
* A Kotlin class representing the Omni HybridObject.
* Implement this abstract class to create Kotlin-based instances of Omni.
* A Kotlin class representing the OmniView HybridObject.
* Implement this abstract class to create Kotlin-based instances of OmniView.
*/
@DoNotStrip
@Keep
@@ -24,27 +24,39 @@ import com.margelo.nitro.views.HybridView
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
)
abstract class HybridOmniSpec: HybridView() {
abstract class HybridOmniViewSpec: HybridView() {
// Properties
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var isRed: Boolean
abstract var autoplay: Boolean?
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var showNotification: Boolean?
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var autoPip: Boolean?
// Methods
// Default implementation of `HybridObject.toString()`
override fun toString(): String {
return "[HybridObject Omni]"
return "[HybridObject OmniView]"
}
// C++ backing class
@DoNotStrip
@Keep
protected open class CxxPart(javaPart: HybridOmniSpec): HybridObject.CxxPart(javaPart) {
// C++ JHybridOmniSpec::CxxPart::initHybrid(...)
protected open class CxxPart(javaPart: HybridOmniViewSpec): HybridObject.CxxPart(javaPart) {
// C++ JHybridOmniViewSpec::CxxPart::initHybrid(...)
external override fun initHybrid(): HybridData
}
override fun createCxxPart(): CxxPart {
@@ -52,6 +64,6 @@ abstract class HybridOmniSpec: HybridView() {
}
companion object {
protected const val TAG = "HybridOmniSpec"
protected const val TAG = "HybridOmniViewSpec"
}
}
@@ -0,0 +1,53 @@
///
/// Metadata.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
/**
* Represents the JavaScript object/struct "Metadata".
*/
@DoNotStrip
@Keep
data class Metadata(
@DoNotStrip
@Keep
val title: String,
@DoNotStrip
@Keep
val album: String?,
@DoNotStrip
@Keep
val artist: String?,
@DoNotStrip
@Keep
val imageLink: String?,
@DoNotStrip
@Keep
val hasPrev: Boolean?,
@DoNotStrip
@Keep
val hasNext: Boolean?
) {
/* primary constructor */
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(title: String, album: String?, artist: String?, imageLink: String?, hasPrev: Boolean?, hasNext: Boolean?): Metadata {
return Metadata(title, album, artist, imageLink, hasPrev, hasNext)
}
}
}
@@ -0,0 +1,25 @@
///
/// MixAudioMode.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
/**
* Represents the JavaScript enum/union "MixAudioMode".
*/
@DoNotStrip
@Keep
enum class MixAudioMode(@DoNotStrip @Keep val value: Int) {
MIXWITHOTHERS(0),
DONOTMIX(1),
DUCKOTHERS(2),
AUTO(3);
companion object
}
@@ -0,0 +1,25 @@
///
/// PlayerStatus.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
/**
* Represents the JavaScript enum/union "PlayerStatus".
*/
@DoNotStrip
@Keep
enum class PlayerStatus(@DoNotStrip @Keep val value: Int) {
IDLE(0),
LOADING(1),
READYTOPLAY(2),
ERROR(3);
companion object
}
@@ -0,0 +1,50 @@
///
/// Rendition.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
/**
* Represents the JavaScript object/struct "Rendition".
*/
@DoNotStrip
@Keep
data class Rendition(
@DoNotStrip
@Keep
val id: String,
@DoNotStrip
@Keep
val width: Double,
@DoNotStrip
@Keep
val height: Double,
@DoNotStrip
@Keep
val bitrate: Double,
@DoNotStrip
@Keep
val selected: Boolean
) {
/* primary constructor */
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(id: String, width: Double, height: Double, bitrate: Double, selected: Boolean): Rendition {
return Rendition(id, width, height, bitrate, selected)
}
}
}
@@ -0,0 +1,50 @@
///
/// Subtitle.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
/**
* Represents the JavaScript object/struct "Subtitle".
*/
@DoNotStrip
@Keep
data class Subtitle(
@DoNotStrip
@Keep
val id: String,
@DoNotStrip
@Keep
val link: String,
@DoNotStrip
@Keep
val mimeType: String?,
@DoNotStrip
@Keep
val language: String?,
@DoNotStrip
@Keep
val label: String?
) {
/* primary constructor */
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(id: String, link: String, mimeType: String?, language: String?, label: String?): Subtitle {
return Subtitle(id, link, mimeType, language, label)
}
}
}
@@ -0,0 +1,47 @@
///
/// Track.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
/**
* Represents the JavaScript object/struct "Track".
*/
@DoNotStrip
@Keep
data class Track(
@DoNotStrip
@Keep
val id: String,
@DoNotStrip
@Keep
val label: String?,
@DoNotStrip
@Keep
val language: String?,
@DoNotStrip
@Keep
val selected: Boolean
) {
/* primary constructor */
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(id: String, label: String?, language: String?, selected: Boolean): Track {
return Track(id, label, language, selected)
}
}
}
@@ -0,0 +1,53 @@
///
/// Variant_NullType_Rendition.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 com.facebook.proguard.annotations.DoNotStrip
import com.margelo.nitro.core.NullType
/**
* Represents the TypeScript variant "NullType | Rendition".
*/
@Suppress("ClassName")
@DoNotStrip
sealed class Variant_NullType_Rendition {
@DoNotStrip
data class First(@DoNotStrip val value: NullType): Variant_NullType_Rendition()
@DoNotStrip
data class Second(@DoNotStrip val value: Rendition): Variant_NullType_Rendition()
val isFirst: Boolean
get() = this is First
val isSecond: Boolean
get() = this is Second
fun asFirstOrNull(): NullType? {
val value = (this as? First)?.value ?: return null
return value
}
fun asSecondOrNull(): Rendition? {
val value = (this as? Second)?.value ?: return null
return value
}
inline fun <R> match(first: (NullType) -> R, second: (Rendition) -> R): R {
return when (this) {
is First -> first(value)
is Second -> second(value)
}
}
companion object {
@JvmStatic
@DoNotStrip
fun create(value: NullType): Variant_NullType_Rendition = First(value)
@JvmStatic
@DoNotStrip
fun create(value: Rendition): Variant_NullType_Rendition = Second(value)
}
}
@@ -0,0 +1,44 @@
///
/// VideoSrc.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
/**
* Represents the JavaScript object/struct "VideoSrc".
*/
@DoNotStrip
@Keep
data class VideoSrc(
@DoNotStrip
@Keep
val uri: String,
@DoNotStrip
@Keep
val mimeType: String?,
@DoNotStrip
@Keep
val headers: Map<String, String>
) {
/* primary constructor */
companion object {
/**
* Constructor called from C++
*/
@DoNotStrip
@Keep
@Suppress("unused")
@JvmStatic
private fun fromCpp(uri: String, mimeType: String?, headers: Map<String, String>): VideoSrc {
return VideoSrc(uri, mimeType, headers)
}
}
}
@@ -1,5 +1,5 @@
///
/// HybridOmniManager.kt
/// HybridOmniViewManager.kt
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
@@ -17,22 +17,22 @@ import com.margelo.nitro.views.RecyclableView
import dev.zoriya.omni.*
/**
* Represents the React Native `ViewManager` for the "Omni" Nitro HybridView.
* Represents the React Native `ViewManager` for the "OmniView" Nitro HybridView.
*/
public class HybridOmniManager: SimpleViewManager<View>() {
public class HybridOmniViewManager: SimpleViewManager<View>() {
init {
if (RecyclableView::class.java.isAssignableFrom(HybridOmni::class.java)) {
if (RecyclableView::class.java.isAssignableFrom(OmniView::class.java)) {
// Enable view recycling
super.setupViewRecycling()
}
}
override fun getName(): String {
return "Omni"
return "OmniView"
}
override fun createViewInstance(reactContext: ThemedReactContext): View {
val hybridView = HybridOmni(reactContext)
val hybridView = OmniView(reactContext)
val view = hybridView.view
view.setTag(associated_hybrid_view_tag, hybridView)
return view
@@ -44,7 +44,7 @@ public class HybridOmniManager: SimpleViewManager<View>() {
// 1. Update each prop individually
hybridView.beforeUpdate()
HybridOmniStateUpdater.updateViewProps(hybridView, stateWrapper)
HybridOmniViewStateUpdater.updateViewProps(hybridView, stateWrapper)
hybridView.afterUpdate()
// 2. Continue in base View props
@@ -74,7 +74,7 @@ public class HybridOmniManager: SimpleViewManager<View>() {
}
}
private fun getHybridView(view: View): HybridOmni? {
return view.getTag(associated_hybrid_view_tag) as? HybridOmni
private fun getHybridView(view: View): OmniView? {
return view.getTag(associated_hybrid_view_tag) as? OmniView
}
}
@@ -1,5 +1,5 @@
///
/// HybridOmniStateUpdater.kt
/// HybridOmniViewStateUpdater.kt
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
@@ -10,7 +10,7 @@ package com.margelo.nitro.omni.views
import com.facebook.react.uimanager.StateWrapper
import com.margelo.nitro.omni.*
internal class HybridOmniStateUpdater {
internal class HybridOmniViewStateUpdater {
companion object {
/**
* Updates the props for [view] through C++.
@@ -18,6 +18,6 @@ internal class HybridOmniStateUpdater {
*/
@Suppress("KotlinJniMissingFunction")
@JvmStatic
external fun updateViewProps(view: HybridOmniSpec, state: StateWrapper)
external fun updateViewProps(view: HybridOmniViewSpec, state: StateWrapper)
}
}