//get the video frames public async Task <Tuple <string, VideoModel> > GetVideoFrames(string video) { VideoModel videoModel = new VideoModel(); //first get the video frames HttpClient client = httpClientFactory.CreateClient(); client.BaseAddress = new Uri("http://localhost:58492/"); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage message = await client.PostAsJsonAsync("api/Frames/getVideoFrames", video); if (message.IsSuccessStatusCode) { string result = message.Content.ReadAsStringAsync().Result; videoModel = JsonConvert.DeserializeObject <VideoModel>(result); Tuple <string, VideoModel> tuple = new Tuple <string, VideoModel>("ok", videoModel); return(tuple); } else { string result = message.Content.ReadAsStringAsync().Result; Tuple <string, VideoModel> tuple = new Tuple <string, VideoModel>(result, null); return(tuple); } }
public bool AddItem(VideoModel video) { var allVideos = All(); if (allVideos.Contains(video)) { // video already saved return(false); } if (!allVideos.Any()) // no videos have been saved yet { var jsonValues = new JsonValue[] { video.JsonValue }; var jsonArray = new JsonArray(jsonValues); Preferences.Set(PreferencesKey, jsonArray.ToString()); return(true); } // otherwise a favorites array of videos already exist in preferences, // so just add to it. var result = Preferences.Get(PreferencesKey, string.Empty); var jsonValue = JsonValue.Parse(result); var videosArray = jsonValue as JsonArray; videosArray.Add(video.JsonValue); Preferences.Set(PreferencesKey, videosArray.ToString()); return(true); }
/// <summary> /// Add links to a video /// </summary> /// <param name="videoModel">the video object</param> /// <param name="uname">username</param> /// <returns>the video after adding links</returns> private VideoModel AddLinks(VideoModel videoModel, string uname) { if (videoModel == null) { return(null); } videoModel.links.Add(new Link { link = Url.Link("GetUserByUsername", new { username = uname }), Method = "GET", Rel = "User" }); videoModel.links.Add(new Link { link = Url.Link("GetVideos", new { username = uname }), Method = "GET", Rel = "Self" }); videoModel.links.Add(new Link { link = Url.Link("GetTags", new { videoLink = videoModel.VideoLink, user = uname }), Method = "GET", Rel = "Tags" }); videoModel.links.Add(new Link { link = Url.Link("AddTags", new { videoLink = videoModel.VideoLink, user = uname }), Method = "POST", Rel = "Tags" }); videoModel.links.Add(new Link { link = Url.Link("GetPlaylist", new { videoLink = videoModel.VideoLink, user = uname }), Method = "GET", Rel = "Playlists" }); return(videoModel); }
public static VideoModel convertENToModelUI(VideoEN videoEN) { VideoModel v = new VideoModel(); v.Titulo = videoEN.Titulo; v.Id = videoEN.Id; v.Descripcion = videoEN.Descripcion; //v.Etiquetas = videoEN.Etiquetas; v.Usuario = videoEN.Usuario.Nick; try { string parseDate = videoEN.Fecha_subida.ToString(); string[] fecha = parseDate.Split(' '); v.Fecha_subida = fecha[0]; } catch { v.Fecha_subida = "No hay fecha"; } v.Miniatura = videoEN.Miniatura; v.Url = videoEN.Url; v.Texto = ""; v.Valor = 0; v.Email = videoEN.Usuario.Email; return(v); }
// All Video For Special Word private void All_KinnectVideos_Click(object sender, RoutedEventArgs e) { Button b = (sender) as Button; if (b.CommandParameter != null) { VideoModel fea = video.GetVideoByWord(int.Parse(b.CommandParameter.ToString()), 1 /*wordtyped*/); DbModel.DomainClasses.Entities.Words wor = word.GetWordsEntityById(int.Parse(b.CommandParameter.ToString())); if (fea == null) { fea = new VideoModel(); fea.Words = wor; var addWindow = new AllVideo_SpecialKinnect(/*fea,*/ wor.word_id, UtilityClass.WordTypeToInt(wor.WordType) /*wordtyped*/); addWindow.Show(); } else { var addWindow = new AllVideo_SpecialKinnect(/*fea,*/ wor.word_id, UtilityClass.WordTypeToInt(wor.WordType) /*wordtyped*/); addWindow.Show(); } } clickVideos = true; this.Close(); }
public ActionResult AddVideo(VideoModel model) { if (model == null) { throw new ArgumentNullException("model"); } TestBlog(model.BlogId); if (String.IsNullOrEmpty(model.Url)) { return(View(model)); } else if (!Regex.Match(model.Url, @".+youtube\..+", RegexOptions.IgnoreCase).Success) { return(View(model)); } String youtubeID = GetYouTubeID(model.Url); if (youtubeID == null) { ModelState.AddModelError("Url", "Le lien est invalide."); return(View(model)); } InsertArticleInBDD(model.BlogId, youtubeID, (long)Tools.MediaTypes.Video, model.Caption, model.Tags); return(RedirectToAction("BlogManagement", "User", new { id = model.BlogId })); }
private async Task PlayVideo(VideoModel model) { if (model.path != null) { PlayLocalOld(model); return; } progress.Visibility = Visibility.Visible; top_Title.Text = model.title + " " + model.page; pro_Num.Text = "填充弹幕中..."; Cid = model.cid; Aid = model.aid; if (sql.ValuesExists(Cid)) { menu_LastPost.IsEnabled = true; LastPost = sql.QueryValue(Cid); } else { menu_LastPost.IsEnabled = false; sql.InsertValue(Cid); } lastPostVIs = false; DanMuPool = await GetDM(model.cid, false, false, string.Empty); pro_Num.Text = "读取视频信息..."; await GetPlayInfo(model.cid, top_cb_Quality.SelectedIndex + 1); }
public void GetVideoEmbedUrl_ProvidedVariousVideoKinds_GetCorrectVideoFormat(VideoKindEnum kind, string embedUrlPrefix) { var model = new VideoModel("foo", "123456", kind); string actualEmbedUrl = VideoHelper.GetVideoEmbedUrl(model); Assert.That(actualEmbedUrl, Does.StartWith(embedUrlPrefix)); }
public ActionResult ViewPortal() { var model = new List <VideoModel>(); // var dal = new Repository(); //var videos = db.Videos.OrderByDescending(p => p.Id).ToList().Take(2); //var videos = dal.GetVideosList(); for sql db WebClient wc = new WebClient(); var videojson = wc.DownloadString(Server.MapPath("~/Content/Video.json")); var videos = JsonConvert.DeserializeObject <List <Video> >(videojson); foreach (var video in videos) { var viewModel = new VideoModel(); viewModel.Id = video.Id; viewModel.EncodedAssetId = video.EncodedAssetId; viewModel.IsEncrypted = video.IsEncrypted; viewModel.LocatorUri = video.LocatorUri; viewModel.Status = AzureMediaAsset.GetEncodingJobStatus(video.EncodingJobId); viewModel.FileType = video.filetype; viewModel.FileName = video.AssetFileName ?? null; //if assetfilename is null it will take null // If encrypted content, then get token to play if (video.IsEncrypted) { IAsset asset = GetAssetById(video.EncodedAssetId); viewModel.Token = AzureMediaAsset.GetTestToken(asset.Id, asset); } model.Add(viewModel); } return(View(model)); }
public void OnGet(int id, int rating, string videoId, string videoName, string videoChannel, string videoDate, string videoDuration, string videoThumbnail, bool canRemove) { VideoModel video = new VideoModel(videoId, videoName, videoChannel, videoDate, videoDuration, videoThumbnail); MyItem = new QueueItemModel(id, video, rating); CanRemove = canRemove; }
public void Prepare(VideoModel videoElement) { videoModel = videoElement; videoSource.SetVideoSource(videoElement.Name); videoPlayer.isLooping = videoElement.IsLooping; videoPlayer.Prepare(); }
public async void CreateStream_Pass() { var user = Guid.NewGuid(); var video = new VideoModel { VideoId = Guid.NewGuid(), VideoLength = 7, VideoName = "Test" }; var request = new RequestModel { VideoId = video.VideoId, UserId = user }; var streamService = new StreamManagementService(); var result = await streamService.RequestStream(request); var streamId = streamService.currentStreams.Find(a => a.UserId == user); var stream = new StreamModel { UserId = user, VideoId = video.VideoId, StreamId = streamId.StreamId }; Assert.NotStrictEqual(stream, result); }
public ActionResult Create(VideoModel model, bool continueEditing) { if (!_permissionService.Authorize("ManageVideos")) { return(AccessDeniedView()); } if (ModelState.IsValid) { var objVideo = _videoService.GetVideoById(model.Id); if (objVideo != null) { objVideo.ModifiedOn = DateTime.Now; objVideo.IsOpenResource = true; objVideo.DisplayOrder = model.DisplayOrder; objVideo.IsActive = model.IsActive; _videoService.Update(objVideo); } } else { return(View(model)); } SuccessNotification("Video updated successfully."); return(RedirectToAction("List")); }
public JsonResult SaveVideo(VideoModel video) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); video.Title = video.Title.Length > 200 ? video.Title.Substring(0, 100) + "..." : video.Title; if (!string.IsNullOrEmpty(video.Shortcontent)) { video.Shortcontent = video.Shortcontent.Length > 300 ? video.Shortcontent.Substring(0, 296) + "..." : video.Shortcontent; } else { video.Shortcontent = null; } video.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(video.Title), UrlSlugger.Get8Digits()); video.CreatedDate = DateTime.Now; video.VideoID = Guid.NewGuid().ToString(); video.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _videoService.CreateVideo(video); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> UploadBlob([Bind("Title, VideoLink, Title, Description, DatePosted")] VideoModel VM) { CloudBlobContainer container = GetCloudBlobContainer(); CloudBlockBlob blob = container.GetBlockBlobReference(VM.Title); // Create the blob in blob storage var path = $@"{VM.VideoLink}"; var req = System.Net.WebRequest.Create(VM.VideoLink); using (Stream stream = req.GetResponse().GetResponseStream()) { blob.UploadFromStreamAsync(stream).Wait(); } var Wd = Directory.GetCurrentDirectory(); /* using (var fileStream = System.IO.File.OpenRead(path)) * { * blob.UploadFromStreamAsync(fileStream).Wait(); * }*/ VM.Owner = currentUser; // Add video meta data to the SQL DB if (ModelState.IsValid) { _context.Add(VM); await _context.SaveChangesAsync(); return(View("Home/Index")); } // if we got this far something went wrong return(View()); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Charset = "utf-8"; HttpPostedFile file = context.Request.Files["file"]; string uploadPath = HttpContext.Current.Server.MapPath("~/Video/"); if (file != null) { if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } string name = System.Guid.NewGuid().ToString() + ".mp4"; string video_title = context.Request["video_title"]; string video_des = context.Request["video_des"]; string user_id = context.Request["user_id"]; VideoModel video = new VideoModel(name, video_title, "\\\\Video\\\\" + name, user_id, video_des); VideoDao dao = Factory.Get(new VideoDao()); dao.Insert(video); file.SaveAs(uploadPath + name); Tool.CatchImg(HttpContext.Current.Server.MapPath("../"), name, "240*180", "1"); //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失 context.Response.Write("1"); } else { context.Response.Write("0"); } }
public async Task <object> UploadVideo(IEnumerable <IFormFile> files, [FromForm] string date, [FromForm] bool isPublic) { var videoList = new List <VideoModel>(); foreach (var file in files) { try { var videoDate = string.IsNullOrEmpty(date) ? DateTime.Now : DateTime.ParseExact(date, "yyyyMMdd", null); var fileName = $"{videoDate.ToString("yyyyMMdd")}_{Guid.NewGuid().ToString()}.mp4"; var video = new VideoModel() { FileName = fileName, Date = videoDate, IsPublic = isPublic, Owner = User.Identity.Name }; using (var stream = file.OpenReadStream()) { video.Contents = new byte[stream.Length]; await stream.ReadAsync(video.Contents, 0, video.Contents.Length); stream.Seek(0, SeekOrigin.Begin); video.ThumbContents = await VideoUtil.CreateThumbnail(stream); } videoList.Add(video); } catch { } } return(new MessageDataResult(await VideosService.SaveItems(videoList), "Upload Video")); }
public async Task <IActionResult> VideoCreateAdmin(VideoModel model, IFormFile file) { var entity = new Video() { Tittle = model.Tittle, Url = model.Url, Date = model.Date }; if (file != null) { var extention = Path.GetExtension(file.FileName); var randomName = string.Format($"{Guid.NewGuid()}{extention}"); entity.Image = randomName; var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img", randomName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } } _videoServices.Create(entity); var name = entity.Tittle; TempData.Put("message", new AlertMessage() { Title = "Video Ekleme", Message = $"{name} Video Başarıyla Eklendi", AlertType = "success" }); return(RedirectToAction("VideoListAdmin")); }
public VideoDetail2ViewModel(VideoModel source) { Source = source; Tags = Source.Tags; JumpUrl = Source.VideoUrl; }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here SessionInitialize(); ComentarioCAD comentarioCAD = new ComentarioCAD(session); ComentarioCEN comentarioCEN = new ComentarioCEN(comentarioCAD); ComentarioEN comentarioEN = comentarioCEN.ReadOID(id); ComentarioModel comentario = ComentarioAssembler.convertENToModelUI(comentarioEN); VideoModel vid = new VideoModel(); VideoEN vidEN = new VideoCAD(session).ReadOIDDefault(comentarioEN.Video.Id); vid = VideoAssembler.convertENToModelUI(vidEN); SessionClose(); new ComentarioCEN().Destroy(id); return(RedirectToRoute(new { controller = "Video", action = "Details", id = vid.Id, })); } catch { return(View()); } }
public async Task <ActionResult> SetVideo(VideoModel model) { int index = model.ButtonId.Value; string dsf = Request.Url.AbsolutePath; if (model.Id == 0) { NewsModel elm = await _context.NewsModel.FirstOrDefaultAsync(r => r.Id == index); if (elm != null) { model.ButtonId = null; elm.ListVideo.Add(model); } } else { VideoModel old = await _context.VideoModels.FirstOrDefaultAsync(r => r.Id == model.Id); if (old != null) { _context.Entry(old).CurrentValues.SetValues(model); } } await _context.SaveChangesAsync(); return(RedirectToAction("AddVideo", new { @id = index })); }
/// <summary> /// 修改视频信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result EditVideo(VideoModel model) { Result result = new Result(); try { var video = _videoContext.VVideos.Where(x => x.Id == model.Vid).FirstOrDefault(); if (video == null) { result.code = "1"; result.msg = "视频信息查找失败!"; return(result); } video.Name = model.Name; video.Cid = model.Cid; video.TypeId = model.TypeId; video.ModifyTime = DateTime.Now; video.ImgUrl = model.ImgUrl; video.Remarks = model.Remarks; _videoContext.VVideos.Update(video); _videoContext.SaveChanges(); result.msg = "新增成功"; return(result); } catch (Exception ex) { LoggerHelper.ErrorToFile("视频修改失败,失败原因:" + ex.Message); result.code = "1"; return(result); } }
/// <summary> /// 添加视频信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result AddVideo(VideoModel model) { Result result = new Result(); try { VVideos videos = new VVideos(); videos.Cid = model.Cid; videos.ImgUrl = model.ImgUrl; videos.TypeId = model.TypeId; videos.Remarks = model.Remarks; videos.Name = model.Name; videos.CreateTime = DateTime.Now; videos.Type = "1"; var res = _videoContext.VVideos.Add(videos); _videoContext.SaveChanges(); if (res != null) { result.code = "0"; result.msg = "新增成功"; } else { result.code = "1"; result.msg = "新增失败"; } return(result); } catch (Exception ex) { LoggerHelper.ErrorToFile("视频新增失败,失败原因:" + ex.Message); result.code = "1"; return(result); } }
public async Task <ActionResult <VideoModel> > Post(VideoModel model) { try { var evideo = await repository.GetByVideoName(model.VideoName); if (evideo != null) { return(BadRequest("This video already exists")); } var newvideo = mapper.Map <Video>(model); repository.Add(newvideo); if (await repository.SaveChangesAsync()) { var url = linkGenerator.GetPathByAction(HttpContext, "Get", values: new { VideoId = newvideo.VideoId }); return(Created(url, mapper.Map <VideoModel>(newvideo))); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public ActionResult Edit(int id, VideoModel vid, HttpPostedFileBase file) { try { SessionInitialize(); VideoModel vidM = null; UsuarioModel usu = null; VideoEN videoEN = new VideoCAD(session).ReadOIDDefault(id); UsuarioEN usuarioEN = new UsuarioCAD(session).ReadOIDDefault(User.Identity.GetUserName()); vidM = VideoAssembler.convertENToModelUI(videoEN); usu = UsuarioAssembler.crearUsu(usuarioEN); SessionClose(); VideoCEN videoCEN = new VideoCEN(); string fileName = "", path = ""; if (file != null && file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); path = Path.Combine(Server.MapPath("~/Images/Uploads/Miniaturas"), fileName); file.SaveAs(path); } else { fileName = "defaultUser.png"; } string tit = vid.Titulo; string desc = vid.Descripcion; string enlace = vid.Url; if (tit == null) { tit = vidM.Titulo; } if (desc == null) { desc = vidM.Descripcion; } if (desc == null) { desc = vidM.Url; } if (vidM.Usuario == usu.Nick) { fileName = "/Images/Uploads/Miniaturas/" + fileName; videoCEN.Modify(p_Video_OID: id, p_titulo: tit, p_descripcion: desc, p_fecha_subida: DateTime.Today, p_miniatura: fileName, p_url: enlace); } return(RedirectToAction("Index")); } catch { return(View()); } }
private VideoModel CreateVideoModel(string id) { string queryString = Request.QueryString.ToString(); if (queryString.Length > 0) { queryString = string.Format(@"?{0}", queryString); } // HTTP addresses var video = new VideoModel { VideoUrl = _projectUriProvider.GetUri(id) + queryString, EmbedUrl = Url.RouteUrl(RouteNames.Embed, new { id, autoplay = 1 }, "http") }; // HTTPS address var builder = new UriBuilder(video.VideoUrl) { Scheme = "https", Port = 443 }; video.VideoSecureUrl = builder.Uri.ToString(); builder = new UriBuilder(video.EmbedUrl) { Scheme = "https", Port = 443 }; video.EmbedSecureUrl = builder.Uri.ToString(); video.Robot = GetProvider(Request.UserAgent); return(video); }
private void OverrideParams(VideoModel video) { // Override title from query string if (!string.IsNullOrEmpty(Request.Params[TitleParam])) { video.Name = Request.Params[TitleParam]; } // Override description from query string if (!string.IsNullOrEmpty(Request.Params[DescriptionParam])) { video.Description = Request.Params[DescriptionParam]; } // Override image from query string if (!string.IsNullOrEmpty(Request.Params[ImageParam])) { Uri uri; if (Uri.TryCreate(Request.Params[ImageParam], UriKind.Absolute, out uri)) { video.Image = uri.AbsoluteUri; } } }
protected void Collect_Click(object sender, EventArgs e) { CollectDAO yes_dao = Factory.Get(new CollectDAO()); VideoModel video_model = (Session["video"] as VideoModel); CollectModel yes_model = new CollectModel(video_model.video_id, (Session["user"] as UserModel).id); VideoDao video_dao = Factory.Get(new VideoDao()); if (Button3.ForeColor == System.Drawing.ColorTranslator.FromHtml("#1763e9")) { Button3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#757575"); yes_dao.Delete(yes_model); video_model.collect--; } else if (Button3.ForeColor == System.Drawing.ColorTranslator.FromHtml("#757575")) { Button3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9"); yes_dao.Insert(yes_model); video_model.collect++; } Label4.Text = "收藏:" + video_model.collect; video_dao.Update(video_model); }
private async void GetVideosRequest() { try { List <Video> videoList = new List <Video>(); VideoModel model = await App.Client.GetVideos(); if (model.status == "true") { for (int i = 0; i < model.feeds.Count; i++) { var video = new Models.Video() { id = model.feeds[i].id, priority = model.feeds[i].priority, video = model.feeds[i].video, splash = model.filebase + model.feeds[i].splash, link = model.feeds[i].link, active = model.feeds[i].active }; videoList.Add(video); } videoListView.ItemsSource = videoList; } } catch (Exception) { } }
public ActionResult Create(VideoModel vid, HttpPostedFileBase file) { string fileName = "", path = ""; if (file != null && file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); path = Path.Combine(Server.MapPath("~/Images/Uploads/Miniaturas"), fileName); file.SaveAs(path); } else { fileName = "defaultUser.png"; } try { fileName = "/Images/Uploads/Miniaturas/" + fileName; VideoCEN videoCEN = new VideoCEN(); videoCEN.New_(p_titulo: vid.Titulo, p_descripcion: vid.Descripcion, p_usuario: User.Identity.GetUserName(), p_fecha_subida: DateTime.Today, p_miniatura: fileName, p_url: vid.Url); return(RedirectToAction("Index")); } catch { return(View()); } }
public VideoControlPanelFormPresentationModel(VideoModel videoModel) { _instance = this; _videoModel = videoModel; _stopButtonEnabled = false; _pauseButtonEnabled = false; _playButtonEnabled = false; _videoModel.PauseVideo += this.ReactPause; _videoModel.PlayVideo += this.ReactPlay; _videoModel.StopVideo += this.ReactStop; }
//public ActionResult AddVideo(VideoModel model) //{ // var result = new StatusModel(true); // //validation // if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Director) || model.Year == 0 || string.IsNullOrWhiteSpace(model.Genre)) // { // result.Success = false; result.Message = "Bad Parameters"; // return Json(result); // } // var videoBL = new VideoBL(); // result = videoBL.Add(model); // return Json(result); //} public ActionResult EditVideo(VideoModel model) { var result = new StatusModel(true); //validation if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Director) || model.Year == 0 || string.IsNullOrWhiteSpace(model.Genre)) { result.Success = false; result.Message = "Bad Parameters"; return Json(result); } var videoBL = new VideoBL(); result = videoBL.Edit(model); return Json(result); }
public ActionResult GetVideo(VideoModel model) { var result = new StatusModel<VideoModel>(true); if (model.ID != 0) { var videoBL = new VideoBL(); result = videoBL.Get(model); } else { result.Data = new VideoModel(); } return View("_Get", result.Data); }
/// <summary> /// add specifiec video to DB /// </summary> /// <param name="model">model contains video properties</param> /// <returns>success/nor</returns> public StatusModel Add(VideoModel model) { var result = new StatusModel(true); try { using (Repository repository = new Repository()) { var video = model.GetEntity(); repository.VideoRepository.Insert(video); repository.VideoRepository.Commit(); } } catch (Exception) { result.Success = false; result.Message = "unexpected ERROR"; } return result; }
/// <summary> /// edit specifiec video from DB or add new one /// </summary> /// <param name="model">model contains video properties</param> /// <returns>success/nor</returns> public StatusModel Edit(VideoModel model) { var result = new StatusModel(true, "Save Completed Successfully"); try { using (Repository repository = new Repository()) { if (model.ID == 0) { //add var video = new Video(); video.Brief = model.Brief; video.Director = model.Director; video.Genre = model.Genre; video.Name = model.Name; video.Year = model.Year; repository.VideoRepository.Insert(video); } else { //edit var video = repository.VideoRepository.GetByKey(model.ID); video.Brief = model.Brief; video.Director = model.Director; video.Genre = model.Genre; video.Name = model.Name; video.Year = model.Year; } repository.VideoRepository.Commit(); } } catch (Exception) { result.Success = false; result.Message = "unexpected ERROR"; } return result; }
/// <summary> /// remove specifiec video from DB /// </summary> /// <param name="model">model contains video id</param> /// <returns>success/nor</returns> public StatusModel Remove(VideoModel model) { var result = new StatusModel(true); try { using (Repository repository = new Repository()) { var video = repository.VideoRepository.GetByKey(model.ID); if (video == null) { result.Success = false; result.Message = "Video not found"; return result; } if (video.RenterID != null) { result.Success = false; result.Message = "Video is rented"; return result; } repository.VideoRepository.Delete(video); repository.VideoRepository.Commit(); } } catch (Exception) { result.Success = false; result.Message = "unexpected ERROR"; } return result; }
private async Task PlayVideo(VideoModel model) { if (model.path!=null) { PlayLocalOld(model); return; } progress.Visibility = Visibility.Visible; top_Title.Text = model.title + " " + model.page; pro_Num.Text = "填充弹幕中..."; Cid = model.cid; Aid = model.aid; if (sql.ValuesExists(Cid)) { menu_LastPost.IsEnabled = true; LastPost = sql.QueryValue(Cid); } else { menu_LastPost.IsEnabled = false; sql.InsertValue(Cid); } lastPostVIs = false; DanMuPool = await GetDM(model.cid,false,false,string.Empty); pro_Num.Text = "读取视频信息..."; await GetPlayInfo(model.cid, top_cb_Quality.SelectedIndex+1); }
/// <summary> /// get specifiec video from DB /// </summary> /// <param name="model">model contains video id</param> /// <returns>success/nor and entity model</returns> public StatusModel<VideoModel> Get(VideoModel model) { var result = new StatusModel<VideoModel>(true); try { using (Repository repository = new Repository()) { var videoEntity = repository.VideoRepository.GetByKey(model.ID); if (videoEntity == null) { result.Success = false; result.Message = "Video not founded"; return result; } result.Data = new VideoModel(videoEntity); } } catch (Exception) { result.Success = false; result.Message = "unexpected ERROR"; } return result; }
private async void PlayLocalOld(VideoModel model) { try { Cid = model.cid; if (sql.ValuesExists(Cid)) { menu_LastPost.IsEnabled = true; LastPost = sql.QueryValue(Cid); } else { menu_LastPost.IsEnabled = false; sql.InsertValue(Cid); } lastPostVIs = false; top_Title.Text = model.title; StorageFile file = await StorageFile.GetFileFromPathAsync(model.path); var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); mediaElement.SetSource(stream, file.ContentType); if (model.IsOld==true) { DanMuPool = await GetDM(model.cid, true,true,string.Empty); } else { DanMuPool = await GetDM(model.cid, true,false, (await file.GetParentAsync()).Path); } Send_text_Comment.PlaceholderText = "Sorry,本地视频暂不支持发送弹幕..."; Send_text_Comment.IsEnabled = false; Send_btn_Send.IsEnabled = false; top_cb_Quality.Visibility = Visibility.Collapsed; //btn_EPList.IsEnabled = false; //GetPlayhistory(model.path); } catch (Exception) { messShow.Show("读取本地视频失败!", 3000); } }
public ActionResult RemoveVideo(VideoModel model) { var result = new StatusModel(true); var videoBL = new VideoBL(); result = videoBL.Remove(model); return Redirect("/admin"); }