StreamHandler
@objc
public protocol StreamHandler
This protocol needs to be implemented for creating a handler for a specific AmpCore/StreamType
-
This function determines if the implementing class should be the handler of an URL
Declaration
Swift
func canHandleUrl(url: String) -> Bool
Parameters
url
The new URL that will be replacing the main content
Return Value
true
if the handler will be handling the URLfalse
otherwise -
This function will be called to start the handling of an URL
When implementing this function create a new AVPlayerItem and replace the current
AmpCore/AmpPlayer/player
‘s item.Declaration
Swift
@objc optional func handleUrl(url: String, player: AmpPlayer, success: @escaping (AVPlayerItem?) -> Void, failure: @escaping (PlayerError) -> Void)
Parameters
url
The URL that will replace the main content
player
The
AmpCore/AmpPlayer
that is going to replace its main contentsuccess
This closure will be called if the handling of the URL was successful
failure
This closure shoudl be called if the handling of the URL failed
-
This function will be called to start the handling of an AVURLAsset
When implementing this function create a new AVPlayerItem and replace the current
AmpCore/AmpPlayer/player
‘s item.Declaration
Swift
@objc optional func handleAVURLAsset(asset: AVURLAsset, player: AmpPlayer, success: @escaping (AVPlayerItem?) -> Void, failure: @escaping (PlayerError) -> Void)
Parameters
asset
The AVURLAsset that will replace the main content
player
The
AmpCore/AmpPlayer
that is going to replace its main contentsuccess
This closure will be called if the handling of the URL was successful
failure
This closure shoudl be called if the handling of the URL failed
-
This function describes the type of stream the handler is meant for
Declaration
Swift
func getStreamType() -> StreamType
Return Value
The
AmpCore/StreamType
that the handler is managing