Esempio n. 1
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;

            try
            {
                _mediaInfo = new MediaInfo.MediaInfo(Path.Combine(
                                                         Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                         Environment.Is64BitProcess ? "MediaInfo-x64\\" : "MediaInfo-x86\\"));
                _mediaInfo.Option("Cover_Data", "base64");

                _mediaInfo.Open(path);
            }
            catch (Exception)
            {
                _mediaInfo?.Dispose();
                _mediaInfo = null;
            }

            context.TitlebarOverlap = true;

            if (_mediaInfo == null ||
                !string.IsNullOrWhiteSpace(_mediaInfo.Get(StreamKind.General, 0, "VideoCount"))) // video
            {
                int.TryParse(_mediaInfo?.Get(StreamKind.Video, 0, "Width"), out var width);
                int.TryParse(_mediaInfo?.Get(StreamKind.Video, 0, "Height"), out var height);
                double.TryParse(_mediaInfo?.Get(StreamKind.Video, 0, "Rotation"), out var rotation);
                // Correct rotation: on some machine the value "90" becomes "90000" by some reason
                if (rotation > 360)
                {
                    rotation /= 1e3;
                }

                var windowSize = new Size
                {
                    Width  = Math.Max(100, width == 0 ? 1366 : width),
                    Height = Math.Max(100, height == 0 ? 768 : height)
                };

                if (rotation % 180 != 0)
                {
                    windowSize = new Size(windowSize.Height, windowSize.Width);
                }

                context.SetPreferredSizeFit(windowSize, 0.8);

                context.TitlebarAutoHide       = true;
                context.Theme                  = Themes.Dark;
                context.TitlebarBlurVisibility = true;
            }
            else // audio
            {
                context.PreferredSize = new Size(500, 300);

                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
        }
Esempio n. 2
0
        public void Cleanup()
        {
            _vp?.Dispose();
            _vp = null;

            _mediaInfo?.Dispose();
            _mediaInfo = null;

            _context = null;
        }