Skip to main content
Skip table of contents

Event timeline

To test the features and view the example code, please see the Apple (FPS) SDK 5 Example Code Quick Start guide.

The Event Timeline provides feedback and analysis of performance tracking or playback issues.

Example code

This feature provides a basic implementation of displaying and filtering events captured by the SDK. The Event Timeline is disabled by default; to enable it:

CODE
OTVEventTimeline.shared.enableTimeline(true)

You can disable the timeline when it is no longer required by passing false to the above function.

Functions are available to access the events in the timeline, allowing specific subsets of events to be retrieved or all the events together.

CODE
let allEvents = OTVEventTimeline.shared.getTimelineList()
let last10Events = OTVEventTimeline.shared.getTimelineList(limit: 10)
let playbackEvents = OTVEventTimeline.shared.getTimelineList(type: OTVEvent.EventType.playback)
let dateRangeEvents = OTVEventTimeline.shared.getTimelineList(from: startDate, to: endDate)

To keep the list of events at a manageable size, you can remove events older than a specific Date. Passing the current date will clear all events:

CODE
OTVEventTimeline.shared.removeTimeline(olderThan: Date())

There is no limit to the number of events that the timeline will store. Running it for long periods without implementing a means to prune its contents periodically is not recommended.

OTVEvent

OTVEvent comprises a timestamp, type, command and extra. The type property is populated with one of the static properties of OTVEvent.EventType, and the command property is similarly populated with one of the static properties of OTVEvent.EventCommand. The extra property provides additional information that changes depending on the type and command. It is stored as a JSON String that is keyed with one or more of the static properties of OTVEvent.ExtraKey.

OTVEventTimelineAnalyzer

OTVEventTimelineAnalyzer can be used to provide a simple analysis of the events in the timeline, including the amount of time it took to start or zap between streams:

CODE
let startTime: Int? = OTVEventTimelineAnalyzer.getStartDuration().first
let zapTime: Int = OTVEventTimelineAnalyzer.getZpDuration(from: "http://stream1.m3u8",
                                                          to: "http://stream2.m3u8")

The analysis provided by OTVEventTimelineAnalyzer is undefined if you are playing back multiple streams at the same time.

Custom Events

You can add custom events to the timeline to track additional events from your own code.

CODE
OTVEventTimeline.shared.addToTimeline(type: "your-custom-type",
                                     command: "your-custom-command",
                                     extra: "optional-extra-info"
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.