WPF MediaElement 循环播放

前端代码:

  <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();
        }

相关推荐


扫描二维码,在手机上阅读

网友评论(0)