private void startOrPause(object sender, RoutedEventArgs e) { if (timer == null) { timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += timer_Tick; timer.Start(); EllStoryboard.Begin(); mediaTimelineController.Start(); var pauseIcon = new SymbolIcon(Symbol.Pause); startAndPauseButton.Icon = pauseIcon; startAndPauseButton.Label = "Pause"; } else { if (mediaTimelineController.State == MediaTimelineControllerState.Running) { EllStoryboard.Pause(); mediaTimelineController.Pause(); var playIcon = new SymbolIcon(Symbol.Play); startAndPauseButton.Icon = playIcon; startAndPauseButton.Label = "Play"; } else { EllStoryboard.Begin(); mediaTimelineController.Resume(); var pauseIcon = new SymbolIcon(Symbol.Pause); startAndPauseButton.Icon = pauseIcon; startAndPauseButton.Label = "Pause"; } } }
private void pause_Click(object sender, RoutedEventArgs e) { timelineController.Pause(); if (IsAudio()) { EllStoryboard.Pause(); } pause.Visibility = Visibility.Collapsed; play.Visibility = Visibility.Visible; }
//pause the media void PauseMedia(object sender, RoutedEventArgs e) { mediaTimelineController.Pause();//暂停播放 //图片旋转动画暂停 EllStoryboard.Pause(); Start.Visibility = Visibility.Visible; Pause.Visibility = Visibility.Collapsed; }
private void CustomMTC_PlayPause(object sender, EventArgs e) { if (mpe.CurrentState == MediaElementState.Playing) { EllStoryboard.Pause(); dispatcherTimer.Stop(); } else if (mpe.CurrentState == MediaElementState.Paused || mpe.CurrentState == MediaElementState.Stopped) { EllStoryboard.Resume(); dispatcherTimer.Start(); } }
public MediaPlayerPage() { InitializeComponent(); // 处理旋转盘片的显示和隐藏 mpe.MediaOpened += async(Media, o) => { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { mpe.TransportControls.IsStopEnabled = true; if (mpe.NaturalVideoHeight > 0) { DisplayDisk = false; } else { DisplayDisk = true; } MediaElement media = Media as MediaElement; String allTime = media.NaturalDuration.TimeSpan.ToString(); TimeRemainingElement.Text = allTime.Substring(0, allTime.IndexOf('.')); ProgressSlider.Maximum = media.NaturalDuration.TimeSpan.TotalSeconds; ProgressSlider.IsEnabled = true; dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); PlayPauseSymbol.Symbol = Symbol.Pause; }); }; mpe.MediaEnded += async(m, o) => { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { EllStoryboard.Stop(); EllStoryboard.Begin(); EllStoryboard.Pause(); dispatcherTimer.Stop(); PlayPauseSymbol.Symbol = Symbol.Play; TimeElapsedElement.Text = "00:00:00"; ProgressSlider.Value = 0; }); }; ProgressSlider.ValueChanged += MediaSlider_ValueChanged; }
private void StopButton_Click(object sender, RoutedEventArgs e) { if (mpe.CurrentState == MediaElementState.Playing) { EllStoryboard.Stop(); EllStoryboard.Begin(); EllStoryboard.Pause(); TimeElapsedElement.Text = "00:00:00"; ProgressSlider.Value = 0; dispatcherTimer.Stop(); mpe.Stop(); PlayPauseSymbol.Symbol = Symbol.Play; } }
private void PlayPauseButton_Click(object sender, RoutedEventArgs e) { if (mpe.CurrentState == MediaElementState.Playing) { // 停止播放 PlayPauseSymbol.Symbol = Symbol.Play; mpe.Pause(); EllStoryboard.Pause(); dispatcherTimer.Stop(); } else if (mpe.CurrentState == MediaElementState.Paused || mpe.CurrentState == MediaElementState.Stopped) { // 继续播放 PlayPauseSymbol.Symbol = Symbol.Pause; mpe.Play(); EllStoryboard.Resume(); dispatcherTimer.Start(); } }
private void pause_Click(object sender, RoutedEventArgs e) { try { if (_mediaTimelineController.State == MediaTimelineControllerState.Running) { EllStoryboard.Pause(); _mediaTimelineController.Pause(); } else { //EllStoryboard.Resume(); EllStoryboard.Begin(); _mediaTimelineController.Resume(); } } catch { } }
private async void PlaybackSession_PlaybackStateChanged(MediaPlaybackSession sender, object args) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { switch (State) { case MediaPlaybackState.Playing: EllStoryboard.Resume(); break; case MediaPlaybackState.Paused: EllStoryboard.Pause(); break; case MediaPlaybackState.None: EllStoryboard.Stop(); break; } }); }
private void Start_pause_Click(object sender, RoutedEventArgs e) { if (_mediaTimelineController.State == MediaTimelineControllerState.Running) { EllStoryboard.Pause(); this._mediaTimelineController.Pause(); start_pause.Icon = new SymbolIcon(Symbol.Play); } else { if (_mediaTimelineController.Position.TotalSeconds < RangeSelectorControl.RangeMin) { this._mediaTimelineController.Position = TimeSpan.FromSeconds(RangeSelectorControl.RangeMin); EllStoryboard.BeginTime = this._mediaTimelineController.Position; } EllStoryboard.Begin(); this._mediaTimelineController.Resume(); start_pause.Icon = new SymbolIcon(Symbol.Pause); } }
private async void PlaybackSession_PlaybackStateChanged(MediaPlaybackSession sender, object args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (sender.PlaybackState == MediaPlaybackState.Playing) { if (EllStoryboard.GetCurrentState() == ClockState.Stopped) { EllStoryboard.Begin(); } else { EllStoryboard.Resume(); RollTicker.Start(); } } else if (sender.PlaybackState == MediaPlaybackState.Paused) { EllStoryboard.Pause(); RollTicker.Stop(); } }); }
// 暂停播放 private void pauseClick(object sender, RoutedEventArgs e) { mediaSimple.Pause(); EllStoryboard.Pause(); }