public override string GeneratePublishHtml(IPublishingContext publishingContext)
        {
            VideoContext  context = new VideoContext(publishingContext);
            StringBuilder html    = new StringBuilder();

            html.Append(GeneratePublishVideoHtml(context));
            html.Append(GenerateMetadataHtml(false));
            return(html.ToString());
        }
        private string GeneratePublishVideoHtml(VideoContext context)
        {
            //check for special cases--whitelist blog providers and such
            string output;

            if (VideoProviderManager.CheckForWhitelist(context.BlogProviderId, ProviderId, Id, HtmlSize, out output))
            {
                return(String.Format(CultureInfo.InvariantCulture, "<div>{0}</div>", output));
            }

            // generate 'smart' html based on the user's preference
            AdaptiveHtmlObject adaptiveHtmlObject = new AdaptiveHtmlObject(VideoProvider.GenerateEmbedHtml(EmbedFormat, Id, HtmlSize), Url);

            if (HtmlSize != VideoSnapshotSize)
            {
                adaptiveHtmlObject.PreviewImageSize = HtmlSize;
            }
            adaptiveHtmlObject.OpenPreviewInNewWindow = OpenInNewWindow;
            HtmlType htmlType;

            //determine player style
            VideoPlayerStyle playerStyle = context.DetermineAppropriatePlayer(Url != String.Empty);

            switch (playerStyle)
            {
            case VideoPlayerStyle.Automatic:
                htmlType = HtmlType.AdaptiveHtml;
                break;

            case VideoPlayerStyle.PreviewWithLink:
                htmlType = HtmlType.PreviewHtml;
                break;

            case VideoPlayerStyle.EmbeddedInPage:
                htmlType = HtmlType.ObjectHtml;
                break;

            default:
                Trace.Fail("Unexpected PlayerStyle: " + playerStyle.ToString());
                htmlType = HtmlType.PreviewHtml;
                break;
            }

            string path = GetSnapshotPathIfNeeded(htmlType, context);

            if (!string.IsNullOrEmpty(path))
            {
                adaptiveHtmlObject.PreviewImageSrc = path;
            }
            else
            {
                htmlType = HtmlType.ObjectHtml;
            }

            return(adaptiveHtmlObject.GenerateHtml(htmlType));
        }
        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);
        }
        private string GeneratePublishVideoHtml(VideoContext context)
        {
            //check for special cases--whitelist blog providers and such
            string output;
            if (VideoProviderManager.CheckForWhitelist(context.BlogProviderId, ProviderId, Id, HtmlSize, out output))
            {
                return String.Format(CultureInfo.InvariantCulture, "<div>{0}</div>", output);
            }

            // generate 'smart' html based on the user's preference
            AdaptiveHtmlObject adaptiveHtmlObject = new AdaptiveHtmlObject(VideoProvider.GenerateEmbedHtml(EmbedFormat, Id, HtmlSize), Url);
            if (HtmlSize != VideoSnapshotSize)
                adaptiveHtmlObject.PreviewImageSize = HtmlSize;
            adaptiveHtmlObject.OpenPreviewInNewWindow = OpenInNewWindow;
            HtmlType htmlType;

            //determine player style
            VideoPlayerStyle playerStyle = context.DetermineAppropriatePlayer(Url != String.Empty);
            switch (playerStyle)
            {
                case VideoPlayerStyle.Automatic:
                    htmlType = HtmlType.AdaptiveHtml;
                    break;

                case VideoPlayerStyle.PreviewWithLink:
                    htmlType = HtmlType.PreviewHtml;
                    break;

                case VideoPlayerStyle.EmbeddedInPage:
                    htmlType = HtmlType.ObjectHtml;
                    break;

                default:
                    Trace.Fail("Unexpected PlayerStyle: " + playerStyle.ToString());
                    htmlType = HtmlType.PreviewHtml;
                    break;
            }

            string path = GetSnapshotPathIfNeeded(htmlType, context);

            if (!string.IsNullOrEmpty(path))
            {
                adaptiveHtmlObject.PreviewImageSrc = path;
            }
            else
            {
                htmlType = HtmlType.ObjectHtml;
            }

            return adaptiveHtmlObject.GenerateHtml(htmlType);
        }
        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;
        }
 public override string GeneratePublishHtml(IPublishingContext publishingContext)
 {
     VideoContext context = new VideoContext(publishingContext);
     StringBuilder html = new StringBuilder();
     html.Append(GeneratePublishVideoHtml(context));
     html.Append(GenerateMetadataHtml(false));
     return html.ToString();
 }