0

我正在尝试使用 MediaElement 控件一次播放一个 .wmv 片段。

我正在使用计时器来播放/暂停视频

但是视频播放一直不同步。

任何想法如何解决这个问题?

public partial class MainWindow : Window
{
    private System.Windows.Threading.DispatcherTimer VideoTimer;
    private bool is_playing;

    private void PlaySegment(long duration_miliseconds,long offset_milisecond=-1)
    {
        if (is_playing) return;
        VideoTimer.Interval = new TimeSpan(10000*duration_miliseconds);
        is_playing = true;
        if (offset_milisecond>=0)
            VideoControl.Position = new TimeSpan(10000*offset_milisecond);
        VideoControl.Play();
        VideoTimer.Start();
    }
    private void Timer_Stopped(object sender, EventArgs e)
    {
        VideoControl.Pause();
        is_playing = false;
    }
    public MainWindow()
    {
        InitializeComponent();
        VideoTimer = new System.Windows.Threading.DispatcherTimer();
        VideoTimer.Tick += new EventHandler(Timer_Stopped);
    }
}

这是相关的 XAML 代码: <MediaElement x:Name="VideoControl" LoadedBehavior="Manual" />

谢谢 !

4

1 回答 1

1

开启刷机...

VideoControl.ScrubbingEnabled = true;
于 2013-08-28T14:36:28.303 回答