/// <summary> /// Searches the specified movie name. /// </summary> /// <typeparam name="TVideo">The type of the t video type.</typeparam> /// <param name="movieName">Name of the movie.</param> /// <returns>List<TVideoType>.</returns> public VideoCollection <TVideo> Search <TVideo>(string movieName) where TVideo : Video, new() { var videoType = typeof(TVideo); var searchPath = videoType.GetCustomAttribute <SearchPathAttribute>()?.Path; if (string.IsNullOrWhiteSpace(searchPath)) { throw new Exception($@"The video type {videoType.Name} does not have a search path."); } var videos = new VideoCollection <TVideo>(); var pageNumber = 1; while (true) { var requestQueries = new RequestQueryCollection { this.APIRequestQuery, new RequestQuery(@"query", movieName), new RequestQuery(@"page", pageNumber.ToString()), new RequestQuery(@"include_adult", bool.TrueString.ToLower()) }; var request = RequestManager.CreateRequest(RequestMethod.GET, $@"search/{searchPath}", requestQueries); var response = RequestManager.GetResponse <SearchResponse <TVideo> >(request); videos.AddRange(response.Results); if (pageNumber >= response.TotalPages || response.Results.Count == 0) { break; } pageNumber++; } return(videos); }
public static void RenderImageAsync(VideoCollection videoCollection, BarcodeConfig file, IProgress <ProgressWrapper> progress, CancellationToken cancellationToken) { if (File.Exists(file.Barcode_Standard.FullOutputFile)) { _logger = LogManager.GetCurrentClassLogger(); _logger.Warn($"Image {file.Barcode_Standard.FullOutputFile} already exists, skipping image creation"); return; } var bmp = new Bitmap(file.OutputWidth, file.OutputHeight); using (Graphics graph = Graphics.FromImage(bmp)) { double frame = 0; double frameJump = videoCollection.Data.Colours.Count / (double)file.OutputWidth; for (var i = 0; i < file.OutputWidth; i++) { cancellationToken.ThrowIfCancellationRequested(); frame = frame + frameJump; Rectangle imageSize = new Rectangle(i, 0, i, file.OutputHeight); graph.FillRectangle(new SolidBrush(ColorTranslator.FromHtml(videoCollection.Data.Colours.First(c => c.Frame == Convert.ToInt32(frame)).Hex)), imageSize); progress.Report(new ProgressWrapper(file.OutputWidth, i + 1, ProcessType.RenderImage)); } } bmp.Save(file.Barcode_Standard.FullOutputFile, ImageFormat.Jpeg); }
public void MediaPlayerAction(MetaData metaData, LaunchControl action) { VideoDetails videoOrPptDetails = VideoCollection.Find(x => x.Id == metaData.VideoId); if (videoOrPptDetails != null) { switch (action) { case LaunchControl.Launch: case LaunchControl.Play: mediaPlayer.PlayVideo(videoOrPptDetails); break; case LaunchControl.PlayAfterPause: mediaPlayer.PlayAfterPauseVideo(); break; case LaunchControl.Pause: mediaPlayer.PauseVideo(); break; case LaunchControl.Stop: mediaPlayer.StopVideo(); break; } } else { MessageBox.Show("Media Not Found"); } }
public int CreateVideo(int profileid, string filename, string filepath) { var videocontext = _theContext.Video; var videocollectioncontext = _theContext.VideoCollections; var timestamp = DateTime.Now; var videoitem = new Video { VideoFormat = "mp4", VideoTitle = filename, CreationDate = timestamp, VideoLength = DateTime.Now, VideoFilePath = filepath, }; videocontext.Add(videoitem); _theContext.SaveChanges(); var newvideo = _theContext.Video.Where(s => s.CreationDate == timestamp).FirstOrDefault <Video>(); var VideoCollection = new VideoCollection { ProfileID = profileid, VideoID = newvideo.VideoID, CreativePurpose = "Statement" }; videocollectioncontext.Add(VideoCollection); _theContext.SaveChanges(); return(newvideo.VideoID); }
public static VideoCollection BuildColourListAsync(VideoCollection videoCollection, SettingsWrapper settings, IProgress <ProgressWrapper> progress, CancellationToken cancellationToken) { Directory.CreateDirectory(videoCollection.Config.ImageDirectory); //initialise colour and image lists otherwise they just keep growing videoCollection.Data.Images = new List <VideoImage>(); videoCollection.Data.Colours = new List <VideoColour>(); for (int i = 1; i <= videoCollection.Config.Duration; i++) { cancellationToken.ThrowIfCancellationRequested(); var image = $"frame.{i}.jpg"; var hex = ImageProcessor.GetAverageHtmlColourFromImageStreamUsingScale(i, image, videoCollection, settings); // nreco can fail on the last frame, unsure why at the moment. Maybe duration & frame count mismatch? if (hex != null) { videoCollection.Data.Images.Add(new VideoImage { Frame = i, Name = image }); videoCollection.Data.Colours.Add(new VideoColour { Frame = i, Hex = hex }); } progress.Report(new ProgressWrapper(videoCollection.Config.Duration, i, ProcessType.BuildColourList)); } return(videoCollection); }
private void SubscribedMessage(Speech.Speech spokenText) { switch (spokenText.TextSpoken) { case "Thank you Dodo": Speech.SpeechSynthezier speechSynthezier = new Speech.SpeechSynthezier(); speechSynthezier.Speak("Your welcome and thanks to giving me this oppurtunity"); VideoDetails videoDetails = VideoCollection.Find(x => x.Id == 13); System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); }); break; //case "Pause the Video Dodo": // System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { // PauseVideo(); // }); // break; //case "Continue video Dodo": // System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { // PlayAfterPauseVideo(); // }); // break; //case "Start gaurdx presentation": // System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { // PptDetails details = PptCollection.Find(x => x.Id == 3); // PptAction(details); // }); // break; //case "Backward video": // System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { // PositionBackVideo(); // }); // break; //case "Previous Slide Dodo": // System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { // if (objPresSet != null) // { // if (objPresSet.Count > 0) // { // objPres.SlideShowWindow.View.Previous(); // } // } // }); // break; //case "Stop video": // System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { // StopVideo(); // }); // break; } }
public string Collection(VideoCollection vi)//收藏视频 { int Vi_id = Convert.ToInt32(Request["vid"]); int User_id = Convert.ToInt32(Session["userid"]); var vi1 = db.VideoCollection.Where(o => o.User_id == User_id).Where(o => o.Video_id == Vi_id).FirstOrDefault(); var vi2 = db.Video.Where(p => p.Video_id == Vi_id).FirstOrDefault(); if (Session["userid"] != null) { if (ModelState.IsValid) { if (vi1 == null) { vi.User_id = User_id; vi.Video_id = Vi_id; vi.State = 1; db.VideoCollection.Add(vi); db.SaveChanges(); vi2.Collection = vi2.Collection + 1; db.SaveChanges(); return("success"); } if (vi1.State == 1) { vi1.State = 0; db.SaveChanges(); vi2.Collection = vi2.Collection - 1; db.SaveChanges(); return("cancel"); } if (vi1.State == 0) { vi1.State = 1; db.SaveChanges(); vi2.Collection = vi2.Collection + 1; db.SaveChanges(); return("success"); } else { return(""); } } else { return(""); } } else { return("login");; } }
public override void KhoiTao(SqlConnection con, Page page) { var sb = new StringBuilder(); var sbItems = new StringBuilder(); var cs = page.ClientScript; var c = HttpContext.Current; var _id = c.Request["VID"]; var itemFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "VideoClip.item.htm"); var viewFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "VideoClip.view.htm"); Video Item = new Video(); VideoCollection List = new VideoCollection(); if (!string.IsNullOrEmpty(_id)) { #region Xem chi tiết Video Item = VideoDal.SelectById(Convert.ToInt32(_id)); List = VideoDal.SelectByIdList(_id, 10); #endregion } else { #region Mặc định List = VideoDal.SelectHot(50); if (List.Count > 0) { Item = List[0]; } #endregion } if (List.Count > 0) { if (List.Count > 1) { sbItems.Append(@"<div class=""video-lienQuan-box"">"); foreach (Video item in List) { if (item.ID != Item.ID) { sbItems.AppendFormat(itemFormat, domain, item.ID, item.Anh, item.Ten, Lib.Bodau(item.Ten)); } } sbItems.Append(@"</div>"); } sb.AppendFormat(viewFormat, Item.Ten, Item.MoTa, Item.YID, domain, sbItems); } Html = sb.ToString(); base.KhoiTao(con); }
public void SetOutputImagesFullDirectory(VideoCollection videoCollection) { Barcode_Standard = new OutputImage { OutputFilename = $"{videoCollection.Config.FilenameWithoutExtension}_{OutputWidth}_{OutputHeight}.jpg" }; Barcode_1px = new OutputImage { OutputFilename = $"{videoCollection.Config.FilenameWithoutExtension}_1px_{OutputWidth}_{OutputHeight}.jpg" }; Barcode_Standard.SetFullOutputFile(videoCollection); Barcode_1px.SetFullOutputFile(videoCollection); }
private void powerpnt_SlideShowEnd(powerpointinterop.Presentation Wn) { Wn.Close(); VideoDetails videoDetails = null; switch (pptDetailsMain.Id) { case 1: //azad exit and rpa video start videoDetails = VideoCollection.Find(x => x.Id == 2); System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); }); break; case 2: //rpa video videoDetails = VideoCollection.Find(x => x.Id == 3); System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); }); break; case 3: //market data entry bot videoDetails = VideoCollection.Find(x => x.Id == 6); System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); }); break; case 4: //market data ppt end videoDetails = VideoCollection.Find(x => x.Id == 7); System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); }); break; case 5: //market data ends and //tech video start videoDetails = VideoCollection.Find(x => x.Id == 10); System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); }); break; case 6: speechRecognize.StartListening(); subscription = EventAggregator.getInstance().Subscribe <Speech.Speech>(SubscribedMessage); break; } }
public static VideoCollection SelectAll(SqlConnection con) { VideoCollection List = new VideoCollection(); using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "tblRss_sp_tblRssVideo_Select_SelectAll_linhnx")) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public static string GetAverageHtmlColourFromImageUsingScale(int frame, VideoCollection videoCollection, SettingsWrapper settings) { SetTempDir(settings); using MagickImage image = new MagickImage(Path.Combine(videoCollection.Config.ImageDirectory, $"frame.{frame}.jpg")); image.Crop(new MagickGeometry(new Percentage(70), new Percentage(70)), Gravity.Center); image.Scale(1, 1); var color = image.GetPixels().First().ToColor(); return(ColorTranslator.ToHtml(Color.FromArgb(color.A, color.R, color.G, color.B))); }
public static VideoCollection SelectHome(SqlConnection con, int Top) { VideoCollection List = new VideoCollection(); SqlParameter[] obj = new SqlParameter[1]; obj[0] = new SqlParameter("Top", Top); using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "tblRss_sp_tblRssVideo_Select_SelectHome_linhnx", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public static VideoCollection SelectByIdList(string V_ID, int Top) { VideoCollection List = new VideoCollection(); SqlParameter[] obj = new SqlParameter[2]; obj[0] = new SqlParameter("V_ID", V_ID); obj[1] = new SqlParameter("Top", Top); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "tblRss_sp_tblRssVideo_Select_SelectByIdList_linhnx", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); string _id = Request["ID"]; Video Item = new Video(); VideoCollection List = new VideoCollection(); sb.AppendFormat(@" <ul id=""tin-view-navi-menus""> <li><a href=""{0}"" class=""tin-view-navi-menus-item home"">Trang chủ</a></li> <li><a class=""tin-view-navi-menus-item"" href=""{0}/Video/"">Video</a></li> </ul> ", domain); using (SqlConnection con = DAL.con()) { if (!string.IsNullOrEmpty(_id)) { #region Xem chi tiết Video Item = VideoDal.SelectById(Convert.ToInt32(_id)); List = VideoDal.SelectByIdList(_id, 10); #endregion } else { #region Mặc định List = VideoDal.SelectHot(50); if (List.Count > 0) { Item = List[0]; } #endregion } } if (List.Count > 0) { sb.AppendFormat(@"<div class=""video-view-item""> <div class=""video-item-ten"">{0} </div> <div class=""video-item-pnl""> <iframe width=""660"" height=""477"" src=""http://www.youtube.com/embed/{2}"" frameborder=""0"" allowfullscreen></iframe> </div> <div class=""video-item-moTa"">{1} </div> </div>", Item.Ten, Item.MoTa, Item.YID); if (List.Count > 1) { sb.Append(@"<div class=""video-lienQuan-header""> Video liên quan </div> <div class=""video-lienQuan-box"">"); foreach (Video item in List) { if (item.ID != Item.ID) { sb.AppendFormat(@"<div class=""video-lienQuan-item""> <a href=""{0}/Video/{4}/{1}.html"" class=""video-item-anhBox""> <img src=""{0}/lib/up/i/{2}"" class=""video-item-anh"" /> </a> <a href=""{0}/Video/{4}/{1}.html"" class=""video-item-ten"">{3} </a> </div>", domain, item.ID, item.Anh, item.Ten, Lib.Bodau(item.Ten)); } } sb.Append(@"</div>"); } HtmlMeta meta = new HtmlMeta(); meta.Name = "description"; meta.Content = Item.MoTa; this.Page.Header.Controls.Add(meta); this.Page.Header.Title = string.Format("{0}", Item.Ten); } txt = sb.ToString(); }
private void DodoMediaPlayer_MediaEnded(object sender, RoutedEventArgs e) { VideoDetails videoDetails = null; PptDetails pptDetails = null; this.Hide(); switch (videoDetailsMain.Id) { case 0: //intro and azadpartika start videoDetails = VideoCollection.Find(x => x.Id == 1); PlayVideo(videoDetails); break; case 1: //azad pratika ppt pptDetails = PptCollection.Find(x => x.Id == 1); PptAction(pptDetails); break; case 2: //rpa ppt pptDetails = PptCollection.Find(x => x.Id == 2); PptAction(pptDetails); break; case 3: videoDetails = VideoCollection.Find(x => x.Id == 4); PlayVideo(videoDetails); break; case 4: ////20 secs stop for lizitha //Thread.Sleep(new TimeSpan(0, 0, 20)); //start gaurdx demo video videoDetails = VideoCollection.Find(x => x.Id == 5); PlayVideo(videoDetails); PauseVideo(); break; case 5: //open gaurdx ppt //pptDetails = PptCollection.Find(x => x.Id == 3); //PptAction(pptDetails); break; case 6: //open market data ppt pptDetails = PptCollection.Find(x => x.Id == 4); PptAction(pptDetails); break; case 7: //open market video 1 ended videoDetails = VideoCollection.Find(x => x.Id == 8); PlayVideo(videoDetails); break; case 8: //open market video 2 ended videoDetails = VideoCollection.Find(x => x.Id == 9); PlayVideo(videoDetails); break; case 9: //open market data ppt part 2 pptDetails = PptCollection.Find(x => x.Id == 5); PptAction(pptDetails); break; case 10: //tech video ended q&a video start videoDetails = VideoCollection.Find(x => x.Id == 11); PlayVideo(videoDetails); break; case 11: //tech video part 2 videoDetails = VideoCollection.Find(x => x.Id == 12); PlayVideo(videoDetails); break; case 12: //tech video pptDetails = PptCollection.Find(x => x.Id == 6); PptAction(pptDetails); break; case 13: this.Close(); break; } }
public string Collection(VideoCollection vi) { if (Session["Users_id"] != null) { int Vi_id = Convert.ToInt32(Request["vid"]); int User_id = Convert.ToInt32(Session["Users_id"]); var vi1 = db.VideoCollection.Where(o => o.User_id == User_id).Where(o => o.Vi_id == Vi_id).FirstOrDefault(); if (vi1 == null) { if (ModelState.IsValid) { vi.Vi_id = Vi_id; vi.User_id = User_id; vi.State = 1; db.VideoCollection.Add(vi); db.SaveChanges(); var collection = db.Video.Find(Vi_id); collection.Collection = collection.Collection + 1; var coll = collection.Collection; db.SaveChanges(); //return Json(""); //return Content("<script>;alert('收藏成功!');</script>"); //return new EmptyResult(); return("11"); } } else { if (vi1.State == 0) { var collection = db.Video.Find(Vi_id); collection.Collection = collection.Collection + 1; var coll1 = collection.Collection; db.SaveChanges(); vi1.State = 1; db.SaveChanges(); //return Json(""); //return Content("<script>;alert('收藏成功!');</script>"); //return new EmptyResult(); return("22"); } if (vi1.State == 1) { var collection = db.Video.Find(Vi_id); collection.Collection = collection.Collection - 1; var coll2 = collection.Collection; db.SaveChanges(); vi1.State = 0; db.SaveChanges(); //return Content("<script>;alert('取消收藏成功!');</script>"); //return Json(""); //return new EmptyResult(); return("33"); } } } else { return("55");; } //return RedirectToAction("Details", "Video"); return("44"); }
public static string GetAverageHtmlColourFromImageStreamUsingScale(int frameTime, string file, VideoCollection videoCollection, SettingsWrapper settings) { SetTempDir(settings); using MemoryStream ms = new MemoryStream(); new NReco.VideoConverter.FFMpegConverter().GetVideoThumbnail(videoCollection.Config.FullPath, ms, frameTime); if (ms.Length == 0) { return(null); } Image.FromStream(ms).Save(Path.Combine(videoCollection.Config.ImageDirectory, file), ImageFormat.Jpeg); ms.Seek(0, SeekOrigin.Begin); using MagickImage image = new MagickImage(ms, new MagickReadSettings { Format = MagickFormat.Jpeg }); image.Crop(new MagickGeometry(new Percentage(70), new Percentage(70)), Gravity.Center); image.Scale(1, 1); IMagickColor <byte> color = image.GetPixels().First().ToColor(); return(ColorTranslator.ToHtml(Color.FromArgb(color.A, color.R, color.G, color.B))); }
public static void BuildAndRenderImageCompressedToOnePixelWideImageAsync(VideoCollection videoCollection, BarcodeConfig file, SettingsWrapper settings, IProgress <ProgressWrapper> progress, CancellationToken cancellationToken) { SetTempDir(settings); const int partDivider = 1000; Directory.CreateDirectory(videoCollection.Config.OnePixelImageDirectory); if (File.Exists(file.Barcode_1px.FullOutputFile)) { _logger = LogManager.GetCurrentClassLogger(); _logger.Warn($"Image {file.Barcode_1px.FullOutputFile} already exists, skipping image creation"); return; } // get any image files now to save querying the file system for every image string[] imageFiles = Directory.GetFiles(videoCollection.Config.OnePixelImageDirectory); List <string> imageParts = new List <string>(); using MagickImageCollection images = new MagickImageCollection(); int geo = 0; for (var i = 0; i < videoCollection.Data.Images.Count; i++) { var frame = videoCollection.Data.Images[i]; cancellationToken.ThrowIfCancellationRequested(); // Resize the image to the output height, if required // Add page to define the image's location in the mosaic // Clone the image add add to the mosaic input list void ResizeAndClone(MagickImage image) { if (image.Height != file.OutputHeight) { image.Resize(new MagickGeometry(1, file.OutputHeight) { IgnoreAspectRatio = true }); } image.Page = new MagickGeometry(geo, 0, 0, 0); images.Add(image.Clone()); } if (imageFiles.All(f => f != frame.Name)) { using MagickImage image = new MagickImage(Path.Combine(videoCollection.Config.ImageDirectory, frame.Name)); // Resize the image to a fixed size without maintaining the aspect ratio (normally an image will be resized to fit inside the specified size) // These frames will be created to the same height as the original image image.Resize(new MagickGeometry(1, image.Height) { IgnoreAspectRatio = true }); image.Write(Path.Combine(videoCollection.Config.OnePixelImageDirectory, frame.Name)); ResizeAndClone(image); } else // get the image from the file system { using MagickImage image = new MagickImage(Path.Combine(videoCollection.Config.OnePixelImageDirectory, frame.Name)); ResizeAndClone(image); } geo++; // split out and write partitioned images every 1000 frames to prevent ImageMagick's 'too many open files' fuckery if (i % partDivider == 0 && i != 0) { var part = Path.Combine(settings.CoreSettings.MagickImageTempDir, $"{Guid.NewGuid()}.jpg"); using (IMagickImage result = images.Mosaic()) { result.Write(part); } images.Clear(); imageParts.Add(part); geo = 0; } progress.Report(new ProgressWrapper(videoCollection.Data.Images.Count, frame.Frame, ProcessType.RenderImageCompressedToOnePixelWide)); } // create the last, smaller than 1000 px part var lastPart = Path.Combine(settings.CoreSettings.MagickImageTempDir, $"{Guid.NewGuid()}.jpg"); using (IMagickImage result = images.Mosaic()) { result.Write(lastPart); } images.Clear(); imageParts.Add(lastPart); // add all the parts to the image collection geo = 0; foreach (var imagePart in imageParts) { using (MagickImage image = new MagickImage(imagePart)) { image.Page = new MagickGeometry(geo, 0, 0, 0); images.Add(image.Clone()); } geo = geo + partDivider; File.Delete(imagePart); } // lets do some f*****g barcode magic using (IMagickImage result = images.Mosaic()) { result.Write(file.Barcode_1px.FullOutputFile); } }