public ActionResult AddVideo(VideoDTO model) { //<iframe width="560" height="315" src="https://www.youtube.com/embed/E7Voso411Vs" frameborder="0" allowfullscreen></iframe> //https://www.youtube.com/watch?v=E7Voso411Vs&ab_channel=ProgrammingwithMosh if (ModelState.IsValid) { string path = model.OriginalVideoPath.Substring(32); string mergeLink = "https://www.youtube.com/embed/"; mergeLink += path; model.VideoPath = string.Format(@"<iframe width=""300"" height=""200"" src=""{0}"" frameborder=""0"" allowfullscreen></iframe>", mergeLink); if (bll.AddVideo(model)) { ViewBag.ProcessState = General.Messages.AddSuccess; ModelState.Clear(); model = new VideoDTO(); } else { ViewBag.ProcessState = General.Messages.GeneralError; } } else { ViewBag.ProcessState = General.Messages.EmptyArea; } return(View(model)); }
public ActionResult AddVideo(VideoDTO model) { // VideoPath: < iframe width = "560" height = "315" src = "https://www.youtube.com/embed/DUg2SWWK18I" title = "YouTube video player" frameborder = "0" allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen ></ iframe > // OriginalVideoPath: https://www.youtube.com/watch?v=DUg2SWWK18I if (ModelState.IsValid) { string path = model.OriginalVideoPath.Substring(32); // DUg2SWWK18I string mergeLink = "https://www.youtube.com/embed/"; mergeLink += path; model.VideoPath = String.Format(@"<iframe width = ""350"" height = ""200"" src = ""{0}"" frameborder = ""0"" allowfullscreen ></iframe>", mergeLink); if (bll.AddVideo(model)) { ViewBag.ProcessState = General.Messages.AddSuccess; ModelState.Clear(); model = new VideoDTO(); } else { ViewBag.ProcessState = General.Messages.GeneralError; } } else { ViewBag.ProcessState = General.Messages.EmptyArea; } return(View(model)); }
public static async Task <object> yt_proc(ApplicationDbContext context, List <SaveVideoInfo> data) { foreach (var _rec in data) { _rec.isenabled = 1; // by default enabled // update entity values _rec.videofilename = ""; _rec.thumbfilename = ""; _rec.originalvideofilename = ""; _rec.pub_url = ""; _rec.thumb_url = _rec.preview_url; _rec.org_url = ""; _rec.isexternal = 1; _rec.youtubeid = _rec.youtubeid; _rec.ispublished = 1; _rec.embed_script = ""; await VideoBLL.AddVideo(context, _rec); } return(new { status = "success", message = "Record processed successfully" }); }
protected void BtnSvae_Click(object sender, EventArgs e) { VideoBLL bll = new VideoBLL(); VideoInfo Video = new VideoInfo(); Video.Title = Tz888.Common.Utility.PageValidate.HtmlEncode(txtTitle.Value.Trim()); Video.ImgUrl = Tz888.Common.Utility.PageValidate.HtmlEncode(txtImgUrl.Value.Trim()); Video.VodeoUrl = Tz888.Common.Utility.PageValidate.HtmlEncode(txtVideoUrl.Value.Trim()); Video.VideoType = Convert.ToInt32(DropVideoType.SelectedValue.Trim()); Video.Type = Convert.ToInt32(Dropzhuanti.SelectedValue); Video.IsRecommend = Convert.ToInt32(RadioRecommend.SelectedValue.Trim()); Video.ShowId = Convert.ToInt32(DropShowPosition.SelectedValue.Trim()); Video.SortId = (txtSort.Value.Trim() == "") ? 0 : Convert.ToInt32(txtSort.Value.Trim()); Video.Remarks = Tz888.Common.Utility.PageValidate.HtmlEncode(txtRemarks.Value.Trim()); if (bll.AddVideo(Video)) { Tz888.Common.MessageBox.ShowAndRedirect(this.Page, "添加成功!", "VideoList.aspx", false); } else { Tz888.Common.MessageBox.Show(this.Page, "添加失败!"); } }
public static async Task <object> direct_proc(ApplicationDbContext context, List <SaveVideoInfo> data) { foreach (var _rec in data) { var _counter = 1; foreach (var thumb in _rec.video_thumbs) { var _prefix = "00"; if (_counter <= 9) { _prefix = "00"; } else if (_counter <= 99) { _prefix = "0"; } else { _prefix = ""; } /* save base64 image in physical path */ byte[] image = Convert.FromBase64String(thumb.filename.Replace("data:image/png;base64,", "")); string thumbFileName = _rec.videofilename.Remove(_rec.videofilename.LastIndexOf(".")) + "_" + _prefix + "" + _counter + ".png"; _counter++; string path = VideoUrlConfig.Thumbs_Path(_rec.userid) + "/" + thumbFileName; if (File.Exists(path)) { File.Delete(path); } File.WriteAllBytes(path, image); if (thumb.selected) { _rec.thumbfilename = thumbFileName; } _rec.tfile = _rec.thumbfilename; } var PubPrefix = Guid.NewGuid().ToString().Substring(0, 12) + "-"; // avoid duplication in cloud try { // in case of direct uploader, there is no published video, source video is published. // shift source video to published directory var SourcePath = VideoUrlConfig.Source_Video_Path(_rec.userid); // no source video there var publishedPath = VideoUrlConfig.Published_Video_Path(_rec.userid); var thumbsPath = VideoUrlConfig.Thumbs_Path(_rec.userid); if (File.Exists(publishedPath + "/" + _rec.videofilename)) { File.Delete(publishedPath + "/" + _rec.videofilename); } File.Move(SourcePath + "/" + _rec.videofilename, publishedPath + "/" + _rec.videofilename); if (Jugnoon.Settings.Configs.AwsSettings.enable) { if (Configs.AwsSettings.bucket != "") { //var previewVideoUrl = ""; // not yet added in this version var _arr = new ArrayList(); _arr.Add(_rec.videofilename); if (_rec.thumbfilename != null) { var _thumbFileName = _rec.thumbfilename; if (_thumbFileName.Contains("_")) { _thumbFileName = _thumbFileName.Remove(_thumbFileName.LastIndexOf("_")); } else { _thumbFileName = _thumbFileName.Replace(".jpg", ""); } } // string status = MediaCloudStorage.UploadMediaFiles("", "", publishedPath, _arr, PubPrefix, thumbsPath, _thumbFileName, _rec.thumbs.Count(), "", _rec.userid, ".png"); // thumb is not provided, just sent via thumb_url in this version string status = MediaCloudStorage.UploadMediaFiles("", "", publishedPath, _arr, PubPrefix, "", "", 0, "", _rec.userid, ".png"); if (status == "PubFailed" || status == "ThumbFailed") { ErrorLgBLL.Add(context, "Error Uploading to Cloud", "", "Error Code 1009, message: storing content to cloud failed"); } } else { ErrorLgBLL.Add(context, "Error Uploading to Cloud", "", "Cloud Storage Enabled But No Cloud Storage Settings Available"); } } } catch (Exception ex) { var err = ex.Message; } var cloud_url = Url.prepareUrl(_rec.userid); // update entity values _rec.videofilename = _rec.videofilename; _rec.thumbfilename = _rec.tfile; _rec.originalvideofilename = _rec.sf; _rec.pub_url = cloud_url.publish_filename + PubPrefix + _rec.videofilename; _rec.thumb_url = _rec.thumb_url; // cloud_url.thumb_filename + _rec.thumbfilename; _rec.org_url = ""; _rec.isexternal = 0; _rec.youtubeid = ""; _rec.ispublished = 1; _rec.embed_script = ""; await VideoBLL.AddVideo(context, _rec); } return(new { status = "success", message = "Record processed successfully" }); }
public static async Task <object> ffmpeg_proc(ApplicationDbContext context, List <SaveVideoInfo> data) { foreach (var _rec in data) { var _ref_filename = ""; var _SelectedIndex = ""; foreach (var thumb in _rec.video_thumbs) { if (thumb.selected) { if (Jugnoon.Settings.Configs.AwsSettings.enable) { _rec.thumbfilename = Path.GetFileName(thumb.filename).Remove(Path.GetFileName(thumb.filename).LastIndexOf("_")) + "/img" + thumb.filename.Remove(0, thumb.filename.LastIndexOf("_")); // _rec.thumbfilename = Path.GetFileNameWithoutExtension(thumb.filename) + "/img_" + thumb.filename.Remove(0, thumb.filename.LastIndexOf("_")); } else { _rec.thumbfilename = Path.GetFileName(thumb.filename); } _ref_filename = Path.GetFileName(thumb.filename); _SelectedIndex = thumb.fileIndex; _rec.thumb_url = thumb.filename; } } var _thumbFile = ""; var PubPrefix = Guid.NewGuid().ToString().Substring(0, 12) + "-"; // avoid duplication in cloud try { if (Jugnoon.Settings.Configs.AwsSettings.enable) { if (Configs.AwsSettings.bucket != "") { var SourcePath = VideoUrlConfig.Source_Video_Path(_rec.userid); var publishedPath = VideoUrlConfig.Published_Video_Path(_rec.userid); var thumbsPath = VideoUrlConfig.Thumbs_Path(_rec.userid); var previewVideoUrl = ""; // not yet added in this version var _arr = new ArrayList(); _arr.Add(_rec.pf); var _thumbFileName = _ref_filename; if (_thumbFileName.Contains("_")) { _thumbFileName = _thumbFileName.Remove(_thumbFileName.LastIndexOf("_")); } else { _thumbFileName = _thumbFileName.Replace(".jpg", ""); } // add key to avoid duplication thumbsPath = thumbsPath + "\\" + _thumbFileName + "_"; _thumbFileName = PubPrefix + "-" + _thumbFileName; var ext = Path.GetExtension(_ref_filename); _thumbFile = _thumbFileName + "/" + _SelectedIndex + ext; // "img_008" + ext; string status = MediaCloudStorage.UploadMediaFiles(SourcePath, _rec.sf, publishedPath, _arr, PubPrefix, thumbsPath, _thumbFileName, 15, previewVideoUrl, _rec.userid, Path.GetExtension(ext)); if (status == "PubFailed" || status == "ThumbFailed") { ErrorLgBLL.Add(context, "Error Uploading to Cloud", "", "Error Code 1009, message: storing content to cloud failed"); } } else { ErrorLgBLL.Add(context, "Error Uploading to Cloud", "", "Cloud Storage Enabled But No Cloud Storage Settings Available"); } } } catch (Exception ex) { var err = ex.Message; } var cloud_url = Url.prepareUrl(_rec.userid); // update entity values _rec.videofilename = _rec.pf; _rec.thumbfilename = Path.GetFileName(_rec.tfile); _rec.originalvideofilename = _rec.sf; _rec.pub_url = cloud_url.publish_filename + PubPrefix + _rec.pf; _rec.thumb_url = cloud_url.thumb_filename + _thumbFile; _rec.org_url = cloud_url.publish_filename + _rec.sf; _rec.preview_url = ""; _rec.isexternal = 0; _rec.youtubeid = ""; _rec.ispublished = 1; _rec.embed_script = ""; await VideoBLL.AddVideo(context, _rec); } return(new { status = "success", message = "Record processed successfully" }); }
public static async Task <object> aws_proc(ApplicationDbContext context, List <SaveVideoInfo> data) { if (Jugnoon.Settings.Configs.AwsSettings.enable) { if (Configs.AwsSettings.bucket != "") { try { foreach (var _rec in data) { _rec.isenabled = 1; // by default enabled if (Jugnoon.Settings.Configs.GeneralSettings.content_approval == 1) { _rec.isapproved = 1; } else { _rec.isapproved = 0; } var SourcePath = VideoUrlConfig.Source_Video_Path(_rec.userid); // no source video there if (File.Exists(SourcePath + "/" + _rec.sf)) { string source_key_prefix = Jugnoon.Videos.Configs.AwsSettings.elastic_transcoder_directory + "" + Guid.NewGuid().ToString().Substring(0, 10); _rec.originalvideofilename = source_key_prefix + "-" + UtilityBLL.ReplaceSpaceWithHyphin_v2(_rec.sf); // Save unpublished video data in database first before uploading file to aws // update entity values _rec.videofilename = ""; _rec.thumbfilename = ""; _rec.pub_url = ""; _rec.thumb_url = ""; _rec.org_url = ""; _rec.isexternal = 0; _rec.youtubeid = ""; _rec.ispublished = 0; _rec.embed_script = ""; await VideoBLL.AddVideo(context, _rec); string status = MediaCloudStorage.UploadMediaFiles_Elastic(SourcePath, _rec.sf, _rec.originalvideofilename, _rec.userid); if (status == "OrgFailed") { ErrorLgBLL.Add(context, "Error Uploading to Cloud", "", "Error Code 1009, message: storing content to cloud failed"); } } else { ErrorLgBLL.Add(context, "Cloud Upload Error", "", "File Not Exist " + SourcePath + "/" + _rec.sf); } } } catch (Exception ex) { ErrorLgBLL.Add(context, "Upload Video Error", "", ex.Message); } } } return(new { status = "success", message = "Record processed successfully" }); }