コード例 #1
0
        private void PopulatePreviewBox()
        {
            _video = null;
            string input = videoCode.Text.Trim();

            try
            {
                _video = VideoProviderManager.FindVideo(input);
            }
            catch (VideoUrlConvertException)
            {
                DisplayHtml(Res.Get(StringId.VideoUrlConvertError), CreateErrorHtml);
                return;
            }

            if (_video != null)
            {
                lblSize.Text    = String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.Plugin_Video_Web_Video_Size), _video.Width, _video.Height);
                lblService.Text = String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.Plugin_Video_Web_Video_Provider),
                                                _video.Provider != null ? _video.Provider.ServiceName : Res.Get(StringId.Plugin_Video_Unknown_Provider));

                DisplayHtml(
                    VideoProvider.GenerateEmbedHtml(_video.EditorFormat, _video.Id,
                                                    new Size(_video.Width, _video.Height)), CreateEmbedHtml);
            }
            else
            {
                DisplayHtml(Res.Get(StringId.Plugin_Video_Cannot_Parse_Url_Message), CreateErrorHtml);
                lblSize.Text    = Res.Get(StringId.Plugin_Video_Web_Video_Size_Blank);
                lblService.Text = Res.Get(StringId.Plugin_Video_Web_Video_Service_Blank);
            }
        }
コード例 #2
0
        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));
        }