/// <summary> /// Gets the status of a video. In the event the video is already publiushed to a service /// this function should return "". When it is being published by WLW we will get the status /// from the publisher. It needs a window so that it can prompt the user for the /// username/password if a status watcher needs to be created. /// </summary> /// <param name="window"></param> /// <returns></returns> private string GenerateStatus(IWin32Window window, string blogId) { if (VideoHasProgress()) { IStatusWatcher publisher = (IStatusWatcher)((IInternalContent)_content).ObjectState; // check to see if we need to create a status watcher, this happens during a post load if (publisher == null) { // Make a video for the publisher to create a watcher for Video video = new Video(_content.Properties.GetString(VIDEO_ID, Guid.Empty.ToString()), _content.Properties.GetString(VIDEO_URL, String.Empty), EmbedFormat, EditorFormat, null, HtmlSize.Width, HtmlSize.Height, VideoAspectRatioType.Unknown); video.Username = _content.Properties.GetString(VIDEO_USERNAME, null); IVideoPublisher newPublisher; if (Provider.IsYouTube) { newPublisher = new YouTubeVideoPublisher(); } else { newPublisher = null; Trace.Fail("Unknown video publisher has been found. ID: " + Provider.ServiceId); } newPublisher.Init(null, window, blogId); // Try to create a new watcher that can be used publisher = newPublisher.CreateStatusWatcher(video); ((IInternalContent)_content).ObjectState = publisher; ((IInternalContent)_content).RefreshCallback = DateTimeHelper.UtcNow; } // If the publisher couldnt make a new status watcher // we just try to take a snap shot and then pretend it is comepleted if (publisher == null) { StopProgress(false); return VideoPublishStatus.Completed.ToString(); } // Check to see the status and if it is comepleted we can stop tracking the progress PublishStatus publishStatus = publisher.Status; Id = publishStatus.Id; if (publishStatus.Status == VideoPublishStatus.Completed) { StopProgress(false); return VideoPublishStatus.Completed.ToString(); } if (publishStatus.Status == VideoPublishStatus.Error) { StopProgress(true); return publishStatus.DisplayMessage; } // return the status message return publishStatus.DisplayMessage; } return String.Empty; }
public override void Init(MediaSmartContent content, string blogId) { base.Init(content, blogId); if (MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.YouTubeVideo)) { YouTubeVideoPublisher youtube = new YouTubeVideoPublisher(); youtube.Init(null, this, blogId); //FIXME sideBarControl.SetEntry(youtube, ResourceHelper.LoadAssemblyResourceBitmap("Video.YouTube.Images.Sidebar.png"), youtube.ToString()); } sideBarControl.SelectedIndexChanged += new EventHandler(sideBarControl_SelectedIndexChanged); }