public static DataAccessAction <VideoReference> CreateVideoReference(VideoReference video) { return(new DataAccessAction <VideoReference>((IDbConnection conn) => { video.Validate(); video.Id = conn.GetNextId <VideoReference>(); conn.Insert(video); return video; })); }
private void SetSource(VideoReference source) { source.Get(Context, (res) => { if (res == null) { VideoPlayer.clip = null; VideoPlayer.url = null; VideoPlayer.source = VideoSource.Url; } else { VideoPlayer.clip = res.Clip; VideoPlayer.url = res.Url; VideoPlayer.source = res.Type; } }); }
public VideoMetadata StartReadingVideo(int projectId, int projectDeviceId) { var project = dispatcher.Dispatch(ProjectActions.GetProject(projectId)); Guard.This(project).AgainstDefaultValue(string.Format("Could not find project with project id '{0}'", projectId)); var video = dispatcher.Dispatch(VideoActions.GetVideoForProject(projectId)); Guard.This(video).AgainstDefaultValue(string.Format("Could not find video for project '{0}' (id '{1}')", project.Name, project.Id)); var projectDeviceVersion = dispatcher.Dispatch(ProjectDeviceActions.GetLatestProjectDeviceVersion(projectDeviceId)); Guard.This(projectDeviceVersion).AgainstDefaultValue(string.Format("Could not get latest project device version for project '{0}' (id '{1}')", project.Name, project.Id)); reader = videoFileReader(); reader.Open(video.FilePath); framesRead = 0; framesToRead = reader.FrameCount; this.videoReference = video; this.projectDeviceVersion = projectDeviceVersion; return(new VideoMetadata(reader.FrameCount, reader.FrameRate)); }
protected void relatedVideos_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //get the ImageReference object that is bound to the current row. VideoReference videoDetails = (VideoReference)e.Item.DataItem; if (videoDetails != null) { // Set the CSS class for the video's containing figure element. HtmlGenericControl container = (HtmlGenericControl)e.Item.FindControl("videoContainer"); if (container != null) { // These are the templates allowed by the CDR's DTD for GlossaryTerm Embedded videos. // Others do exist in Percussion, but are deprecated per OCECDR-3558. switch (videoDetails.Template.ToLowerInvariant()) { case "video100notitle": case "video100title": container.Attributes.Add("class", "video center size100"); break; case "video50notitle": container.Attributes.Add("class", "video center size50"); break; case "video50notitleright": case "video50titleright": container.Attributes.Add("class", "video right size50"); break; case "video75notitle": case "video75title": container.Attributes.Add("class", "video center size75"); break; default: log.ErrorFormat("Unknown video template '{0}'.", videoDetails.Template); container.Attributes.Add("class", "video center size100"); break; } } // Set up the title display. // Requires a title be present, and not using one of the "NoTitle" templates. if (!String.IsNullOrWhiteSpace(videoDetails.Title) && !videoDetails.Template.ToLowerInvariant().Contains("notitle")) { HtmlGenericControl title = (HtmlGenericControl)e.Item.FindControl("videoTitle"); if (title != null) { title.Visible = true; title.InnerText = videoDetails.Title; } } // Display the caption HtmlGenericControl caption = (HtmlGenericControl)e.Item.FindControl("captionContainer"); if (caption != null && !String.IsNullOrWhiteSpace(videoDetails.Caption)) { caption.Visible = true; caption.InnerHtml = videoDetails.Caption; } } } }
/// <summary> /// Gets the videos associated with this title (video gallery). /// </summary> /// <param name="session">The session.</param> /// <param name="imdbID">The imdb ID.</param> /// <remarks>uses web scraping</remarks> /// <returns></returns> public static List <VideoReference> GetVideos(Session session, string imdbID) { List <VideoReference> videos = new List <VideoReference>(); string data = session.MakeRequest(string.Format(session.Settings.VideoGallery, imdbID)); HtmlNode root = Utility.ToHtmlNode(data); if (root != null) { var nodes = root.SelectNodes("//div[contains(@class, 'results-item')]"); string movieTitle = root.SelectSingleNode("//h3/a").InnerText; if (nodes != null) { foreach (HtmlNode node in nodes) { HtmlNode imgNode = node.SelectSingleNode("a/img"); if (imgNode == null) { continue; } string href = node.SelectSingleNode("h2/a").GetAttributeValue("href", ""); if (href.Contains("/imdblink/")) { continue; // link to an external trailer } string videoTitle = node.SelectSingleNode("h2/a").InnerText; if (videoTitle.ToLower().Trim() == movieTitle.ToLower().Trim()) { // if the title is the same as the movie title try the image's title var title2 = imgNode.GetAttributeValue("title", ""); if (title2 != "") { videoTitle = title2; } } // clean up the video title int i = videoTitle.IndexOf(" -- "); if (i >= 0) { videoTitle = videoTitle.Substring(i + 4); } videoTitle = videoTitle.Replace(movieTitle + ":", string.Empty).Trim(); VideoReference video = new VideoReference(); video.session = session; video.Image = imgNode.GetAttributeValue("src", ""); video.ID = imgNode.Attributes["viconst"].Value; video.Title = HttpUtility.HtmlDecode(videoTitle); videos.Add(video); } } } return(videos); }