public override bool ValidateSelection()
        {
            if (_video == null)
            {
                string input = videoCode.Text.Trim();
                try
                {
                    _video = VideoProviderManager.FindVideo(input);
                }
                catch (VideoUrlConvertException)
                {
                    DisplayHtml(Res.Get(StringId.VideoUrlConvertError), CreateErrorHtml);
                    return(false);
                }

                if (_video == null)
                {
                    DisplayHtml(Res.Get(StringId.Plugin_Video_Cannot_Parse_Url_Message), CreateErrorHtml);
                    return(false);
                }
            }

            IViewObject element = GetIViewObjectElement(previewBox.Document.Body);

            // The object doesnt cant have a snapshot taken of it, but we should still allow it to
            // be inserted, though on some providers this means it might be stripped.
            // NOTE: We skip this behavior on IE9+ because of WinLive 589461.
            if (element == null || ApplicationEnvironment.BrowserVersion.Major >= 9)
            {
                _video.Snapshot = null;
                return(true);
            }

            try
            {
                _video.Snapshot = HtmlScreenCaptureCore.TakeSnapshot(element, _video.Width, _video.Height);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Failed to take video snapshot: " + ex);
                _video.Snapshot = null;
            }

            return(true);
        }
        private string GetSnapshotPathIfNeeded(HtmlType htmlType, VideoContext context)
        {
            // NOTE: We skip this behavior on IE9+ because of WinLive 589461.
            if (htmlType == HtmlType.ObjectHtml || ApplicationEnvironment.BrowserVersion.Major >= 9)
            {
                return(null);
            }

            try
            {
                IHTMLElement element = context.GetElement(((IInternalContent)_content).Id);

                if (element != null)
                {
                    element = ((IHTMLDOMNode)element).firstChild as IHTMLElement;
                }

                if (element != null && (element is IViewObject))
                {
                    Bitmap snapshot = HtmlScreenCaptureCore.TakeSnapshot((IViewObject)element, element.offsetWidth, element.offsetHeight);
                    UpdateVideoSnapshot(snapshot);
                }

                Uri uri = _content.Files.GetUri(_content.Properties.GetString(VIDEO_PUBLISH_IMAGE, String.Empty));

                if (uri != null)
                {
                    return(uri.ToString());
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Failed to take video snapshot: " + ex);
            }

            return(null);
        }