AmpPlayer

@objc open class AmpPlayer: NSObject

Class in charge of augmenting the AVPlayer related functionality.

  • The type of Media Characteristic defined in a enum

    • CloseCaptions: The Characteristic for Close Captions.
    • Audio: The Characteristic for Audio Tracks.
    See more

    Declaration

    Swift

    @objc public enum MediaCharacteristic: Int
  • The native player.

    Declaration

    Swift

    @objc open var player: AVPlayer?
  • The stream’s information

    Declaration

    Swift

    @objc open var streamInfo: StreamInfo?
  • The player’s version

    Declaration

    Swift

    @objc open let version: String = Bundle(for: AmpPlayer.self).infoDictionary!["CFBundleShortVersionString"] as! String
  • The project’s domain

    Declaration

    Swift

    @objc open static let domain: String = "com.media.akamai"
  • The native player item.

    Declaration

    Swift

    @objc open var playerItem: AVPlayerItem?
  • Enable or disable the playback on the background, on your App you must enable Background modes with Audio, Airplay and Picture in Picture

    Declaration

    Swift

    open var allowBackgroundPlayback:Bool = false
  • Set the playback mode when the player enters to the background

    Declaration

    Swift

    open var playbackStateOnAppDidBecomeActive:PlaybackState = .playing
  • The container in charge of storing, deleting and iterating on the registered observers.

    Declaration

    Swift

    open var observable: Observable<PlayerEventObserver>?
  • Variable used to manage the json or xml config

    Declaration

    Swift

    open var ampConfig:AmpConfig?
  • Variable used to manage the media loaded from json

    Declaration

    Swift

    @objc open var mediaObject:Media?
  • Enables or disables autoplay

    Declaration

    Swift

    @objc open var autoplay: Bool = false
  • url

    The current URL

    Declaration

    Swift

    @objc open var url: String!
  • The type of the stream loaded

    Declaration

    Swift

    @objc open var streamType: StreamType
  • The current state of the video playback

    Declaration

    Swift

    @objc open var playbackState: PlaybackState
  • The current metadata on current time (ID3Tags)

    Declaration

    Swift

    @objc open var timedMetadata:[AVMetadataItem]
  • Initializes a new AmpPlayer with the parameters provided.

    Declaration

    Swift

    public override init()

    Return Value

    A configured instance of an AmpPlayer.

  • Notification on player will resign active

    Declaration

    Swift

    @objc open func handleWillResignActive()
  • Notification on player did become active

    Declaration

    Swift

    @objc open func handleDidBecomeActive()
  • Notification on player handle AVPlayer Access.

    Declaration

    Swift

    @objc open func handleAVPlayerAccess(_ notification: Notification)
  • Function to set the player URL, you can use it to change the current video stream.

    Declaration

    Swift

    @objc @discardableResult open func handleUrl(_ url: String) -> Bool
  • Function to set the player URL Using Fairplay DRM, you can use it to change the current video stream.

    Declaration

    Swift

    @objc open func handleUrl(_ url:String, certificateUrl:String, serverURL:String)
  • Function to set the player config URL.

    Declaration

    Swift

    open func setConfigURL(_ url:String)
  • Function to set the media object to the sdk

    • paramater object: Media Object

    Declaration

    Swift

    open func setMedia(_ object:MediaObject)
  • Function start the Event Manager

    • paramater url: URL to the text file
    • paramater states: Array of States to verify
    • paramater states: Seconds to try again

    Declaration

    Swift

    open func setEventManager(_ url:String, states:[State], verificationTimeSeconds:Int)
  • Function to set the quality level if the current stream

    • paramater level: a QualityLevel

    Declaration

    Swift

    open func setMaxQualityLevel(level:QualityLevel)
  • Function to set the media url to the sdk

    • paramater url: String with the URL

    Declaration

    Swift

    open func setFeedURL(_ url:String)
  • Function to set the Image Poster

    • paramater image: UIImage with Image poster

    Declaration

    Swift

    open func setPosterImage(_ image:UIImage, parentView:UIView? = nil)
  • Function to set the Image Poster

    • paramater image: String with Image poster url

    Declaration

    Swift

    open func setPosterImage(_ image:String, parentView:UIView? = nil)
  • Function to show the poster image

    Declaration

    Swift

    open func showPosterImage()
  • Function to hide the poster image

    Declaration

    Swift

    open func hidePosterImage()
  • Remove the player observers to avoid memory leaks and zombies.

    Declaration

    Swift

    open func removePlayerItemObservers()
  • Return whether the stream is a live stream or not.

    Declaration

    Swift

    open func isLive() -> Bool

    Return Value

    Whether the stream is a live stream or not.

  • Function to manage the information’s change on the play back

    Declaration

    Swift

    @objc open func playerInfoChanged(_ notification: Notification)
  • Function to manage when the player finished to play an asset

    Declaration

    Swift

    @objc open func playerItemDidPlayToEndTime(_ notification: Notification)
  • Function to manage when the player stalled while playing an asset

    Declaration

    Swift

    @objc open func playerDidStall(_ notification: Notification)
  • Function to manage when the player finished to play an asset

    Declaration

    Swift

    @objc open func playerItemFailedToPlayToEndTime(_ notification: Notification)
  • Function to manage when the position when is playing an asset

    Declaration

    Swift

    @objc open func updatePosition()
  • Plays the stream and sets the playbackState to Playing.

    Declaration

    Swift

    open func play()
  • If the playback ended, plays the same stream from the beginning.

    Declaration

    Swift

    open func replay()
  • Pauses the stream and sets the playbackState to Paused.

    Declaration

    Swift

    open func pause()
  • Destroy the player instance and do player cleanup.

    Declaration

    Swift

    open func stop()
  • Forwards (or rewinds if negative) the stream by the given amount of seconds.

    Declaration

    Swift

    open func jumpToTime(seconds: TimeInterval)
  • Seeks the stream to live.

    Declaration

    Swift

    open func goLive()
  • Seeks the stream to the given position in seconds.

    Declaration

    Swift

    open func seekTo(_ seconds: TimeInterval)
  • Returns the duration of the current stream.

    Declaration

    Swift

    open func duration() -> Double

    Return Value

    The duration of the current stream.

  • Returns the current time of the stream.

    Declaration

    Swift

    open func currentTime() -> Double

    Return Value

    The current time of the stream.

  • Sets player speed

    Declaration

    Swift

    open func setPlayerSpeed(_ speed:Float)
  • Enable or disable the play button overlay

    Declaration

    Swift

    open func overlayButton(enabled:Bool)
  • Enable or disable the buffer loading indicator

    Declaration

    Swift

    open func loadingSpinner(enabled:Bool)
  • List the available audio tracks

    Declaration

    Swift

    open func getAvailableAudioTracks() -> [String]

    Return Value

    List of Audio Selections Options.

  • Set the media option

    Declaration

    Swift

    open func setMediaCharacteristic(_ mediaCharacteristic:String, type:MediaCharacteristic)
  • List the available closed captions

    Declaration

    Swift

    open func getAvailableCloseCaptions() -> [String]

    Return Value

    List of Closed Captions Selections Options.

  • Function to set the WebVTT Close Caption File

    • paramater url: String URL to WebVTT Caption File
    • paramater forLanguage: String language name for caption

    Declaration

    Swift

    open func setCloseCaption(url:String, forLanguage:String)
  • Registers an observer to be notified of player events.

    Declaration

    Swift

    @objc open func registerObserver(_ observer: PlayerEventObserver) -> Int

    Return Value

    The id of the registered observer.

  • Removes a registered observer.

    Declaration

    Swift

    @objc open func removeObserver(_ id: Int)
  • Activate Airplay Support.

    Declaration

    Swift

    open func allowAirplayPlayback(_ value:Bool)
  • Verify if Airplay support is enabled.

    Declaration

    Swift

    open func AirPlayPlaybackEnabled() -> Bool

    Return Value

    true or false.

  • Enable logs in the player for debugging.

    Declaration

    Swift

    open func enableLogs()
  • Disable logs in the player for debugging.

    Declaration

    Swift

    open func disableLogs()
  • Returns true if the logs are enabled.

    Declaration

    Swift

    open func logsEnabled() -> Bool

    Return Value

    true or false.

  • Returns true if the log has colors. cancelPlayback

    Declaration

    Swift

    open func logsHasColors() -> Bool

    Return Value

    true or false.