AmpPlayer

public 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

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

    Declaration

    Swift

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

    Declaration

    Swift

    public let version: String = NSBundle(forClass: AmpPlayer.self).infoDictionary!["CFBundleShortVersionString"] as! String
  • The project’s domain

    Declaration

    Swift

    public static let domain: String = "com.media.akamai"
  • The container in charge of storing, deleting and iterating on the registered observers.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public var autoplay: Bool = false
  • url

    The current URL

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public 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

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

    Declaration

    Swift

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

    Declaration

    Swift

    public func handleAVPlayerAccess(notification: NSNotification)

    Parameters

    notification

    The NSNotification.

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

    Declaration

    Swift

    public func handleUrl(url: String)

    Parameters

    url

    String with the URL.

  • Function to set the player config URL.

    Declaration

    Swift

    public 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

    public 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

    public 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

    public func setFeedURL(url:String)
  • Function to set the Image Poster - paramater image: UIImage with Image poster

    Declaration

    Swift

    public func setPosterImage(image:UIImage, parentView:UIView? = nil)
  • Function to set the Image Poster - paramater image: String with Image poster url

    Declaration

    Swift

    public func setPosterImage(image:String, parentView:UIView? = nil)
  • Remove the player observers to avoid memory leaks and zombies.

    Declaration

    Swift

    public func removePlayerObservers()
  • Return whether the stream is a live stream or not.

    Declaration

    Swift

    public 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 - parameter notification: The NSNotification

    Declaration

    Swift

    public func playerInfoChanged(notification: NSNotification)

    Parameters

    notification

    The NSNotification

  • Function to manage when the player finished to play an asset - parameter notification: The NSNotification

    Declaration

    Swift

    public func playerItemDidPlayToEndTime(notification: NSNotification)

    Parameters

    notification

    The NSNotification

  • Function to manage when the player finished to play an asset - parameter notification: The NSNotification

    Declaration

    Swift

    public func playerItemFailedToPlayToEndTime(notification: NSNotification)

    Parameters

    notification

    The NSNotification

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

    Declaration

    Swift

    public func updatePosition()
  • Plays the stream and sets the playbackState to Playing.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public func pause()
  • Stops the stream and sets the playbackState to Stopped.

    Declaration

    Swift

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

    Declaration

    Swift

    public func seekTo(seconds: NSTimeInterval)

    Parameters

    seconds

    The position in seconds.

  • Returns the duration of the current stream.

    Declaration

    Swift

    public func duration() -> Double

    Return Value

    The duration of the current stream.

  • Returns the current time of the stream.

    Declaration

    Swift

    public func currentTime() -> Double

    Return Value

    The current time of the stream.

  • Sets player speed

    Declaration

    Swift

    public func setPlayerSpeed(speed:Float)

    Parameters

    speed

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

  • List the available audio tracks

    Declaration

    Swift

    public func getAvailableAudioTracks() -> [String]

    Return Value

    List of Audio Selections Options.

  • Set the media option

    Declaration

    Swift

    public 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

    public func getAvailableCloseCaptions() -> [String]

    Return Value

    List of Closed Captions Selections Options.

  • Registers an observer to be notified of player events.

    Declaration

    Swift

    public 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

    public 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

    public func removeObserver(id: Int)

    Parameters

    id

    The id of the observer to be removed.

  • Activate Airplay Support.

    Declaration

    Swift

    public func allowAirplayPlayback(value:Bool)

    Parameters

    value

    true or false.

  • Verify if Airplay support is enabled.

    Declaration

    Swift

    public func AirPlayPlaybackEnabled() -> Bool

    Return Value

    true or false.

  • Enable logs in the player for debugging.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public func logsEnabled() -> Bool

    Return Value

    true or false.

  • Returns true if the log has colors.

    Declaration

    Swift

    public func logsHasColors() -> Bool

    Return Value

    true or false.