WPF Media 简单的播放器

时间:2022-06-02 20:53:12
<Window x:Class="PlayTest.MediaControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MediaControl" Height="" Width="">
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="Button.Click" SourceName="playButton">
<EventTrigger.Actions>
<BeginStoryboard Name="beginStoryboard">
<Storyboard>
<MediaTimeline Source="e:\\第1讲.Linux应用与发展(下).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" Background="Brown" Height="">Play</Button>
<Button x:Name="pauseButton" Background="Brown" Height="">Pause</Button>
<Button x:Name="resumeButton" Background="Brown" Height="">Resume</Button>
</StackPanel>
</Grid>
</Window>

WPF揭秘 14.2