4 MediaElementAdapter
Scott Miller редактировал(а) эту страницу 2016-03-17 10:09:03 -07:00

The MediaElementAdapter serves as an abstract layer between the MediaPlayer and the media that your app is playing. The MediaPlayer is used to display the media and provides a user interface for the user to interact with. The MediaElementAdapter is where you can insert any custom logic that is specific for your app. One example of this would be to have telemetry logic to record usage information from your customers.

###Properties liveTime
Type number
Gets or sets the live time.

isLive
Type boolean
Gets or sets whether the content is a live stream.

isPauseAllowed
Type boolean
Gets or sets a value that specifies whether the pause method can be executed.

If isPauseAllowed is set to false, the user will not be able to execute a pause command through the associated MediaPlayer Class. For example, the Pause control will be disabled and the voice command for pause will not work. When isPauseAllowed is set to false, the only way to execute pause is to have the app call it programmatically. When you set isPauseAllowed to true, the pause controls will be enabled for users.

isPlayAllowed
Type boolean Gets or sets a value that specifies whether the play method can be executed.

If isPlayAllowed is set to false, the user will not be able to execute a play command through the assicoated MediaPlayer Class. For example, the Play control will be disabled and the voice command for play will not work. When isPlayAllowed is set to false, the only way to execute play is to have the app call it programmatically. When you set isPlayAllowed to true, the play controls will be enabled for users.

isSeekAllowed
Type boolean
Gets or sets a value that specifies whether the seek method can be executed.

If isSeekAllowed is set to false, the following controls will be disabled on the associated MediaPlayer class. In addition, the user will not be able to execute any of the following commands through any mechanism such as speech. If isSeekAllowed is false, the only way to execute these commands is if the app executes them programmatically.

  • chapterSkipBackward
  • chapterSkipForward
  • timeSkipBackward
  • timeSkipForward

Setting isSeekAllowed to true will enable the buttons in the list above.

mediaElement
Type HTMLElement
Gets or sets a value the underlying media element. This is a video tag.

This property can be set using the constructor or after creation by changing the property.

###Methods baseMediaElementAdapterConstructor()
The base class constructor. If you are deriving from the MediaElementAdapter class, you must call this base class constructor.

dispose()
Disposes this class.

nextTrack()
Skips to the next track in a playlist. This function is empty by default and it is your responsibility to override this function and provide a custom implementation if you want to use it in your app.

pause()
Pauses the media.

This will pause the current media regardless of the current playback rate. That means that pause will pause media even when rewinding or fast forwarding. To resume playing media, call play.

Calling this method on media that is paused or not playing will have no effect.

play()
Sets the playbackRate to the default playbackRate for the media and plays the media.

previousTrack()
Skips to the previous track in a playlist. This function is empty by default and meant to be overridden with a custom implementation.

seek(time)
Navigates to the specified position in the media.
time (number) - the time to seek to in seconds.

The video tag throws an exception if newTime is before 0 or after the total duration of the video. The audio or video tag will also throw an exception if you try to execute seek before the media has been loaded into the player. Once the audio or video tag has been loaded, you can call seek to jump to a portion of the media that hasn't been buffered, but the player will stall until the buffering is completed. The canplay event indicates it is safe to call seek.

stop()
Navigates to the specified position in the media.