Simple Media Player : MediaElement « Windows Presentation Foundation « C# / C Sharp






Simple Media Player

Simple Media Player
   

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid.Triggers>
    <EventTrigger RoutedEvent="Button.Click" SourceName="playButton">
      <EventTrigger.Actions>
        <BeginStoryboard Name="beginStoryboard">
          <Storyboard>
            <MediaTimeline Source="C:\video.wmv"
            Storyboard.TargetName="video"/>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger.Actions>
    </EventTrigger>
    <EventTrigger RoutedEvent="Button.Click" SourceName="pauseButton">
      <EventTrigger.Actions>
        <PauseStoryboard BeginStoryboardName="beginStoryboard"/>
      </EventTrigger.Actions>
    </EventTrigger>
    <EventTrigger RoutedEvent="Button.Click" SourceName="resumeButton">
      <EventTrigger.Actions>
        <ResumeStoryboard BeginStoryboardName="beginStoryboard"/>
      </EventTrigger.Actions>
    </EventTrigger>
  </Grid.Triggers>
  <MediaElement x:Name="video"/>
  <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
    <Button x:Name="playButton">Play</Button>
    <Button x:Name="pauseButton">Pause</Button>
    <Button x:Name="resumeButton">Resume</Button>
  </StackPanel>
</Grid>

   
    
    
  








Related examples in the same category

1.Using MediaElement for AudioUsing MediaElement for Audio
2.Overlapping Videos with EffectsOverlapping Videos with Effects
3.Play mp3 filePlay mp3 file
4.Play wav filePlay wav file
5.Declarative PlaybackDeclarative Playback
6.Play a Media FilePlay a Media File
7.Sound And Video Playback in CodeSound And Video Playback in Code
8.Play with MediaPlayerPlay with MediaPlayer
9.Play Audio AsynchronouslyPlay Audio Asynchronously
10.Play System SoundsPlay System Sounds