WPF MediaElement播放视频,如何实现实现循环播放视频??
mediaelement循环视频,网上查过:一是:添加视频播放完事件,播放完,再重新播放。理论可行,但失败了<MediaElementName="player"Grid....
mediaelement循环视频,网上查过:
一是:添加视频播放完事件,播放完,再重新播放。理论可行,但失败了
<MediaElement Name="player" Grid.Row="1" Grid.Column="2" Source="Video/test.mpg" LoadedBehavior="Manual" MediaEnded="player_MediaEnded">
</MediaElement>
private void player_MediaEnded(object sender, RoutedEventArgs e)
{
player.Position = new TimeSpan(0);
player.Play();
}
二是:用MediaTimeline添加动画效果。理论可行,但还是失败了。
<MediaElement Name="media1" LoadedBehavior="Play">
<MediaElement.Triggers>
<EventTrigger RoutedEvent="MediaElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<MediaTimeline Source="Video\test.mpg" RepeatBehavior="Forever" Storyboard.TargetName="media1"></MediaTimeline>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</MediaElement.Triggers>
</MediaElement>
两种方法都不行,不知道是为什么,有人实现过吗?或指出问题在哪?或给个成功的实例... 展开
一是:添加视频播放完事件,播放完,再重新播放。理论可行,但失败了
<MediaElement Name="player" Grid.Row="1" Grid.Column="2" Source="Video/test.mpg" LoadedBehavior="Manual" MediaEnded="player_MediaEnded">
</MediaElement>
private void player_MediaEnded(object sender, RoutedEventArgs e)
{
player.Position = new TimeSpan(0);
player.Play();
}
二是:用MediaTimeline添加动画效果。理论可行,但还是失败了。
<MediaElement Name="media1" LoadedBehavior="Play">
<MediaElement.Triggers>
<EventTrigger RoutedEvent="MediaElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<MediaTimeline Source="Video\test.mpg" RepeatBehavior="Forever" Storyboard.TargetName="media1"></MediaTimeline>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</MediaElement.Triggers>
</MediaElement>
两种方法都不行,不知道是为什么,有人实现过吗?或指出问题在哪?或给个成功的实例... 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询