Beispiel #1
0
 private void PlayControl()
 {
     try
     {
         if (!mediaplaying)
         {
             mediaplaying      = true;
             Play.Visibility   = Visibility.Hidden;
             Pause.Visibility  = Visibility.Visible;
             Pause2.Visibility = Visibility.Visible;
             PreviewMedia.Play();
             timer.Start();
         }
         else
         {
             mediaplaying      = false;
             Pause.Visibility  = Visibility.Hidden;
             Pause2.Visibility = Visibility.Hidden;
             Play.Visibility   = Visibility.Visible;
             PreviewMedia.Pause();
             timer.Stop();
         }
     }
     catch (Exception ex)
     {
         Error.WriteToLog(ex);
     }
 }
Beispiel #2
0
        private void updateProgressBar()
        {
            try
            {
                if (mediaplaying && !isdragging)
                {
                    var MediaMilliseconds = PreviewMedia.Position.TotalMilliseconds;
                    var MediaSeconds      = PreviewMedia.Position.TotalSeconds;
                    var MediaMinutes      = PreviewMedia.Position.TotalMinutes;
                    var MediaHours        = PreviewMedia.Position.TotalHours;

                    var RemainingMilliseconds = PreviewMedia.NaturalDuration.TimeSpan.TotalMilliseconds - PreviewMedia.Position.TotalMilliseconds;
                    var RemainingSeconds      = Math.Floor((RemainingMilliseconds / 1000) % 60);
                    var RemainingMinutes      = Math.Floor((RemainingMilliseconds / 60000) % 60);
                    var RemainingHours        = Math.Floor((RemainingMilliseconds / 3600000) % 60);

                    SettingProgressBar  = true;
                    VideoProgress.Value = PreviewMedia.Position.TotalMilliseconds;
                    SettingProgressBar  = false;

                    if (PreviewMedia.NaturalDuration.HasTimeSpan)
                    {
                        if (PreviewMedia.Position.TotalMilliseconds == PreviewMedia.NaturalDuration.TimeSpan.TotalMilliseconds)
                        {
                            if (LessThan10Seconds)
                            {
                                PreviewMedia.Stop();
                                PreviewMedia.Play();
                            }
                            else
                            {
                                PreviewMedia.Stop();
                                mediaplaying      = false;
                                Play.Visibility   = Visibility.Visible;
                                Pause.Visibility  = Visibility.Hidden;
                                Pause2.Visibility = Visibility.Hidden;
                            }
                        }
                    }

                    mediatime.Content          = (MediaHours >= 1 ? Math.Floor(MediaHours).ToString("00.") + ":" : "00:") + Math.Floor(MediaMinutes % 60).ToString("00.") + ":" + Math.Floor(MediaSeconds % 60).ToString("00.");
                    RemainingMediaTime.Content = RemainingHours.ToString("00.") + ":" + RemainingMinutes.ToString("00.") + ":" + RemainingSeconds.ToString("00.");
                }
            }
            catch (Exception ex)
            {
                Error.WriteToLog(ex);
            }
        }
Beispiel #3
0
        public MediaFullscreen(string mediafile, TimeSpan position, XMLUtil.SaveSettings settings, List <string> Tags, bool mediaplay)
        {
            InitializeComponent();
            SetWindowScreen(this, GetWindowScreen(App.Current.MainWindow));

            try
            {
                this.Cursor  = Cursors.None;
                this.Topmost = true;
                mousedelay   = settings.Mousedisappeardelay;

                timer.Interval = new TimeSpan(0, 0, 1);
                timer.Tick    += new EventHandler(update_progress);
                mousewheeldonetimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
                mousewheeldonetimer.Tick    += new EventHandler(MouseWheel_Done);
                mousenomove.Interval         = new TimeSpan(0, 0, mousedelay);
                mousenomove.Tick            += new EventHandler(Mouse_nomove);

                if (Tags != null)
                {
                    if (Tags.Count > 0)
                    {
                        foreach (string tag in Tags)
                        {
                            if (tag.Contains("Event: "))
                            {
                                EventControls.Visibility = Visibility.Visible;
                                string   tagname = tag.Remove(0, 7);
                                string[] others  = tagname.Split('|');
                                Button   event1  = new Button
                                {
                                    Content = others[0],
                                    HorizontalContentAlignment = HorizontalAlignment.Center,
                                    Tag         = others[1],
                                    Background  = Brushes.LightGray,
                                    BorderBrush = Brushes.Transparent,
                                    Foreground  = Brushes.Black,
                                    FontWeight  = FontWeights.Bold,
                                    FontSize    = 12,
                                    Height      = 20
                                };
                                event1.Click += new RoutedEventHandler(Event1_Click);
                                EventControls.Children.Add(event1);
                            }
                        }
                    }
                }

                PreviewMedia.Source = new Uri(mediafile);
                ss             = settings;
                Volume.Value   = ss.Volume;
                mediaplaying   = mediaplay;
                returnposition = position;

                if (mediaplaying)
                {
                    PreviewMedia.Play();
                    mediaplaying = true;
                    timer.Start();
                    Play.Visibility   = Visibility.Hidden;
                    Pause.Visibility  = Visibility.Visible;
                    Pause2.Visibility = Visibility.Visible;
                }
                else
                {
                    mediaplaying = false;
                    timer.Stop();
                    Play.Visibility   = Visibility.Visible;
                    Pause.Visibility  = Visibility.Hidden;
                    Pause2.Visibility = Visibility.Hidden;
                }
            }
            catch (Exception ex)
            {
                this.Topmost = false;
                MessageBox.Show("Error initializing media fullcreen. - " + ex.Message);
                Error.WriteToLog(ex);
            }
        }