APSMediaPlayerProtocol

Objective-C

@protocol APSMediaPlayerProtocol <NSObject>

Swift

protocol APSMediaPlayerProtocol : NSObjectProtocol

This protocol allows 3rd party implementations of the media rendering engine that stands behind Veeplay. This protocol extends the KRAdapter protocol, so objects should also implement a type method, returning a unique string to register under.

To use:

  • Create a new class that implements this protocol
  • Register it with the player shared instance:

      [[APSMediaPlayer sharedInstance] registerClass:[<YOURCLASS> class] inGroup:kAPSMediaPlayerBackendsGroup];
    
  • Set up the class with the player:

      [[APSMediaPlayer sharedInstance] setBackendPlayerClass:[<YOURCLASS> class]];
    

Accessing the APSAVPlayer’s view

  • The container UIView of the player.

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) UIView *_Nullable view;

    Swift

    var view: UIView? { get }

Properties

  • Returns a Boolean value specifing if the player is ready to play media

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) BOOL isPreparedToPlay;

    Swift

    var isPreparedToPlay: Bool { get }
  • Get or set the initial time in stream from which the player will start playing the media

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite)
        NSTimeInterval initialPlaybackTime;

    Swift

    var initialPlaybackTime: TimeInterval { get set }
  • Get or set the current position in stream

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite)
        NSTimeInterval currentPlaybackTime;

    Swift

    var currentPlaybackTime: TimeInterval { get set }
  • Get the duration of the buffered content

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) NSTimeInterval playableDuration;

    Swift

    var playableDuration: TimeInterval { get }
  • Get the total duration of the video

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) NSTimeInterval duration;

    Swift

    var duration: TimeInterval { get }
  • Get or set the current playback rate

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite)
        float currentPlaybackRate;

    Swift

    var currentPlaybackRate: Float { get set }
  • Get or set the current media’s URL

    Declaration

    Objective-C

    @required
    @property (nonatomic, strong, readwrite) NSURL *_Nullable contentURL;

    Swift

    var contentURL: URL? { get set }
  • Get or set the scaling mode of the video according to its viewport

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite)
        APSMovieScalingMode scalingMode;

    Swift

    var scalingMode: APSMovieScalingMode { get set }
  • Get or set if the player should autoplay an URL as soon as it is provided

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite) BOOL shouldAutoplay;

    Swift

    var shouldAutoplay: Bool { get set }
  • Get the current playback state

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) APSMoviePlaybackState playbackState;

    Swift

    var playbackState: APSMoviePlaybackState { get }
  • Get the current state of the buffer

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) APSMovieLoadState loadState;

    Swift

    var loadState: APSMovieLoadState { get }
  • Get the current media’s source type (e.g. file or stream)

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite)
        APSMovieSourceType movieSourceType;

    Swift

    var movieSourceType: APSMovieSourceType { get set }
  • Set or get how the player controls will appear

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite)
        APSMovieControlStyle controlStyle;

    Swift

    var controlStyle: APSMovieControlStyle { get set }
  • Obtains the most recent time-based metadata provided by the streamed movie.

    Returns an array of the most recent MPTimedMetadata objects provided by the media stream.

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) NSArray *_Nullable timedMetadata;

    Swift

    var timedMetadata: [Any]? { get }
  • Specifies whether the movie player allows AirPlay movie playback.

    Declaration

    Objective-C

    @required
    @property (nonatomic, assign, unsafe_unretained, readwrite) BOOL allowsAirPlay;

    Swift

    var allowsAirPlay: Bool { get set }
  • Check out if AirPlay video is started or stopped.

    Declaration

    Objective-C

    @required
    @property (nonatomic, readonly) BOOL airPlayVideoActive;

    Swift

    var airPlayVideoActive: Bool { get }

Required protocol methods

  • Prepare to play media. This is also automatically called on play

    Declaration

    Objective-C

    - (void)prepareToPlay;

    Swift

    func prepareToPlay()
  • Play the current media in the queue

    Declaration

    Objective-C

    - (void)play;

    Swift

    func play()
  • Pause the current playing media

    Declaration

    Objective-C

    - (void)pause;

    Swift

    func pause()
  • Stop the player, remove all the items from the queue and remove the player’s CALayer from its superlayer

    Declaration

    Objective-C

    - (void)stop;

    Swift

    func stop()
  • Play the media with an increased playback rate (speed)

    Declaration

    Objective-C

    - (void)beginSeekingForward;

    Swift

    func beginSeekingForward()
  • Rewind the media

    Declaration

    Objective-C

    - (void)beginSeekingBackward;

    Swift

    func beginSeekingBackward()
  • Stop the seeking process startd by beginSeekingForward or beginSeekingBackward;

    Declaration

    Objective-C

    - (void)endSeeking;

    Swift

    func endSeeking()
  • Get the stream’s source type. Different by movieSourceType because it returns if the stream is a VOD stream or a live stream.

    Declaration

    Objective-C

    - (APSMovieStreamSourceType)streamSourceType;

    Swift

    func streamSourceType() -> APSMovieStreamSourceType

    Return Value

    The stream’s type as a APSMovieStreamSourceType enum

  • Request a thumbnail image

    Warning

    This method should execute blocking operations on a background thread, and should invoke the callback block on the main thread.

    Declaration

    Objective-C

    - (void)thumbnailAt:(NSTimeInterval)playbackTime
        withCompletionBlock:(APSThumbnailGeneratedBlock _Nonnull)block;

    Swift

    func thumbnail(at playbackTime: TimeInterval, withCompletionBlock block: @escaping APSThumbnailGeneratedBlock)

    Parameters

    playbackTime

    The time when the thumbnail should be taken from the video.

    block

    The block to be invoked on thumbnail generation completion.

  • Set the sound volume of the player, in the range of 0.0 to 1.0.

    Declaration

    Objective-C

    - (void)setVolume:(CGFloat)volume;

    Swift

    func setVolume(_ volume: CGFloat)

    Parameters

    volume

    CGFloat sound volume.

  • Get the sound volume of the player, in the range of 0.0 to 1.0.

    Declaration

    Objective-C

    - (CGFloat)getVolume;

    Swift

    func getVolume() -> CGFloat

    Return Value

    The sound volume of the player

  • Mute the player

    Declaration

    Objective-C

    - (void)setMute:(BOOL)mute;

    Swift

    func setMute(_ mute: Bool)

    Parameters

    mute

    BOOL set YES to mute or NO to unmute.

  • Get if the player is muted or no

    Declaration

    Objective-C

    - (BOOL)getMute;

    Swift

    func getMute() -> Bool

    Return Value

    The mute status

Optional protocol methods

  • Add an URL to the current play queue

    Declaration

    Objective-C

    - (void)appendURL:(NSURL *_Nonnull)url;

    Swift

    optional func append(_ url: URL)

    Parameters

    url

    A NSURL instance pointing to the media location

  • Insert an URL to the current play queue at the given position

    Declaration

    Objective-C

    - (void)insertURL:(NSURL *_Nonnull)url atIndex:(NSInteger)index;

    Swift

    optional func insert(_ url: URL, at index: Int)

    Parameters

    url

    A NSURL instance pointing to the media location

  • The priority based on which the backend will be selected

    Declaration

    Objective-C

    + (NSInteger)backendPriority;

    Swift

    optional static func backendPriority() -> Int
  • This is invoked by the player before setting a new URL for playback

    Declaration

    Objective-C

    - (void)willSetURL:(NSURL *_Nonnull)url;

    Swift

    optional func willSetURL(_ url: URL)

    Parameters

    url

    A NSURL instance pointing to the media location

  • This is invoked by the player after setting a new URL for playback

    Declaration

    Objective-C

    - (void)didSetURL:(NSURL *_Nonnull)url;

    Swift

    optional func didSetURL(_ url: URL)

    Parameters

    url

    A NSURL instance pointing to the media location

  • This is invoked by the player after playback is complete

    Declaration

    Objective-C

    - (void)clear;

    Swift

    optional func clear()
  • Start Picture in Picture, if possible

    Declaration

    Objective-C

    - (void)startPictureInPicture;

    Swift

    optional func startPictureInPicture()
  • Stop Picture in Picture

    Declaration

    Objective-C

    - (void)stopPictureInPicture;

    Swift

    optional func stopPictureInPicture()
  • Get Picture in Picture status

    Declaration

    Objective-C

    - (BOOL)isPictureInPictureActive;

    Swift

    optional func isPictureInPictureActive() -> Bool
  • Get a list of available subtitles

    Declaration

    Objective-C

    - (NSDictionary<NSString *, NSString *> *_Nonnull)availableSubtitles;

    Swift

    optional func availableSubtitles() -> [String : String]

    Return Value

    A NSDictionary containing the subtitles in format {“language_code”: “Language name”}

  • Enable the corresponding subtitle for the given language

    Declaration

    Objective-C

    - (void)enableSubtitle:(NSString *_Nonnull)language;

    Swift

    optional func enableSubtitle(_ language: String)

    Parameters

    language

    NSString the language code to enable

  • Get a list of available audio tracks

    Declaration

    Objective-C

    - (NSDictionary *_Nonnull)availableAudioTracks;

    Swift

    optional func availableAudioTracks() -> [AnyHashable : Any]

    Return Value

    A NSDictionary of available audio tracks in format {“track_id”: “Track name”}

  • Select a track id

    Declaration

    Objective-C

    - (void)enableAudioTrack:(NSString *_Nonnull)trackId;

    Swift

    optional func enableAudioTrack(_ trackId: String)

    Parameters

    trackId

    NSString the ID of the audio track to enable