Share via


Media Element State Transitions

There are eight possible states for a SmoothStreamingMediaElement object. During state transitions, the CurrentStateChanged event may not behave as expected.

Smooth Streaming Media Element State

A SmoothStreamingMediaElement object can be in any of the following states, which are defined in the SmoothStreamingMediaElementState enumeration:

To work with an SmoothStreamingMediaElement object's state and state transitions, you primarily use the following APIs:

The following events are available to help you work with SmoothStreamingMediaElement state:

  • The CurrentStateChanged event, which occurs on every state change.

  • The SeekCompleted event, which occurs when seek finishes. Only one seek operation at a time will work. Developers can use this event to determine when a previous seek operation is finished and to block seek operations while a previous seek is in progress. This event is also raised when an application calls SetPlaybackRate.

  • The ManifestReady event, which occurs during the opening state and signals that the manifest has been downloaded and some initial actions can be called, such as SetPlaybackRate.

  • The ManifestMerge event, which occurs during the opening state. For more information, see Manifest Merge

  • The SmoothStreamingErrorOccurred and MediaFailed events, which indicate issues that could set the state to closed.

State Transitions

Several state-affecting conditions might have effects that may not be obvious, including the following:

  • During fast forwarding, when live play is reached, the playback rate is set to 1.0. The SeekCompleted event is raised to indicate that the playback rate changed.

  • During rewind, if start is reached, the playback rate is set to 1.0. The SeekCompleted event is raised to indicate that the playback rate changed.

  • If the StartSeekToLive method is called, playback rate is set to 1.0 and then SeekCompleted event is raised to indicate that the playback rate changed.

  • When the end of stream is reached, the state is set to Paused.

The following table shows states (rows) and how actions affect those states (columns). For example, if the current state is Playing and the action is SetPlaybackRate, the resulting state is Playing.

State Transition Matrix

State/Action

Play

Pause

Set Playback Rate

Stop

Seek

Set Source

Select Tracks

Schedule Clip

Playing

Playing. The action is ignored.

Paused

Playing. The new playback rate applies, which will be a value from the SupportedPlaybackRates list.

Stopped

Playing. The current position is the new position. A SeekCompleted event occurs when seek is complete.

Closed for the clip that is currently playing. There can subsequently be a call for opening, buffering, or other actions, depending on whether the AutoPlay setting is true or false. The playback rate will to 1.0.

Playing. The track should be switched immediately.

Playing/ClipPlaying. The clip run as scheduled. If the scheduled time is now, the state changes to clip playing. The application can monitor clip states.

Paused

Buffering/Playing. This action does not change the playback rate. When enough data has been buffered, the clip changes to playing state.

Paused. The action is ignored.

Playing. The new playback rate applies, which will be a value from the SupportedPlaybackRates list.

Stopped.

Paused. The current position on the timeline becomes the new position.

Closed. This is for the clip that is currently playing. There can subsequently be a call for opening, buffering, or other actions, depending on whether the AutoPlay setting is true or false.

Paused.

Paused. The clip must take effect as scheduled. The clip changes to the playing state from the paused state only when the player is resumed.

Stopped

Buffering. Playback starts at zero.

Stopped. The clip is set to position zero.

Playing. The playback rate property is set to a new value from the SupportedPlaybackRates list.

Stopped. The request is ignored.

Paused. Goes to the new location indicated by the seek operation, then pauses.

Closed. This is for the clip that is currently playing. There can subsequently be a call for opening, buffering, or other actions, depending on whether the setting of the AutoPlay property is true or false.

Stopped.

Stopped. An InvalidOperationException error is thrown.

Buffering

Playing. The state is changed from buffering to playing. For more details, see the MediaElement State Transition Table.

Paused

Buffering. Call SetPlaybackRate immediately.

Stopped

Buffering. This action starts a seek operation.

Closed. This is for the clip that is currently playing. There can subsequently be a call for opening, buffering, or other actions, depending on whether the AutoPlay setting is true or false.

Buffering. Call SetPlaybackRate immediately.

Buffering. The clip must take effect as scheduled. The clip starts in playing state.

Opening

Opening. The request is ignored

Opening. The request is ignored

Opening. The request is ignored

Opening. The request is ignored

Opening. The request is ignored

Closed. This is for the clip that is currently playing. There can subsequently be a call for opening, buffering, or other actions, depending on whether the AutoPlay setting is true or false.

Opening. The request is ignored

Opening. An invalidOperationException error occurs.

ClipPlaying. (See note following table.)

ClipPlaying. If the clip was paused, it resumes.

ClipPlaying. If the clip was playing, it is paused.

ClipPlaying. An InvalidOperationException error is thrown.

Stopped. All actions are stopped.

ClipPlaying. An InvalidOperationException error is thrown.

Closed.

ClipPlaying. The track should be changed on the main video, but not on the clip.

ClipPlaying. The clip must play as scheduled. The clip starts in Playing state. The most recently started clip takes precedence, and any other clip is stopped and unscheduled.

Note

The ClipPlaying state is used only to determine when a clip is in the active window. There are other states associated with the clip. Applications can use ClipStateChanged and CurrentClipState to get these states.

Note

The player state does not change to Stopped when the manifest/license manager URL is invalid. Instead, the clip remains in Opening state.

See Also

Concepts

Manifest Merge

Other Resources

MediaElement States