PlayerServiceProtocol

public protocol PlayerServiceProtocol

Represents the requirements of a PlayerService

  • The player managed by the service

    Declaration

    Swift

    var player: RemoteMediaPlayer? { get set }
  • Observable stream of player data emitted during playback

    Declaration

    Swift

    var playerData: Observable<PlayerData?> { get }
  • Initializes the service

    Declaration

    Swift

    init(dependencies: PlayerServiceDependenciesProtocol, withPlayer player: RemoteMediaPlayer?)

    Parameters

    dependencies

    player service dependencies

    player

    player which should be managed and controlled

  • Connects to the given player to receive player status feedback

    Declaration

    Swift

    func connectToPlayer(_ newPlayer: RemoteMediaPlayer) -> Completable

    Parameters

    newPlayer

    player to connect to

    Return Value

    an observable to get notified about a successful connection or an error

  • Tries to play the player handled by the service

    Declaration

    Swift

    func play() -> Completable

    Return Value

    an observable to get notified about a successful action or an error

  • Plays the given url with the passed metadata on the player handled by the service

    Declaration

    Swift

    func play(withMetadata metadata: Metadata, url: String) -> Completable

    Parameters

    metadata

    metadata describing the media at the given url

    url

    the url of the media which should be played

    Return Value

    an observable to get notified about a successful action or an error

  • Pauses the current playback of the player handled by the service

    Declaration

    Swift

    func pause() -> Completable

    Return Value

    an observable to get notified about a successful action or an error

  • Modifies the playback position of the player handled by the service

    Declaration

    Swift

    func setPosition(position: Int64, type: SeekType) -> Completable

    Parameters

    position

    position to seek to

    type

    seek type, to be able to set an absolute position or a relative position

    Return Value

    an observable to get notified about a successful action or an error

  • Stops the playback of the player handled by the service

    Declaration

    Swift

    func stop() -> Completable

    Return Value

    an observable to get notified about a successful action or an error

  • Gets the MediaPlayerInfo of the player handled by the service (url and metadata of the currently played media)

    Declaration

    Swift

    func getPlayerInfo() -> Single<MediaPlayerInfo>

    Return Value

    an observable to get the MediaPlayerInfo on success or an error

  • Gets the data of the player handled by service (current status and position of the player)

    Declaration

    Swift

    func getPlayerData() -> Single<PlayerData>

    Return Value

    an observable to get the PlayerData on success or an error

  • Fetches the duration of the currently played media

    Declaration

    Swift

    func getDuration() -> Single<Int64>

    Return Value

    an observable to get the duration on success or an error

  • Fetches the current playback position of the player handled by the service

    Declaration

    Swift

    func getPosition() -> Single<Int64>

    Return Value

    an observable to get the position on success or an error

  • Disconnects from the player handled by the service

    Throws

    an error if service has no player

    Declaration

    Swift

    func disconnectFromCurrentPlayer() throws -> Completable

    Return Value

    an observable to get notified about a successful disconnection or an error

  • Disconnects from the given player

    Declaration

    Swift

    func disconnect(fromPlayer player: RemoteMediaPlayer) -> Completable

    Parameters

    player

    player to disconnect from

    Return Value

    an observable to get notified about a successful disconnection or an error