AmpPlayer

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

    public enum MediaCharacteristic: Int
  • The native player.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    open static let domain: String = "com.media.akamai"
  • 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

    open var mediaObject:Media?
  • Variable to control ad plugins callbacks

    Declaration

    Swift

    open var ampAdObservable: Observable<AmpAdObserver>?
  • Enables or disables autoplay

    Declaration

    Swift

    open var autoplay: Bool = false
  • url

    The current URL

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    open var timedMetadata:[AVMetadataItem]
  • The current buferring state

    Declaration

    Swift

    open var bufferingState: BufferingState
  • The class in charge of downloading the stream file

    Declaration

    Swift

    open var streamDownloader: StreamDownloader?
  • 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

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

    Declaration

    Swift

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

    Declaration

    Swift

    open func handleAVPlayerAccess(_ notification: Notification)

    Parameters

    notification

    The NSNotification.

  • Function to set the player URL, you can use it to change the current video stream.

    Declaration

    Swift

    open func handleUrl(_ url: String)

    Parameters

    url

    String with the URL.

  • Function to set the player config URL.

    Declaration

    Swift

    open func setConfigURL(_ url:String)

    Parameters

    url

    String with the URL it must be a json file.

  • 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 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)
  • Remove the player observers to avoid memory leaks and zombies.

    Declaration

    Swift

    open func removePlayerObservers()
  • 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

    open func playerInfoChanged(_ notification: Notification)

    Parameters

    notification

    The NSNotification

  • Function to manage when the player finished to play an asset

    Declaration

    Swift

    open func playerItemDidPlayToEndTime(_ notification: Notification)

    Parameters

    notification

    The NSNotification

  • Function to manage when the player finished to play an asset

    Declaration

    Swift

    open func playerItemFailedToPlayToEndTime(_ notification: Notification)

    Parameters

    notification

    The NSNotification

  • Function to manage when the position when is playing an asset

    Declaration

    Swift

    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()
  • Stops the stream and sets the playbackState to Stopped.

    Declaration

    Swift

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

    Declaration

    Swift

    open func seekTo(_ seconds: TimeInterval)

    Parameters

    seconds

    The position in seconds.

  • 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)

    Parameters

    speed

    The player speed 1x, 2x, 3x, etc.

  • 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)

    Parameters

    mediaCharacteristic

    String code for the Media Characteristic.

    type

    String MediaCharacteristic enum.

  • 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

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

    Parameters

    observer

    The observer to be registered.

    Return Value

    The id of the registered observer.

  • Registers an ad observer to be notified of ad events.

    Declaration

    Swift

    open func resgisterAdObserver(_ observer: AmpAdObserver) -> Int

    Parameters

    observer

    The observer to be registered.

    Return Value

    The id of the registered observer.

  • Removes a registered observer.

    Declaration

    Swift

    open func removeObserver(_ id: Int)

    Parameters

    id

    The id of the observer to be removed.

  • Activate Airplay Support.

    Declaration

    Swift

    open func allowAirplayPlayback(_ value:Bool)

    Parameters

    value

    true or false.

  • 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.

    Declaration

    Swift

    open func logsHasColors() -> Bool

    Return Value

    true or false.