Files
AudioStreaming/AudioStreaming/Streaming/AudioPlayer/AudioPlayerDelegate.swift
2020-11-15 20:14:59 +00:00

35 lines
1.6 KiB
Swift

//
// Created by Dimitrios Chatzieleftheriou on 03/08/2020.
// Copyright © 2020 Decimal. All rights reserved.
//
import Foundation
public protocol AudioPlayerDelegate: AnyObject {
/// Tells the delegate that the player started player
func audioPlayerDidStartPlaying(player: AudioPlayer, with entryId: AudioEntryId)
/// Tells the delegate that the player finished buffering for an entry.
/// - note: May be called multiple times when seek is requested
func audioPlayerDidFinishBuffering(player: AudioPlayer, with entryId: AudioEntryId)
/// Tells the delegate that the state has changed passing both the new state and previous.
func audioPlayerStateChanged(player: AudioPlayer, with newState: AudioPlayerState, previous: AudioPlayerState)
/// Tells the delegate that an entry has finished
func audioPlayerDidFinishPlaying(player: AudioPlayer,
entryId: AudioEntryId,
stopReason: AudioPlayerStopReason,
progress: Double,
duration: Double)
/// Tells the delegate when an unexpected error occured.
/// - note: Probably a good time to recreate the player when this occurs
func audioPlayerUnexpectedError(player: AudioPlayer, error: AudioPlayerError)
/// Tells the delegate when cancel occurs, usually due to a stop or play (new source)
func audioPlayerDidCancel(player: AudioPlayer, queuedItems: [AudioEntryId])
/// Tells the delegate when a metadata read occurred from the stream.
func audioPlayerDidReadMetadata(player: AudioPlayer, metadata: [String: String])
}