コード例 #1
0
        public static void PlayMedia(IVideo video)
        {
            var videoPath = GetVideoPath(video);

            if (!string.IsNullOrEmpty(videoPath) && File.Exists(videoPath))
            {
                if (Properties.Settings.Default.UseDefaultMediaPlayer)
                {
                    Process.Start(videoPath);
                }
                else
                {
                    var player = new BuiltinMediaPlayer(video);
                    player.Show();
                }
            }
            else
            {
                MessageBox.Show(string.Format("Could not find a compatible video file in '{0}'.", Path.Combine(Properties.Settings.Default.MediaDirectory, video.GetMediaPath())), "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #2
0
 public void Refresh()
 {
     if (_video != null)
     {
         Header           = _inTimeline ? _video.GetTimelineHeader() : _video.GetHeader();
         txtSynopsis.Text = _video.Synopsis;
         txtDate.Text     = _video.GetDateRepresentation();
         if (_video.GetDate() > DateTime.Now)
         {
             txtDate.Foreground = Brushes.Red;
             txtDate.ToolTip    = "This product is not available yet...";
         }
         try
         {
             imgCover.Source = new BitmapImage(new Uri(string.Format("{0}.jpg", Path.Combine(Properties.Settings.Default.MediaDirectory, _video.GetMediaPath(), MediaHelper.SanitizeMediaText(_video.Title))), UriKind.Absolute));
         }
         catch (FileNotFoundException fnfe)
         {
             imgCover.ToolTip = fnfe.Message;
         }
     }
 }
コード例 #3
0
        public static string GetVideoPath(IVideo video)
        {
            var dir            = Path.Combine(Properties.Settings.Default.MediaDirectory, video.GetMediaPath());
            var title          = Path.Combine(dir, SanitizeMediaText(video.Title));
            var possibleFiles  = VIDEO_FORMATS.Select(f => string.Format("{0}.{1}", title, f)).ToList();
            var availableFiles = Directory.GetFiles(dir);

            return(availableFiles.FirstOrDefault(f => possibleFiles.Contains(f)));
        }