Gets the status of this MediaElement.
Syntax
Property value
Type: MediaElementState
The current state of this MediaElement. The state can be one of the following (as defined in the MediaElementState enumeration): Buffering, Closed, Opening, Paused, Playing, or Stopped. The default value is Closed.
Examples
The following example demonstrates one way to display the CurrentState of a MediaElement. It creates a MediaElement and several buttons for controlling media playback. To display the current state of the MediaElement, the example registers for the CurrentStateChanged event and uses an event handler to update a TextBlock.
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <MediaElement CurrentStateChanged="Media_State_Changed" x:Name="media" Source="xbox.wmv" Width="300" Height="300" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" /> <!-- Stops media playback.--> <Button Click="StopMedia" Grid.Column="0" Grid.Row="1" Content="Stop" /> <!-- Pauses media playback. --> <Button Click="PauseMedia" Grid.Column="1" Grid.Row="1" Content="Pause" /> <!-- Begins media playback. --> <Button Click="PlayMedia" Grid.Column="2" Grid.Row="1" Content="Play" /> <TextBlock Grid.Column="0" Grid.Row="2" Margin="10" FontSize="12">CurrentState:</TextBlock> <TextBlock x:Name="mediaStateTextBlock" Grid.Column="1" Grid.Row="2" Margin="0,10,0,0" FontSize="12"></TextBlock> </Grid>
private void StopMedia(object sender, RoutedEventArgs e) { media.Stop(); } private void PauseMedia(object sender, RoutedEventArgs e) { media.Pause(); } private void PlayMedia(object sender, RoutedEventArgs e) { media.Play(); } private void Media_State_Changed(object sender, RoutedEventArgs e) { mediaStateTextBlock.Text = media.CurrentState.ToString(); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 3/12/2013