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);
            }
        }
 public void CreateContentFromEmbed(string embed, ISmartContent content)
 {
     try
     {
         // download the video
         Video             video = VideoProviderManager.FindVideo(embed);
         VideoSmartContent vsc   = new VideoSmartContent(content);
         vsc.Initialize(video, null);
         if (video == null)
         {
             throw new ContentCreationException(
                       "Unable to Parse Video Embed", "Unknown provider or incomplete embed.");
         }
     }
     catch (ContentCreationException)
     {
         throw;
     }
     catch (VideoPluginException ex)
     {
         throw new ContentCreationException(ex.Title, ex.Description);
     }
     catch (Exception ex)
     {
         VideoPluginUnexpectedException exception = new VideoPluginUnexpectedException(ex);
         throw new ContentCreationException(exception.Title, exception.Description);
     }
 }
 public override void CreateContentFromUrl(string url, ref string title, ISmartContent content)
 {
     try
     {
         // download the video
         Video video = VideoProviderManager.FindVideo(url);
         if (video == null)
         {
             throw new ContentCreationException(
                       Res.Get(StringId.Plugin_Video_Cannot_Parse_Url),
                       Res.Get(StringId.Plugin_Video_Cannot_Parse_Url_Message));
         }
         VideoSmartContent vsc = new VideoSmartContent(content);
         vsc.Initialize(video, null);
     }
     catch (ContentCreationException)
     {
         throw;
     }
     catch (VideoPluginException ex)
     {
         throw new ContentCreationException(ex.Title, ex.Description);
     }
     catch (Exception ex)
     {
         VideoPluginUnexpectedException exception = new VideoPluginUnexpectedException(ex);
         throw new ContentCreationException(exception.Title, exception.Description);
     }
 }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        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);
        }
        bool IHandlesMultipleUrls.HasUrlMatch(string url)
        {
            VideoProvider provider = VideoProviderManager.FindProviderFromUrl(url);

            return(provider != null);
        }