Ejemplo n.º 1
0
        private void TiviMediaElement_OnMediaOpened(object sender, RoutedEventArgs e)
        {
            //
            if (!TiviMediaElement.NaturalDuration.TimeSpan.Equals(TimeSpan.Zero))
            {
                TimelineSlider.Maximum      = TiviMediaElement.NaturalDuration.TimeSpan.TotalSeconds;
                TotalDurationTextBlock.Text = FormatTimeSpan(TiviMediaElement.NaturalDuration.TimeSpan);
            }
            else
            {
                //TimelineSlider.IsEnabled = false;
                //TotalDurationTextBlock.Text = string.Empty;
                TimelineSlider.Maximum = 1;     //10 phút
            }
            isOpenedMedia = true;
            TiviMediaElement.Play();
            TiviMediaElement.Volume = CalcVolume(VolumeSlider.Value);

            _positionTimer.Start();
            ProsesProgressBar.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 2
0
        private void PlayPauseButton_OnClick(object sender, RoutedEventArgs e)
        {
            PlayAgainButton.Visibility = Visibility.Collapsed;
            string str = "/Assets/Icon/transport.pause.png";

            imgPause.Source = null;
            if (TiviMediaElement.CurrentState == MediaElementState.Playing)
            {
                _positionTimer.Stop();
                TiviMediaElement.Pause();
            }
            else if (TiviMediaElement.CurrentState == MediaElementState.Paused)
            {
                InitMediaPlayer();
            }
            else
            {
                TiviMediaElement.Play();
                _positionTimer.Start();
            }
            UpdateState(TiviMediaElement.CurrentState);
        }