fix(player): add a setSource

This commit is contained in:
2026-07-21 19:54:24 +02:00
parent 6eb02d32cb
commit a2d5ede547
7 changed files with 14 additions and 8 deletions
+3 -3
View File
@@ -232,9 +232,9 @@ namespace margelo::nitro::omni {
}
// Methods
void JHybridOmniPlayerSpec::setSource(const std::optional<Source>& src) {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSource> /* src */)>("setSource");
method(_javaPart, src.has_value() ? JSource::fromCpp(src.value()) : nullptr);
void JHybridOmniPlayerSpec::setSource(const std::optional<Source>& source) {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSource> /* source */)>("setSource");
method(_javaPart, source.has_value() ? JSource::fromCpp(source.value()) : nullptr);
}
void JHybridOmniPlayerSpec::play() {
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("play");
+1 -1
View File
@@ -76,7 +76,7 @@ namespace margelo::nitro::omni {
public:
// Methods
void setSource(const std::optional<Source>& src) override;
void setSource(const std::optional<Source>& source) override;
void play() override;
void pause() override;
void seekBy(double offset) override;
@@ -110,7 +110,7 @@ abstract class HybridOmniPlayerSpec: HybridObject() {
// Methods
@DoNotStrip
@Keep
abstract fun setSource(src: Source?): Unit
abstract fun setSource(source: Source?): Unit
@DoNotStrip
@Keep
+1 -1
View File
@@ -89,7 +89,7 @@ namespace margelo::nitro::omni {
public:
// Methods
virtual void setSource(const std::optional<Source>& src) = 0;
virtual void setSource(const std::optional<Source>& source) = 0;
virtual void play() = 0;
virtual void pause() = 0;
virtual void seekBy(double offset) = 0;
+4
View File
@@ -74,6 +74,10 @@ export class WebOmniPlayer implements OmniPlayer {
return this._source;
}
setSource(source?: Source): void {
this.source = source ?? null;
}
set source(source: Source | null) {
this._source = source;
// Drop the overlay subtitle if it is not part of the new source.
-2
View File
@@ -56,8 +56,6 @@ export interface OmniPlayer
extends HybridObject<{ android: "kotlin" }>,
OmniPlayerT {
readonly eventMap: OmniEventMap;
setSource(src?: Source): void;
}
export interface OmniPlayerFactory extends HybridObject<{ android: "kotlin" }> {
+4
View File
@@ -1,6 +1,10 @@
import type { Source } from "./source";
export interface OmniPlayer extends OmniPlayerState {
showNotification?: boolean;
setSource(source?: Source): void;
play(): void;
pause(): void;
seekBy(offset: number): void;