コード例 #1
0
        void LoadBackgroundVideo()
        {
            DirectoryInfo DI = new DirectoryInfo(BackgroundVideoPath);

            if (!DI.Exists)
            {
                DI.Create();
            }

            var files = DI.GetFiles("*.mp4");

            if (files.Length > 0)
            {
                int c            = files.Length;
                int r            = RNG.Next(c);
                var selected_vid = files[r];

                if (selected_vid.Exists && selected_vid.Extension.ToLower() == ".mp4") //redundant check
                {
                    try
                    {
                        BackgroundVideoPlayer.Source      = new Uri(selected_vid.FullName, UriKind.Absolute);
                        BackgroundVideoPlayer.MediaEnded += (_o, _e) => { BackgroundVideoPlayer.Stop(); BackgroundVideoPlayer.Play(); };
                        BackgroundVideoPlayer.Play();
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #2
0
 private void UserControl_Unloaded(object sender, RoutedEventArgs e)
 {
     BackgroundVideoPlayer.Stop();
     if (TimeoutTimer != null)
     {
         TimeoutTimer.Stop();
     }
 }
コード例 #3
0
        void OnTimeoutTimerElapsed()
        {
            EventHandler eh = this.Completed;

            if (eh != null)
            {
                BackgroundVideoPlayer.Stop();
                if (TimeoutTimer != null)
                {
                    TimeoutTimer.Stop();
                }
                eh(this, new EventArgs());
            }
        }