APSMediaEvent

Objective-C

@interface APSMediaEvent : NSObject <APSMediaEventProtocol>

Swift

class APSMediaEvent : NSObject, APSMediaEventProtocol

The APSMediaEvent class describes a container that developers can use to instruct the player to run specific blocks of code at specific moments of time. Objects extending this class and implementing the corresponding APSMediaEventProtocol protocol can be added to the player’s main queue and can also be attached to a specific APSMediaUnit object, for runtime triggering.

Configuring the Event Interval

  • Sets the starting time point of the event.

    Declaration

    Objective-C

    - (void)setStartPoint:(NSString *_Nonnull)startPoint;

    Swift

    func setStartPoint(_ startPoint: String)

    Parameters

    startPoint

    A string format describing the time point when the player needs to trigger the event. Possible values are seconds (e.g.: @“60”) or a percentage relative to the total duration of the parent clip (e.g.: @“50%”).

  • Sets the ending time point of the event.

    Declaration

    Objective-C

    - (void)setEndPoint:(NSString *_Nonnull)endPoint;

    Swift

    func setEndPoint(_ endPoint: String)

    Parameters

    endPoint

    A string format describing the time point when the player needs to unload the event. Possible values are seconds (e.g.: @“60”) or a percentage relative to the total duration of the parent clip (e.g.: @“50%”).

  • The time interval (in seconds) when the player needs to trigger the event.

    Warning

    If percentual values were set via setStartPoint, this value will change immediately after the current clip’s duration is available.

    Declaration

    Objective-C

    - (NSTimeInterval)startPoint;

    Swift

    func startPoint() -> TimeInterval

    Return Value

    The initial time interval.

  • The playback time (in seconds) when the player needs to unload the event. Defaults to -1 for events that should unload right after triggering.

    Warning

    If percentual values were set via setStartPoint, this value will change immediately after the current clip’s duration is available.

    Declaration

    Objective-C

    - (NSTimeInterval)endPoint;

    Swift

    func endPoint() -> TimeInterval

    Return Value

    The final time interval.

  • If this parameter is greater than 0, then the event will be retriggered by the media player after the specific time interval (in seconds).

    Declaration

    Objective-C

    @property (nonatomic) NSTimeInterval repeatAfter;

    Swift

    var repeatAfter: TimeInterval { get set }
  • Shifts air-time for an event by a defined amount of time.

    Declaration

    Objective-C

    - (void)incrementStartAndEndPointsWithInterval:(NSTimeInterval)duration;

    Swift

    func incrementStartAndEndPoints(withInterval duration: TimeInterval)

    Parameters

    duration

    Shift duration in seconds.

  • Translates percentual values set via setStartPoint and setEndPoint to actual time intervals in seconds, relative to a specified total duration.

    Declaration

    Objective-C

    - (void)adjustRelativeToDuration:(NSTimeInterval)duration;

    Swift

    func adjustRelative(toDuration duration: TimeInterval)

    Parameters

    duration

    The total duration.

Asynchroneous Pre-Trigger

  • Call this to trigger the event.

    Declaration

    Objective-C

    - (void)trigger;

    Swift

    func trigger()
  • Call this to preload the event.

    Declaration

    Objective-C

    - (void)preload;

    Swift

    func preload()

Asynchroneous Event Preloading

  • Defines the number of seconds before the scheduled start point when the event should receive the [APSMediaEventProtocol preload] message (if the method is implemented).

    Declaration

    Objective-C

    @property (nonatomic) NSTimeInterval preloadInterval;

    Swift

    var preloadInterval: TimeInterval { get set }
  • Defines the maximum number of seconds the event is allowed to live once it has been pretriggered, without setting the loaded property to YES.

    Declaration

    Objective-C

    @property (nonatomic) NSTimeInterval timeout;

    Swift

    var timeout: TimeInterval { get set }
  • The current lifecycle state of the event.

    Declaration

    Objective-C

    @property APSMediaEventState state;

    Swift

    var state: APSMediaEventState { get set }
  • Set by the player to the current playback time in seconds, after the current event begins preloading. Defaults to -1 if the event did not start preloading.

    Declaration

    Objective-C

    @property NSTimeInterval preloadPoint;

    Swift

    var preloadPoint: TimeInterval { get set }
  • Set this to YES if the event has no specific start time, and the player should handle insertion.

    Declaration

    Objective-C

    @property BOOL dynamicPosition;

    Swift

    var dynamicPosition: Bool { get set }