//接受語音事件 private void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e) { /* * if (e.Result.Confidence < 0.2)//肯定度低於0.6,判為錯誤語句 * { * return; * }*/ switch (e.Result.Text.ToUpperInvariant()) { case "STOP": VideoElement.Pause(); break; case "PLAY": VideoElement.Play(); break; case "LOUD": VideoElement.Volume += 2; break; case "XIAO SHENG": VideoElement.Volume += -1; break; case "TIMEOUT": unit = 7; MessageBox.Show("暫停"); break; } }
/// <summary> /// Play next song in playlist. /// </summary> public async void BtnPlay_Click(object sender, RoutedEventArgs e) { _videoPlay = true; _forcePaused = false; if (ComponentPlayer.Current == null) { BtnOpen_Click(sender, e); return; } switch (ComponentPlayer.Current.PlayerStatus) { case PlayerStatus.Playing: if (VideoElement?.Source != null) { await VideoElement.Pause(); } PauseMedia(); break; case PlayerStatus.Ready: case PlayerStatus.Stopped: case PlayerStatus.Paused: if (VideoElement?.Source != null) { await VideoElement.Play(); } PlayMedia(); break; } }
private async Task PauseVideo() { if (VideoElement.MediaState != MediaPlaybackState.Play) { return; } await VideoElement.Pause(); }
private void SetUpVideo() //get the incoming video object, load it into MediaElement for playback and pause it { VideoElement.Source = new Uri(VideoPath, UriKind.Absolute); VideoElement.MediaFailed += MediaFailed; VideoElement.Loaded += MediaLoaded; VideoElement.Pause(); GetVideoDuration(); //get videos duration TimeSpan time = TimeSpan.FromSeconds(0); //go to the beginning of of the video VideoElement.Position = time; }
private void PlayStopButtonClick(object sender, RoutedEventArgs e) { if (PlayButton.IsChecked.Value) { VideoElement.Play(); PlayButton.Content = "\ue103"; } else { VideoElement.Pause(); PlayButton.Content = "\ue102"; } }
//private async void VideoPlay() //{ // //await VideoElement.Pause(); // //await VideoElement.Play(); //} private async Task VideoJumpTo(int milliseconds) { _waitActionCts = new MyCancellationTokenSource(); Guid?guid = _waitActionCts?.Guid; var trueOffset = milliseconds + _videoOffset; if (trueOffset < 0) { await VideoElement.Pause(); VideoElement.Position = TimeSpan.FromMilliseconds(0); await Task.Run(() => { Thread.Sleep(TimeSpan.FromMilliseconds(-trueOffset)); }); if (_waitActionCts?.Guid != guid || _waitActionCts?.IsCancellationRequested == true) { return; } if (!_forcePaused) { await VideoElement.Play(); } else { await VideoElement.Pause(); } } else { //if (_mediaEnded) //{ // VideoElement.Position = TimeSpan.FromMilliseconds(0); // await Task.Run(() => { Thread.Sleep(10); }); //} if (!_forcePaused) { await VideoElement.Play(); } else { await VideoElement.Pause(); } VideoElement.Position = TimeSpan.FromMilliseconds(trueOffset); } }
private void btnPlayPause_Checked(object sender, RoutedEventArgs e) { VideoElement.Pause(); btnPlayPause.Content = "Play"; }
private void btn_pasue_Click(object sender, RoutedEventArgs e) { VideoElement.Pause(); // 控制影片暫停 }