Пример #1
0
 private void Play(object sender, RoutedEventArgs e)
 {
     PlayButton.Visibility  = Visibility.Collapsed;
     PauseButton.Visibility = Visibility.Visible;
     mediaPlayer.Play();
     EllStoryboard.Begin();
 }
Пример #2
0
 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";
         }
     }
 }
Пример #3
0
 public void DisplayButton_Click(object sender, RoutedEventArgs e)
 {
     if (mediaPlayer.CurrentState == MediaPlayerState.Paused || mediaPlayer.CurrentState == MediaPlayerState.Stopped)
     {
         DispatcherTimer timer = new DispatcherTimer();
         timer.Interval = TimeSpan.FromSeconds(1);
         timer.Tick    += timer_Tick;
         timer.Start();
         EllStoryboard.Begin();
         innerEllStoryboard.Begin();
         switchOn.Begin();
         mediaPlayer.Play();
         DisplayButton.Label = "暂停";
         DisplayButton.Icon  = new SymbolIcon(Symbol.Pause);
     }
     else if (mediaPlayer.CurrentState == MediaPlayerState.Playing)
     {
         EllStoryboard.Pause();
         innerEllStoryboard.Pause();
         switchOff.Begin();
         mediaPlayer.Pause();
         DisplayButton.Label = "播放";
         DisplayButton.Icon  = new SymbolIcon(Symbol.Play);
     }
 }
Пример #4
0
 private async void Player_MediaOpened(MediaPlayer sender, object args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         MusicTime = sender.PlaybackSession.NaturalDuration.ToString(@"mm\:ss");
         EllStoryboard.Begin();
     });
 }
Пример #5
0
 private void start_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         DispatcherTimer timer = new DispatcherTimer();
         timer.Interval = TimeSpan.FromSeconds(1);
         timer.Tick    += timer_Tick;
         timer.Start();
         EllStoryboard.Begin();
         _mediaTimelineController.Start();
     }
     catch
     {
     }
 }
Пример #6
0
        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;
        }
Пример #7
0
        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;
            }
        }
Пример #8
0
        void timer_Tick(object sender, object e)
        {
            Display_ProcessBar.Value = ((TimeSpan)mediaPlayer.Position).TotalSeconds;
            if (Display_ProcessBar.Value == Display_ProcessBar.Maximum)
            {
                mediaPlayer.Position = TimeSpan.FromSeconds(0);
                if ((string)DisplayOrderButton.Tag == "Circle")
                {
                    EllStoryboard.Begin();
                    innerEllStoryboard.Begin();
                    switchOn.Begin();
                    mediaPlayer.Play();
                    DisplayButton.Label = "暂停";
                    DisplayButton.Icon  = new SymbolIcon(Symbol.Pause);
                }
                else
                {
                    mediaPlayer.Pause();
                    EllStoryboard.Stop();
                    switchOff.Begin();
                    innerEllStoryboard.Stop();
                    DisplayButton.Label = "播放";
                    DisplayButton.Icon  = new SymbolIcon(Symbol.Play);
                }
            }
            String time;
            int    minute  = ((int)Display_ProcessBar.Value) / 60;
            int    second  = ((int)Display_ProcessBar.Value) - minute * 60;
            string minutes = minute.ToString();
            string seconds = second.ToString();

            if (minute < 10)
            {
                minutes = "0" + minute.ToString();
            }
            if (second < 10)
            {
                seconds = "0" + second.ToString();
            }
            time             = minutes + ":" + seconds;
            CurrentTime.Text = time;
        }
Пример #9
0
 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
     {
     }
 }
Пример #10
0
 private void play_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         DispatcherTimer timer = new DispatcherTimer();
         timer.Interval = TimeSpan.FromSeconds(1);
         timer.Tick    += TimerTick;
         timer.Start();
         if (IsAudio())
         {
             EllStoryboard.Begin();
         }
         timelineController.Resume();
         play.Visibility  = Visibility.Collapsed;
         pause.Visibility = Visibility.Visible;
     }
     catch
     {
     }
 }
 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);
     }
 }
Пример #12
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ToDetailAnimation");
                if (animation != null)
                {
                    animation.TryStart(GridBack);
                }
            }
            catch (Exception) { }

            BackBlurBrush.Amount = 0;
            BackBlurTicker.Start();

            if (MusicPage.ThisPage.MediaControl.MediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
            {
                EllStoryboard.Begin();
                RollTicker.Start();
            }
        }
Пример #13
0
        private async void OpenFileButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.MusicLibrary
            };

            string[] type = { ".mp3", ".mp4", ".avi", ".wmv", ".rmvb", ".mpeg", ".wma" };
            foreach (string s in type)
            {
                picker.FileTypeFilter.Add(s);
            }
            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                mpe.AutoPlay = true;
                //get the stream from the storage file
                var mediaStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                //set the source to the video stream
                mpe.SetSource(mediaStream, file.ContentType);
                EllStoryboard.Begin();
                // MediaSource.CreateFromStorageFile(file);
                JsonObject res = await Services.MusicService.SearchSong(file.Name);

                string     songId   = Services.MusicService.GetSongIdFromSearch(res);
                JsonObject songData = await Services.MusicService.GetSongDetail(songId);

                string url        = Services.MusicService.GetAlbumImageFromSong(songData);
                string AlbumTitle = Services.MusicService.GetAlbumTitleFromSong(songData);
                DiskImage.ImageSource = new BitmapImage(new Uri(url));


                TitleText.Text = file.Name;
                AlbumText.Text = AlbumTitle;
                EllStoryboard.Resume();
            }
        }
Пример #14
0
 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();
         }
     });
 }
Пример #15
0
        //play the media
        void PlayMedia(object sender, RoutedEventArgs e)
        {
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += Timer;
            timer.Start();
            if (mediaTimelineController.State == MediaTimelineControllerState.Paused)
            {
                mediaTimelineController.Resume();
            }
            else
            {
                mediaTimelineController.Start();//播放加载好的视频文件.
                InitializePropertyValues();
            }

            //图片旋转动画开始
            EllStoryboard.Begin();

            Start.Visibility = Visibility.Collapsed;
            Pause.Visibility = Visibility.Visible;
        }
Пример #16
0
 public NewUser()
 {
     this.InitializeComponent();
     EllStoryboard.Begin();
 }
Пример #17
0
 // 开始播放
 private void playClick(object sender, RoutedEventArgs e)
 {
     mediaSimple.Play();
     EllStoryboard.Begin();
     progress.Maximum = mediaSimple.NaturalDuration.TimeSpan.TotalSeconds;
 }