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.
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 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 timeMetadata:[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()
Parameters
playerFrame
The bounds of the player view.
parentView
The view where the player view is going to be added.
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 -parameter notification: The NSNotification
Declaration
Swift
public func handleAVPlayerAccess(notification: NSNotification)
-
Function to set the player URL, you can use it to change the current video stream - paramater url: String with the URL
Declaration
Swift
public func handleUrl(url: String)
-
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 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 tracks
Declaration
Swift
public func getAvailableCloseCaptions() -> [String]
Return Value
List of Close 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.
-
Removes a registered observer.
Declaration
Swift
public func removeObserver(id: Int)
Parameters
id
The id of the observer to be removed.
-
Observe the different events on playing a stream.
Declaration
Swift
public override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>)
Parameters
keyPath
String with the key path.
object
Object of change.
change
The change.
context
Current context.