2020 API AWARDS WINNER - BEST IN MEDIA APIs LEARN MORE

VideoPresentationService

The VideoPresentationService allows the application to share the hosted video file with the participants, and synchronously control the playback for all participants. The video file location, specified by the URL parameter of the start method, needs to be accessible by all participants. The MPEG-4 Part 14 or MP4 file formats are recommended for the hosted video file.

The app uses the HTML video element to render the shared video and listen to various events to stay synchronized with the video presentation.

A typical workflow of the application:

For the presenter:

1. The application prepares the MP4 file and uploads to the network the location that is accessible by all conference participants through the URL.

2. The application calls the start method and supplies the URL as its parameter.

3. The application attaches the URL to the src attribute of the HTML video element.

4. The application allows the presenter to pause and resume the video. While sharing the video with other conference participants, the application coordinates the timestamp in the local and presented video. It uses the seek method to inform other participants about the current video position (timestamp).

5. The application calls the stop method to end the video presentation.

For participants:

1. The application reacts to started event and extracts the URL parameter from the VideoPresentation.

2. The application attaches the URL to the src attribute of the HTML video element.

3. The application is notified that the video is stopped or resumed through the paused and played events.

4. The application reacts to the sought event, exacts the timestamp, and applies it to the currenttime attribute of the video elements.

5. The application is notified about the end of the video presentation through the stopped event.

Events

started

started(videoPresentation: VTVideoPresentation)

Emitted when a video presentation is started.

Parameters:

NameType
videoPresentationVTVideoPresentation

stopped

stopped(videoPresentation: VTVideoPresentation)

Emitted when a video presentation is stopped.

Parameters:

NameType
videoPresentationVTVideoPresentation

played

played(videoPresentation: VTVideoPresentation)

Emitted when a video presentation is resumed.

Parameters:

NameType
videoPresentationVTVideoPresentation

paused

paused(videoPresentation: VTVideoPresentation)

Emitted when a video presentation is paused.

Parameters:

NameType
videoPresentationVTVideoPresentation

sought

sought(videoPresentation: VTVideoPresentation)

Emitted when a video presentation is sought.

Parameters:

NameType
videoPresentationVTVideoPresentation

Accessors

current

current: VTVideoPresentation?

Provides the current video presentation.

Returns: VTVideoPresentation?


state

state: VTVideoPresentationState

Provides the current state of the video presentation.

Returns: VTVideoPresentationState


delegate

delegate: VTVideoPresentationDelegate

Delegate, a means of communication between objects in the video presentation service.

Returns: VTVideoPresentationDelegate

Methods

start

start(url: URL, completion: ((_ error: NSError?) -> Void)?)

Starts a video presentation.

Parameters:

NameTypeDefaultDescription
urlURL-The URL of the video
completion((_ error: NSError?) -> Void)?nil-

stop

stop(completion: ((_ error: NSError?) -> Void)?)

Stops the current video presentation.

Parameters:

NameTypeDefault
completion((_ error: NSError?) -> Void)?nil

play

play(completion: ((_ error: NSError?) -> Void)?)

Plays the current video presentation.

Parameters:

NameTypeDefault
completion((_ error: NSError?) -> Void)?nil

pause

pause(timestamp: Int, completion: ((_ error: NSError?) -> Void)?)

Pauses the current video presentation.

Parameters:

NameTypeDefaultDescription
timestampInt-The timestamp of the video to seek to
completion((_ error: NSError?) -> Void)?nil-

seek

seek(timestamp: Int, completion: ((_ error: NSError?) -> Void)?)

Seeks the current video presentation.

Parameters:

NameTypeDefaultDescription
timestampInt-The timestamp of the video to seek to
completion((_ error: NSError?) -> Void)?nil-