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 // Methods
void JHybridOmniPlayerSpec::setSource(const std::optional<Source>& src) { void JHybridOmniPlayerSpec::setSource(const std::optional<Source>& source) {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSource> /* src */)>("setSource"); static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSource> /* source */)>("setSource");
method(_javaPart, src.has_value() ? JSource::fromCpp(src.value()) : nullptr); method(_javaPart, source.has_value() ? JSource::fromCpp(source.value()) : nullptr);
} }
void JHybridOmniPlayerSpec::play() { void JHybridOmniPlayerSpec::play() {
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("play"); static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("play");
+1 -1
View File
@@ -76,7 +76,7 @@ namespace margelo::nitro::omni {
public: public:
// Methods // Methods
void setSource(const std::optional<Source>& src) override; void setSource(const std::optional<Source>& source) override;
void play() override; void play() override;
void pause() override; void pause() override;
void seekBy(double offset) override; void seekBy(double offset) override;
@@ -110,7 +110,7 @@ abstract class HybridOmniPlayerSpec: HybridObject() {
// Methods // Methods
@DoNotStrip @DoNotStrip
@Keep @Keep
abstract fun setSource(src: Source?): Unit abstract fun setSource(source: Source?): Unit
@DoNotStrip @DoNotStrip
@Keep @Keep
+1 -1
View File
@@ -89,7 +89,7 @@ namespace margelo::nitro::omni {
public: public:
// Methods // 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 play() = 0;
virtual void pause() = 0; virtual void pause() = 0;
virtual void seekBy(double offset) = 0; virtual void seekBy(double offset) = 0;
+4
View File
@@ -74,6 +74,10 @@ export class WebOmniPlayer implements OmniPlayer {
return this._source; return this._source;
} }
setSource(source?: Source): void {
this.source = source ?? null;
}
set source(source: Source | null) { set source(source: Source | null) {
this._source = source; this._source = source;
// Drop the overlay subtitle if it is not part of the new 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" }>, extends HybridObject<{ android: "kotlin" }>,
OmniPlayerT { OmniPlayerT {
readonly eventMap: OmniEventMap; readonly eventMap: OmniEventMap;
setSource(src?: Source): void;
} }
export interface OmniPlayerFactory extends HybridObject<{ android: "kotlin" }> { export interface OmniPlayerFactory extends HybridObject<{ android: "kotlin" }> {
+4
View File
@@ -1,6 +1,10 @@
import type { Source } from "./source";
export interface OmniPlayer extends OmniPlayerState { export interface OmniPlayer extends OmniPlayerState {
showNotification?: boolean; showNotification?: boolean;
setSource(source?: Source): void;
play(): void; play(): void;
pause(): void; pause(): void;
seekBy(offset: number): void; seekBy(offset: number): void;