Implement media sessions notification

This commit is contained in:
2026-04-22 22:51:10 +02:00
parent 6635266fc8
commit a0b43ae009
25 changed files with 173 additions and 219 deletions
@@ -94,6 +94,15 @@ namespace margelo::nitro::omni {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSource> /* source */)>("setSource");
method(_javaPart, JSource::fromCpp(source));
}
std::optional<bool> JHybridOmniPlayerSpec::getShowNotification() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getShowNotification");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
}
void JHybridOmniPlayerSpec::setShowNotification(std::optional<bool> showNotification) {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* showNotification */)>("setShowNotification");
method(_javaPart, showNotification.has_value() ? jni::JBoolean::valueOf(showNotification.value()) : nullptr);
}
bool JHybridOmniPlayerSpec::getHasPrev() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getHasPrev");
auto __result = method(_javaPart);
@@ -53,6 +53,8 @@ namespace margelo::nitro::omni {
std::shared_ptr<HybridOmniEventMapSpec> getEventMap() override;
Source getSource() override;
void setSource(const Source& source) override;
std::optional<bool> getShowNotification() override;
void setShowNotification(std::optional<bool> showNotification) override;
bool getHasPrev() override;
bool getHasNext() override;
std::vector<Track> getVideos() override;
-9
View File
@@ -63,15 +63,6 @@ namespace margelo::nitro::omni {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* autoplay */)>("setAutoplay");
method(_javaPart, autoplay.has_value() ? jni::JBoolean::valueOf(autoplay.value()) : nullptr);
}
std::optional<bool> JHybridOmniViewSpec::getShowNotification() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getShowNotification");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
}
void JHybridOmniViewSpec::setShowNotification(std::optional<bool> showNotification) {
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* showNotification */)>("setShowNotification");
method(_javaPart, showNotification.has_value() ? jni::JBoolean::valueOf(showNotification.value()) : nullptr);
}
std::optional<bool> JHybridOmniViewSpec::getAutoPip() {
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getAutoPip");
auto __result = method(_javaPart);
-2
View File
@@ -54,8 +54,6 @@ namespace margelo::nitro::omni {
void setPlayer(const std::shared_ptr<HybridOmniPlayerSpec>& player) override;
std::optional<bool> getAutoplay() override;
void setAutoplay(std::optional<bool> autoplay) override;
std::optional<bool> getShowNotification() override;
void setShowNotification(std::optional<bool> showNotification) override;
std::optional<bool> getAutoPip() override;
void setAutoPip(std::optional<bool> autoPip) override;
@@ -45,10 +45,6 @@ void JHybridOmniViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /*
hybridView->setAutoplay(props->autoplay.value);
props->autoplay.isDirty = false;
}
if (props->showNotification.isDirty) {
hybridView->setShowNotification(props->showNotification.value);
props->showNotification.isDirty = false;
}
if (props->autoPip.isDirty) {
hybridView->setAutoPip(props->autoPip.value);
props->autoPip.isDirty = false;
@@ -35,6 +35,12 @@ abstract class HybridOmniPlayerSpec: HybridObject() {
@set:Keep
abstract var source: Source
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var showNotification: Boolean?
@get:DoNotStrip
@get:Keep
abstract val hasPrev: Boolean
@@ -38,12 +38,6 @@ abstract class HybridOmniViewSpec: HybridView() {
@set:Keep
abstract var autoplay: Boolean?
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
@set:Keep
abstract var showNotification: Boolean?
@get:DoNotStrip
@get:Keep
@set:DoNotStrip
+2
View File
@@ -17,6 +17,8 @@ namespace margelo::nitro::omni {
prototype.registerHybridGetter("eventMap", &HybridOmniPlayerSpec::getEventMap);
prototype.registerHybridGetter("source", &HybridOmniPlayerSpec::getSource);
prototype.registerHybridSetter("source", &HybridOmniPlayerSpec::setSource);
prototype.registerHybridGetter("showNotification", &HybridOmniPlayerSpec::getShowNotification);
prototype.registerHybridSetter("showNotification", &HybridOmniPlayerSpec::setShowNotification);
prototype.registerHybridGetter("hasPrev", &HybridOmniPlayerSpec::getHasPrev);
prototype.registerHybridGetter("hasNext", &HybridOmniPlayerSpec::getHasNext);
prototype.registerHybridGetter("videos", &HybridOmniPlayerSpec::getVideos);
+3 -1
View File
@@ -27,11 +27,11 @@ namespace margelo::nitro::omni { enum class PlayerStatus; }
#include <memory>
#include "HybridOmniEventMapSpec.hpp"
#include "Source.hpp"
#include <optional>
#include "Track.hpp"
#include <vector>
#include "Rendition.hpp"
#include "PlayerStatus.hpp"
#include <optional>
namespace margelo::nitro::omni {
@@ -63,6 +63,8 @@ namespace margelo::nitro::omni {
virtual std::shared_ptr<HybridOmniEventMapSpec> getEventMap() = 0;
virtual Source getSource() = 0;
virtual void setSource(const Source& source) = 0;
virtual std::optional<bool> getShowNotification() = 0;
virtual void setShowNotification(std::optional<bool> showNotification) = 0;
virtual bool getHasPrev() = 0;
virtual bool getHasNext() = 0;
virtual std::vector<Track> getVideos() = 0;
-2
View File
@@ -18,8 +18,6 @@ namespace margelo::nitro::omni {
prototype.registerHybridSetter("player", &HybridOmniViewSpec::setPlayer);
prototype.registerHybridGetter("autoplay", &HybridOmniViewSpec::getAutoplay);
prototype.registerHybridSetter("autoplay", &HybridOmniViewSpec::setAutoplay);
prototype.registerHybridGetter("showNotification", &HybridOmniViewSpec::getShowNotification);
prototype.registerHybridSetter("showNotification", &HybridOmniViewSpec::setShowNotification);
prototype.registerHybridGetter("autoPip", &HybridOmniViewSpec::getAutoPip);
prototype.registerHybridSetter("autoPip", &HybridOmniViewSpec::setAutoPip);
});
-2
View File
@@ -51,8 +51,6 @@ namespace margelo::nitro::omni {
virtual void setPlayer(const std::shared_ptr<HybridOmniPlayerSpec>& player) = 0;
virtual std::optional<bool> getAutoplay() = 0;
virtual void setAutoplay(std::optional<bool> autoplay) = 0;
virtual std::optional<bool> getShowNotification() = 0;
virtual void setShowNotification(std::optional<bool> showNotification) = 0;
virtual std::optional<bool> getAutoPip() = 0;
virtual void setAutoPip(std::optional<bool> autoPip) = 0;
@@ -46,16 +46,6 @@ namespace margelo::nitro::omni::views {
throw std::runtime_error(std::string("OmniView.autoplay: ") + exc.what());
}
}()),
showNotification([&]() -> CachedProp<std::optional<bool>> {
try {
const react::RawValue* rawValue = rawProps.at("showNotification", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.showNotification;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.showNotification);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("OmniView.showNotification: ") + exc.what());
}
}()),
autoPip([&]() -> CachedProp<std::optional<bool>> {
try {
const react::RawValue* rawValue = rawProps.at("autoPip", nullptr, nullptr);
@@ -81,7 +71,6 @@ namespace margelo::nitro::omni::views {
switch (hashString(propName)) {
case hashString("player"): return true;
case hashString("autoplay"): return true;
case hashString("showNotification"): return true;
case hashString("autoPip"): return true;
case hashString("hybridRef"): return true;
default: return false;
@@ -44,7 +44,6 @@ namespace margelo::nitro::omni::views {
public:
CachedProp<std::shared_ptr<HybridOmniPlayerSpec>> player;
CachedProp<std::optional<bool>> autoplay;
CachedProp<std::optional<bool>> showNotification;
CachedProp<std::optional<bool>> autoPip;
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniViewSpec>& /* ref */)>>> hybridRef;
-1
View File
@@ -6,7 +6,6 @@
"validAttributes": {
"player": true,
"autoplay": true,
"showNotification": true,
"autoPip": true,
"hybridRef": true
}