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);
     }
 }
        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);
        }