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

#include "JHybridOmniPlayerSpec.hpp"

// Forward declaration of `HybridOmniEventMapSpec` to properly resolve imports.
namespace margelo::nitro::omni { class HybridOmniEventMapSpec; }
// Forward declaration of `Source` to properly resolve imports.
namespace margelo::nitro::omni { struct Source; }
// Forward declaration of `VideoSrc` to properly resolve imports.
namespace margelo::nitro::omni { struct VideoSrc; }
// Forward declaration of `Subtitle` to properly resolve imports.
namespace margelo::nitro::omni { struct Subtitle; }
// Forward declaration of `Metadata` to properly resolve imports.
namespace margelo::nitro::omni { struct Metadata; }
// Forward declaration of `MixAudioMode` to properly resolve imports.
namespace margelo::nitro::omni { enum class MixAudioMode; }
// Forward declaration of `PlayerStatus` to properly resolve imports.
namespace margelo::nitro::omni { enum class PlayerStatus; }
// Forward declaration of `CastStatus` to properly resolve imports.
namespace margelo::nitro::omni { enum class CastStatus; }
// Forward declaration of `Track` to properly resolve imports.
namespace margelo::nitro::omni { struct Track; }
// Forward declaration of `Rendition` to properly resolve imports.
namespace margelo::nitro::omni { struct Rendition; }

#include <memory>
#include "HybridOmniEventMapSpec.hpp"
#include "JHybridOmniEventMapSpec.hpp"
#include <optional>
#include "Source.hpp"
#include "JSource.hpp"
#include "VideoSrc.hpp"
#include "JVideoSrc.hpp"
#include <string>
#include <unordered_map>
#include "Subtitle.hpp"
#include <vector>
#include "JSubtitle.hpp"
#include "Metadata.hpp"
#include "JMetadata.hpp"
#include "MixAudioMode.hpp"
#include "JMixAudioMode.hpp"
#include "PlayerStatus.hpp"
#include "JPlayerStatus.hpp"
#include "CastStatus.hpp"
#include "JCastStatus.hpp"
#include "Track.hpp"
#include "JTrack.hpp"
#include "Rendition.hpp"
#include "JRendition.hpp"

namespace margelo::nitro::omni {

  std::shared_ptr<JHybridOmniPlayerSpec> JHybridOmniPlayerSpec::JavaPart::getJHybridOmniPlayerSpec() {
    auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
    auto castHybridObject = std::dynamic_pointer_cast<JHybridOmniPlayerSpec>(hybridObject);
    if (castHybridObject == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniPlayerSpec!");
    }
    return castHybridObject;
  }

  jni::local_ref<JHybridOmniPlayerSpec::CxxPart::jhybriddata> JHybridOmniPlayerSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  std::shared_ptr<JHybridObject> JHybridOmniPlayerSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
    auto castJavaPart = jni::dynamic_ref_cast<JHybridOmniPlayerSpec::JavaPart>(javaPart);
    if (castJavaPart == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniPlayerSpec::JavaPart!");
    }
    return std::make_shared<JHybridOmniPlayerSpec>(castJavaPart);
  }

  void JHybridOmniPlayerSpec::CxxPart::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridOmniPlayerSpec::CxxPart::initHybrid),
    });
  }

  // Properties
  std::shared_ptr<HybridOmniEventMapSpec> JHybridOmniPlayerSpec::getEventMap() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridOmniEventMapSpec::JavaPart>()>("getEventMap");
    auto __result = method(_javaPart);
    return __result->getJHybridOmniEventMapSpec();
  }
  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);
    return static_cast<bool>(__result);
  }
  bool JHybridOmniPlayerSpec::getHasNext() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getHasNext");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  std::optional<Source> JHybridOmniPlayerSpec::getSource() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSource>()>("getSource");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
  }
  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);
  }
  PlayerStatus JHybridOmniPlayerSpec::getStatus() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPlayerStatus>()>("getStatus");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  bool JHybridOmniPlayerSpec::getIsPlaying() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isPlaying");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  double JHybridOmniPlayerSpec::getCurrentTime() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getCurrentTime");
    auto __result = method(_javaPart);
    return __result;
  }
  void JHybridOmniPlayerSpec::setCurrentTime(double currentTime) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* currentTime */)>("setCurrentTime");
    method(_javaPart, currentTime);
  }
  double JHybridOmniPlayerSpec::getBuffered() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getBuffered");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridOmniPlayerSpec::getDuration() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getDuration");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridOmniPlayerSpec::getPlaybackRate() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getPlaybackRate");
    auto __result = method(_javaPart);
    return __result;
  }
  void JHybridOmniPlayerSpec::setPlaybackRate(double playbackRate) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* playbackRate */)>("setPlaybackRate");
    method(_javaPart, playbackRate);
  }
  double JHybridOmniPlayerSpec::getVolume() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getVolume");
    auto __result = method(_javaPart);
    return __result;
  }
  void JHybridOmniPlayerSpec::setVolume(double volume) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* volume */)>("setVolume");
    method(_javaPart, volume);
  }
  bool JHybridOmniPlayerSpec::getMuted() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getMuted");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridOmniPlayerSpec::setMuted(bool muted) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* muted */)>("setMuted");
    method(_javaPart, muted);
  }
  bool JHybridOmniPlayerSpec::getIsAutoQuality() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isAutoQuality");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  CastStatus JHybridOmniPlayerSpec::getCastStatus() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JCastStatus>()>("getCastStatus");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  std::vector<Track> JHybridOmniPlayerSpec::getVideos() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JTrack>>()>("getVideos");
    auto __result = method(_javaPart);
    return [&](auto&& __input) {
      size_t __size = __input->size();
      std::vector<Track> __vector;
      __vector.reserve(__size);
      for (size_t __i = 0; __i < __size; __i++) {
        auto __element = __input->getElement(__i);
        __vector.push_back(__element->toCpp());
      }
      return __vector;
    }(__result);
  }
  std::vector<Track> JHybridOmniPlayerSpec::getAudios() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JTrack>>()>("getAudios");
    auto __result = method(_javaPart);
    return [&](auto&& __input) {
      size_t __size = __input->size();
      std::vector<Track> __vector;
      __vector.reserve(__size);
      for (size_t __i = 0; __i < __size; __i++) {
        auto __element = __input->getElement(__i);
        __vector.push_back(__element->toCpp());
      }
      return __vector;
    }(__result);
  }
  std::vector<Track> JHybridOmniPlayerSpec::getSubtitles() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JTrack>>()>("getSubtitles");
    auto __result = method(_javaPart);
    return [&](auto&& __input) {
      size_t __size = __input->size();
      std::vector<Track> __vector;
      __vector.reserve(__size);
      for (size_t __i = 0; __i < __size; __i++) {
        auto __element = __input->getElement(__i);
        __vector.push_back(__element->toCpp());
      }
      return __vector;
    }(__result);
  }
  std::vector<Rendition> JHybridOmniPlayerSpec::getRenditions() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JRendition>>()>("getRenditions");
    auto __result = method(_javaPart);
    return [&](auto&& __input) {
      size_t __size = __input->size();
      std::vector<Rendition> __vector;
      __vector.reserve(__size);
      for (size_t __i = 0; __i < __size; __i++) {
        auto __element = __input->getElement(__i);
        __vector.push_back(__element->toCpp());
      }
      return __vector;
    }(__result);
  }

  // Methods
  void JHybridOmniPlayerSpec::abandon() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("abandon");
    method(_javaPart);
  }
  void JHybridOmniPlayerSpec::play() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("play");
    method(_javaPart);
  }
  void JHybridOmniPlayerSpec::pause() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("pause");
    method(_javaPart);
  }
  void JHybridOmniPlayerSpec::seekBy(double offset) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* offset */)>("seekBy");
    method(_javaPart, offset);
  }
  void JHybridOmniPlayerSpec::toggleCastStatus() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("toggleCastStatus");
    method(_javaPart);
  }
  void JHybridOmniPlayerSpec::playPrev() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("playPrev");
    method(_javaPart);
  }
  void JHybridOmniPlayerSpec::playNext() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("playNext");
    method(_javaPart);
  }
  void JHybridOmniPlayerSpec::selectVideo(const Track& video) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JTrack> /* video */)>("selectVideo");
    method(_javaPart, JTrack::fromCpp(video));
  }
  void JHybridOmniPlayerSpec::selectAudio(const Track& audio) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JTrack> /* audio */)>("selectAudio");
    method(_javaPart, JTrack::fromCpp(audio));
  }
  void JHybridOmniPlayerSpec::selectSubtitle(const std::optional<Track>& subtitle) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JTrack> /* subtitle */)>("selectSubtitle");
    method(_javaPart, subtitle.has_value() ? JTrack::fromCpp(subtitle.value()) : nullptr);
  }
  void JHybridOmniPlayerSpec::selectRendition(const std::optional<Rendition>& rendition) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JRendition> /* rendition */)>("selectRendition");
    method(_javaPart, rendition.has_value() ? JRendition::fromCpp(rendition.value()) : nullptr);
  }

} // namespace margelo::nitro::omni
