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

import NitroModules

/// See ``HybridPlaybackEngineSpec``
public protocol HybridPlaybackEngineSpec_protocol: HybridObject {
  // Properties
  var engineId: String { get }
  var state: PlaybackState { get }
  var mediaPosition: MediaPosition { get }
  var currentItem: (any HybridMediaItemSpec)? { get }
  var currentItemSource: ItemSource { get }
  var isLive: Bool { get }
  var isPlaying: Bool { get }
  var isPaused: Bool { get }
  var isLoaded: Bool { get }
  var availableSubtitleTracks: [SubtitleTrack] { get }
  var availableAudioTracks: [AudioTrack] { get }
  var volume: Double { get set }
  var rate: Double { get set }
  var muted: Bool { get set }
  var loop: Bool { get set }
  var queueItems: [(any HybridMediaItemSpec)] { get }
  var queueIndex: Double { get }
  var queueCount: Double { get }
  var repeatMode: RepeatMode { get set }
  var shuffleEnabled: Bool { get set }

  // Methods
  func load(item: (any HybridMediaItemSpec)) throws -> Promise<Void>
  func loadAndPlay(item: (any HybridMediaItemSpec)) throws -> Promise<Void>
  func play() throws -> Promise<Void>
  func pause() throws -> Promise<Void>
  func stop() throws -> Promise<Void>
  func seekTo(positionMs: Double) throws -> Promise<Void>
  func release() throws -> Void
  func activateDefaultDecoder() throws -> Void
  func setQueue(items: [(any HybridMediaItemSpec)]) throws -> Void
  func addToQueue(item: (any HybridMediaItemSpec)) throws -> Void
  func insertInQueue(item: (any HybridMediaItemSpec), afterIndex: Double) throws -> Void
  func removeFromQueue(index: Double) throws -> Void
  func moveInQueue(fromIndex: Double, toIndex: Double) throws -> Void
  func clearQueue() throws -> Void
  func skipToNext() throws -> Promise<Void>
  func skipToPrevious() throws -> Promise<Void>
  func skipToIndex(index: Double, autoPlay: Bool) throws -> Promise<Void>
  func setEnabledCommands(commands: [RemoteCommand]) throws -> Void
  func setCompactCommands(commands: [RemoteCommand]) throws -> Void
  func setSkipIntervalMs(intervalMs: Double) throws -> Void
  func updateNowPlaying(info: NowPlayingInfo) throws -> Void
  func overrideRemoteCommand(command: RemoteCommand) throws -> Void
  func clearRemoteCommandOverride(command: RemoteCommand) throws -> Void
  func setAudioSession(session: (any HybridAudioSessionSpec)) throws -> Void
  func clearCallbacks() throws -> Void
  func onStateChange(callback: @escaping (_ state: PlaybackState) -> Void) throws -> Void
  func onMediaPositionChange(callback: @escaping (_ position: MediaPosition) -> Void) throws -> Void
  func onCurrentItemChange(callback: @escaping (_ item: (any HybridMediaItemSpec)?, _ source: ItemSource) -> Void) throws -> Void
  func onRemoteCommand(callback: @escaping (_ event: RemoteCommandEvent) -> Void) throws -> Void
  func onError(callback: @escaping (_ message: String, _ code: String) -> Void) throws -> Void
  func onPlaybackEnded(callback: @escaping () -> Void) throws -> Void
  func onQueueEnd(callback: @escaping () -> Void) throws -> Void
  func onQueueChange(callback: @escaping () -> Void) throws -> Void
  func onPlaybackMetric(callback: @escaping (_ event: PlaybackMetricEvent) -> Void) throws -> Void
  func onTracksAvailable(callback: @escaping (_ tracks: AvailableTracks) -> Void) throws -> Void
  func onDomainEvent(callback: @escaping (_ event: DomainEvent) -> Void) throws -> Void
  func setInterruptionMode(mode: AviationInterruptionMode) throws -> Void
  func setBecomingNoisyBehavior(behavior: BecomingNoisyBehavior) throws -> Void
  func selectVideoTrack(selection: VideoTrackSelection) throws -> Void
  func selectSubtitleTrack(selection: SubtitleTrackSelection) throws -> Void
  func selectAudioTrack(selection: AudioTrackSelection) throws -> Void
  func clearCache() throws -> Promise<Void>
  func getCacheSize() throws -> Double
  func isCached(uri: String) throws -> Bool
  func setCacheEnabled(enabled: Bool) throws -> Void
  func preload(items: [(any HybridMediaItemSpec)]) throws -> Void
  func setPreloadConfig(config: PreloadConfig) throws -> Void
  func setBufferConfig(config: BufferConfig) throws -> Void
  func setCacheMaxSize(sizeBytes: Double) throws -> Void
  func setPreloadEnabled(enabled: Bool) throws -> Void
}

public extension HybridPlaybackEngineSpec_protocol {
  /// Default implementation of ``HybridObject.toString``
  func toString() -> String {
    return "[HybridObject PlaybackEngine]"
  }
}

/// See ``HybridPlaybackEngineSpec``
open class HybridPlaybackEngineSpec_base {
  private weak var cxxWrapper: HybridPlaybackEngineSpec_cxx? = nil
  public init() { }
  public func getCxxWrapper() -> HybridPlaybackEngineSpec_cxx {
  #if DEBUG
    guard self is any HybridPlaybackEngineSpec else {
      fatalError("`self` is not a `HybridPlaybackEngineSpec`! Did you accidentally inherit from `HybridPlaybackEngineSpec_base` instead of `HybridPlaybackEngineSpec`?")
    }
  #endif
    if let cxxWrapper = self.cxxWrapper {
      return cxxWrapper
    } else {
      let cxxWrapper = HybridPlaybackEngineSpec_cxx(self as! any HybridPlaybackEngineSpec)
      self.cxxWrapper = cxxWrapper
      return cxxWrapper
    }
  }
}

/**
 * A Swift base-protocol representing the PlaybackEngine HybridObject.
 * Implement this protocol to create Swift-based instances of PlaybackEngine.
 * ```swift
 * class HybridPlaybackEngine : HybridPlaybackEngineSpec {
 *   // ...
 * }
 * ```
 */
public typealias HybridPlaybackEngineSpec = HybridPlaybackEngineSpec_protocol & HybridPlaybackEngineSpec_base
