前端代码:
<MediaElement LoadedBehavior="Manual" Name="MyVideo" MediaEnded="MyVideo_MediaEnded" Stretch="Fill" Volume="100" />
后端代码:
private void MyVideo_MediaEnded(object sender, RoutedEventArgs e) { MyVideo.Stop(); MyVideo.Play(); }后端代码2:
private void MediaElement_MediaEnded(object sender, RoutedEventArgs e) { var mele = (MediaElement)sender; mele.Position = new TimeSpan(0); mele.Play(); }