///
/// HybridVideoPlayerSpec.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <NitroModules/JHybridObject.hpp>
#include <fbjni/fbjni.h>
#include "HybridVideoPlayerSpec.hpp"




namespace margelo::nitro::video {

  using namespace facebook;

  class JHybridVideoPlayerSpec: public jni::HybridClass<JHybridVideoPlayerSpec, JHybridObject>,
                                public virtual HybridVideoPlayerSpec {
  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/HybridVideoPlayerSpec;";
    static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
    static void registerNatives();

  protected:
    // C++ constructor (called from Java via `initHybrid()`)
    explicit JHybridVideoPlayerSpec(jni::alias_ref<jhybridobject> jThis) :
      HybridObject(HybridVideoPlayerSpec::TAG),
      HybridBase(jThis),
      _javaPart(jni::make_global(jThis)) {}

  public:
    ~JHybridVideoPlayerSpec() override {
      // Hermes GC can destroy JS objects on a non-JNI Thread.
      jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
    }

  public:
    size_t getExternalMemorySize() noexcept override;
    void dispose() noexcept override;

  public:
    inline const jni::global_ref<JHybridVideoPlayerSpec::javaobject>& getJavaPart() const noexcept {
      return _javaPart;
    }

  public:
    // Properties
    std::shared_ptr<HybridVideoPlayerSourceSpec> getSource() override;
    std::shared_ptr<HybridVideoPlayerEventEmitterSpec> getEventEmitter() override;
    VideoPlayerStatus getStatus() override;
    double getDuration() override;
    double getVolume() override;
    void setVolume(double volume) override;
    double getCurrentTime() override;
    void setCurrentTime(double currentTime) override;
    bool getMuted() override;
    void setMuted(bool muted) override;
    bool getLoop() override;
    void setLoop(bool loop) override;
    double getRate() override;
    void setRate(double rate) override;
    MixAudioMode getMixAudioMode() override;
    void setMixAudioMode(MixAudioMode mixAudioMode) override;
    IgnoreSilentSwitchMode getIgnoreSilentSwitchMode() override;
    void setIgnoreSilentSwitchMode(IgnoreSilentSwitchMode ignoreSilentSwitchMode) override;
    bool getPlayInBackground() override;
    void setPlayInBackground(bool playInBackground) override;
    bool getPlayWhenInactive() override;
    void setPlayWhenInactive(bool playWhenInactive) override;
    bool getIsPlaying() override;
    std::optional<TextTrack> getSelectedTrack() override;

  public:
    // Methods
    std::shared_ptr<Promise<void>> replaceSourceAsync(const std::optional<std::shared_ptr<HybridVideoPlayerSourceSpec>>& source) override;
    std::vector<TextTrack> getAvailableTextTracks() override;
    void selectTextTrack(const std::optional<TextTrack>& textTrack) override;
    std::shared_ptr<Promise<void>> initialize() override;
    std::shared_ptr<Promise<void>> preload() override;
    void play() override;
    void pause() override;
    void seekBy(double time) override;
    void seekTo(double time) override;

  private:
    friend HybridBase;
    using HybridBase::HybridBase;
    jni::global_ref<JHybridVideoPlayerSpec::javaobject> _javaPart;
  };

} // namespace margelo::nitro::video
