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
+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
}