示例#1
0
        private void btnPlayClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (isPlaying)
                {
                    ReplaySDK.PlayM4_Pause(_port, !(bool)btnPlayPause.IsChecked);
                    if ((bool)btnPlayPause.IsChecked)
                    {
                        timer.Start();
                    }
                    else
                    {
                        timer.Stop();
                    }
                }
                else
                {
                    if (!(bool)checkBoxPlayLocalFile.IsChecked)
                    {
                        var viewModel = DataContext as DataReplayerViewModel;
                        if (viewModel != null && viewModel.SelectedVideo != null)
                        {
                            string directory = string.Format(@"c:\{0}", viewModel.SelectedVideo.Directory);
                            if (!Directory.Exists(directory))
                            {
                                Directory.CreateDirectory(directory);
                            }
                            string file = string.Format(@"c:\{0}", viewModel.SelectedVideo.FullPath);

                            if (!File.Exists(file))
                            {
                                DownloadAndPlayVideoFile(viewModel.SelectedVideo.Address, file);
                            }
                            else
                            {
                                PlayVideoFile(file);
                            }
                        }
                    }
                    else
                    {
                        if (File.Exists(selectedVideoFile))
                        {
                            PlayVideoFile(selectedVideoFile);
                        }
                        else
                        {
                            MessageBox.Show(string.Format("指定的文件不存:{0}", selectedVideoFile));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#2
0
 void VideoReplayerView_Unloaded(object sender, RoutedEventArgs e)
 {
     if (isPlaying)
     {
         btnPlayPause.IsChecked = false;
         ReplaySDK.PlayM4_Pause(_port, !(bool)btnPlayPause.IsChecked);
         timer.Stop();
     }
 }