public ActionResult Show(int id = 0) { if (id != 0) { Live live = new Live(); live = db.Lives.Find(id); ViewBag.ShowLive = live; } else { Live live = new Live(); live.LiveURL = "rtmp://218.8.130.128:1935/Live/Video1"; live.Title = "测试"; ViewBag.ShowLive = live; } ViewBag.LiveID = id; return View(); }
public ActionResult AddLive(Live model, HttpPostedFileBase file) { if (file != null) { System.IO.Stream stream = file.InputStream; byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); stream.Close(); model.Picture = buffer; db.Lives.Add(model); db.SaveChanges(); return Redirect("/Admin/LiveManager"); } else { return Redirect("/Admin/AdminMessage?msg=你填写信息不正确,请重新填写!"); } }
public ActionResult LiveEdit(Live model, HttpPostedFileBase file) { Live live = db.Lives.Find(model.ID); if (file != null) { System.IO.Stream stream = file.InputStream; byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); stream.Close(); live.Picture = buffer; } live.Title = model.Title; live.Description = model.Description; live.Begin = model.Begin; live.End = model.End; live.LiveURL = model.LiveURL; live.NeedAuthorize = model.NeedAuthorize; db.SaveChanges(); return Redirect("/Admin/LiveManager"); }
/// <summary> /// 视频缩略图 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult ShowPicture(int id) { Live live = new Live(); live = db.Lives.Find(id); return File(live.Picture, "image/jpg"); }