internal void Delete() { // FIXME:It would be nice if this was copied to all the old versions // of this file in the SupportingFile store using (Bitmap img = CreateMockPlayer(Res.Get(StringId.VideoError))) { // Show the player as in an error state, stop tracking its progress UpdateVideoSnapshot(img); } _content.Properties.SetBoolean(VIDEO_HAS_PROGRESS, false); _content.Properties.SetString(VIDEO_STATUS, Res.Get(StringId.VideoError)); //FIXME: The problem with doing this is that once you undo a delete file, // there is no way to turn it back on for call backs // If it is a video and has a watcher make sure it is taken care of IStatusWatcher statusWatcher = ((IInternalContent)_content).ObjectState as IStatusWatcher; if (statusWatcher == null) { return; } statusWatcher.CancelPublish(); statusWatcher.Dispose(); ((IInternalContent)_content).ObjectState = null; }
/// <summary> /// When a video is finished or has an error it should no longer /// have settings that say it has progress. Clears those out, and make /// sure that we arent going to be called back anymore. /// </summary> /// <param name="message">The last known status that the video had</param> private void StopProgress(bool hasError) { IStatusWatcher sw = ((IInternalContent)_content).ObjectState as IStatusWatcher; if (sw != null) { sw.Dispose(); } // Remove the place holder on success if (!hasError) { RemoveBitmap(_content.Properties.GetString(VIDEO_PUBLISH_IMAGE, String.Empty)); _content.Properties.Remove(VIDEO_PUBLISH_IMAGE); } RemoveBitmap(VIDEO_PROGRESS_PATH); _content.Properties.SetBoolean(VIDEO_HAS_PROGRESS, false); _content.Properties.SetBoolean(VIDEO_HAS_ERROR, hasError); }
private void InitializeSettingsUI() { Padding margin = new Padding(_VideoContent.LayoutStyle.LeftMargin, _VideoContent.LayoutStyle.TopMargin, _VideoContent.LayoutStyle.RightMargin, _VideoContent.LayoutStyle.BottomMargin); SetAlignmentMargin(margin, _VideoContent.LayoutStyle.Alignment); // video size in status-bar UpdateVideoSizeDisplay(); IStatusWatcher statusWatcher = ((IInternalContent)_VideoContent.SmartContent).ObjectState as IStatusWatcher; if (statusWatcher != null && statusWatcher.IsCancelable) { commandVideoWebPreview.PublishCompleted = false; } else { commandVideoWebPreview.PublishCompleted = true; } }
/// <summary> /// Gets the status of a video. In the event the video is already published 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 completed if (publisher == null) { StopProgress(false); return(VideoPublishStatus.Completed.ToString()); } // Check to see the status and if it is completed 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); }