Пример #1
0
        public ActionResult Pop()
        {
            List <VideoFiles> videolist = new List <VideoFiles>();
            string            CS        = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand("select * from dbo.VideoFiles where Genre LIKE 'Pop'", con);
                //cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    VideoFiles video = new VideoFiles();
                    video.ID          = Convert.ToInt32(rdr["ID"]);
                    video.Name        = rdr["Name"].ToString();
                    video.FileSize    = Convert.ToInt32(rdr["FileSize"]);
                    video.FilePath    = rdr["FilePath"].ToString();
                    video.Description = rdr["Description"].ToString();
                    video.Genre       = rdr["Genre"].ToString();

                    videolist.Add(video);
                }
            }
            return(View(videolist));
        }
Пример #2
0
 public VkVideo(string title, VideoFiles videoFiles, string previewUrl, string url, string extension = ".mp4") : base(title, url, extension)
 {
     VideoUrls  = videoFiles;
     PreviewUrl = previewUrl;
     UpdateResolutionLinks();
     ClearNameFromIllegalSymbols();
 }
Пример #3
0
        public FileResult DownloadFile(int?fileId)
        {
            OgrenciDBEntities entities = new OgrenciDBEntities();
            VideoFiles        file     = entities.VideoFiles.ToList().Find(p => p.ID == fileId.Value);

            return(File(file.Data, file.ContentType, file.Name));
        }
Пример #4
0
        public ActionResult UploadVideo()
        {
            List <VideoFiles> videolist = new List <VideoFiles>();
            string            CS        = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand("spGetAllVideoFile", con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    VideoFiles video = new VideoFiles();
                    video.ID          = Convert.ToInt32(rdr["ID"]);
                    video.Name        = rdr["Name"].ToString();
                    video.FileSize    = Convert.ToInt32(rdr["FileSize"]);
                    video.FilePath    = rdr["FilePath"].ToString();
                    video.Description = rdr["Description"].ToString();
                    video.Genre       = rdr["Genre"].ToString();
                    if (Request.Cookies.Get("CurrentUser") != null)
                    {
                        video.UserName = Request.Cookies.Get("CurrentUser").Value;
                    }
                    ;

                    videolist.Add(video);
                }
            }
            return(View(videolist));
        }
Пример #5
0
        public void MoveDown(VideoFile video)
        {
            var oldIndex = VideoFiles.IndexOf(video);

            if (oldIndex < VideoFiles.Count - 1)
            {
                VideoFiles.Move(oldIndex, oldIndex + 1);
            }
            NotifyOfPropertyChange(() => VideoFiles);
        }
Пример #6
0
        public void MoveUp(VideoFile video)
        {
            var oldIndex = VideoFiles.IndexOf(video);

            if (oldIndex > 0)
            {
                VideoFiles.Move(oldIndex, oldIndex - 1);
            }
            NotifyOfPropertyChange(() => VideoFiles);
        }
Пример #7
0
        /// <summary>Starts the GUI</summary>
        /// <remarks>A file is opened if it was specified as argument. If it wasn't, a blank start is performed.</summary>
        public void Start()
        {
            string subtitleFilePath = GetSubtitleFileArg(Base.ExecutionContext.Args);

            if (subtitleFilePath != null)
            {
                Uri videoUri = Base.Config.VideoAutoChooseFile ? VideoFiles.FindMatchingVideo(subtitleFilePath) : null;
                int codePage = GetFileOpenCodePageFromConfig();
                Open(subtitleFilePath, codePage, videoUri);
            }
        }
Пример #8
0
        private void FillVideoComboBoxBasedOnCurrentFolder()
        {
            videoFiles     = null;
            videoFilenames = null;
            videoComboBox.RemoveAll();

            string folder = String.Empty;

            try {
                folder = (Dialog as FileChooserDialog).CurrentFolder;
            }
            catch (Exception e) {
                Logger.Error(e, "Caught exception when trying to get the current folder");
                SetVideoSelectionSensitivity(false);
                return;
            }

            if ((folder == null) || (folder == String.Empty))
            {
                Logger.Error("Error when trying to get the current folder.");
                SetVideoSelectionSensitivity(false);
                return;
            }

            videoFiles = VideoFiles.GetVideoFilesAtPath(folder);

            if ((videoFiles.Count == 0) || (videoFiles == null))
            {
                SetVideoSelectionSensitivity(false);
                return;
            }
            else
            {
                SetVideoSelectionSensitivity(true);
            }

            videoFiles.Sort();
            videoFilenames = new ArrayList();
            foreach (string file in videoFiles)
            {
                string filename = Path.GetFileName(file);
                videoComboBox.AppendText(filename);

                videoFilenames.Add(FilenameWithoutExtension(filename));
            }

            videoComboBox.PrependText("-");
            videoComboBox.PrependText(Catalog.GetString("None"));
            videoComboBox.Active = 0;
        }
Пример #9
0
        public ActionResult Delete(string id)
        {
            var        vid         = Convert.ToInt32(id);
            VideoFiles deletevideo = db.VideoFiles.Find(vid);

            if (deletevideo != null)
            {
                string videoPath = Server.MapPath(deletevideo.FilePath.ToString());
                System.IO.File.Delete(videoPath);
                db.VideoFiles.Remove(deletevideo);
                db.SaveChanges();
            }
            return(RedirectToAction("UploadVideo"));
        }
Пример #10
0
        /// <summary>
        /// 结构转换成XML
        /// </summary>
        /// <param name="playlist">播放列表</param>
        /// <returns></returns>
        public string ToXml(AMS_PlayListMd5Model playlist)
        {
            //TODO:转换成xml结构的算法
            //创建一个xml对象
            XmlDocument xmlDoc = new XmlDocument();
            //创建开头
            XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlDoc.AppendChild(dec);
            //创建根节点
            XmlElement root = xmlDoc.CreateElement("Root");

            root.SetAttribute("Num", playlist.PlayListNo);
            root.SetAttribute("EffectDate", playlist.EffectDate.ToShortDateString());
            root.SetAttribute("EndDate", playlist.EndDate.ToShortDateString());
            root.SetAttribute("PlayElapsed", playlist.PlayElapsed.ToString());
            //创建二级节点
            XmlElement SecNode = xmlDoc.CreateElement("VideoItems");

            root.AppendChild(SecNode);
            //遍历媒体文件并添加到节点中
            foreach (AMS_VideoMd5Item video in playlist.PlayVideoItems)
            {
                XmlElement ThirdNode = xmlDoc.CreateElement("Video");
                ThirdNode.SetAttribute("name", video.Name);
                ThirdNode.SetAttribute("playtime", video.PlayTime);
                ThirdNode.SetAttribute("source", video.RelativeUrl);
                ThirdNode.SetAttribute("md5value", video.md5value);

                SecNode.AppendChild(ThirdNode);
                //不重复的视频文件名称
                int i;
                for (i = 0; i < VideoFiles.Count; i++)
                {
                    if (VideoFiles[i].Name == video.Name)
                    {
                        break;
                    }
                }
                if (i >= VideoFiles.Count)
                {
                    VideoFiles.Add(video);
                }
            }
            //在根节点中添加二级节点
            root.AppendChild(SecNode);
            //添加根节点
            xmlDoc.AppendChild(root);
            return(xmlDoc.OuterXml);
        }
Пример #11
0
        private void AddVidRecord()
        {
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.InitialDirectory = DBLayer.MovieFiles;

            ofd.Multiselect = true;

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (string fil in ofd.FileNames)
                {
                    VideoFiles.AddVideoFile(fil);
                }
            }
        }
Пример #12
0
        public ActionResult UploadVideo(HttpPostedFileBase fileupload)
        {
            if (fileupload != null)
            {
                string fileName = Path.GetFileName(fileupload.FileName);
                int    fileSize = fileupload.ContentLength;
                int    Size     = fileSize / 1000;
                fileupload.SaveAs(Server.MapPath("~/VideoFileUpload/" + fileName));

                VideoFiles model = new VideoFiles();
                model.Name     = fileName;
                model.FilePath = "~/VideoFileUpload/" + fileName;
                model.FileSize = Size;
                if (ModelState.IsValid)
                {
                    db.VideoFiles.Add(model);
                    db.SaveChanges();
                    return(RedirectToAction("UploadVideo"));
                }
                return(View(model));
            }
            return(RedirectToAction("UploadVideo"));
        }
Пример #13
0
 public void RemoveFile(ISingleFile file)
 {
     VideoFiles.Remove(file);
     Videos.Remove(file.VideoFileName);
 }
Пример #14
0
 public void AddFile(ISingleFile file)
 {
     VideoFiles.Add(file);
     Videos.Add(file.VideoFileName);
 }
Пример #15
0
        public async void StartUpload()
        {
            if (string.IsNullOrEmpty(FileName))
            {
                MessageBox.Show("Please enter a file name");
                return;
            }


            try
            {
                CurrentState = State.Working;
                ErrorText    = "";
                _cancelToken = new CancellationTokenSource();
                var uploadProgress = new Progress <UploadProgress>(up =>
                {
                    UploadProgress = up.PercentComplete;
                    UploadRate     = up.BitsPerSecond;
                });
                var encodeProgress = new Progress <EncodeProgress>(ep =>
                {
                    EncodeProgress = ep.PercentComplete;
                    EncodeFps      = ep.FramesPerSecond;
                });

                if (IsMultiClip)
                {
                    YouTubeId = await _clipCreator.ClipAndUpload(VideoFiles.Select(vf => vf.File).ToList(),
                                                                 $"{SafeFileName}.mp4",
                                                                 SelectedEncoder,
                                                                 ForceWideScreen,
                                                                 SelectedDestination,
                                                                 encodeProgress,
                                                                 uploadProgress, _cancelToken.Token);
                }
                else
                {
                    YouTubeId = await _clipCreator.ClipAndUpload(OriginalFile.FullName, $"{SafeFileName}.mp4",
                                                                 Timelines,
                                                                 SelectedEncoder,
                                                                 ForceWideScreen,
                                                                 SelectedDestination,
                                                                 encodeProgress,
                                                                 uploadProgress, _cancelToken.Token);
                }


                CurrentState = State.Done;
                if (!DeleteOnSuccess)
                {
                    return;
                }
                if (!IsMultiClip)
                {
                    await _fileDeleter.Delete(OriginalFile);
                }
                else
                {
                    foreach (var video in VideoFiles)
                    {
                        await _fileDeleter.Delete(video.File);
                    }
                }
            }
            catch (Exception e)
            {
                CurrentState = State.Error;
                Console.Write(e);
                ErrorText = $"Error: {e.Message}";
            }
            finally
            {
                _cancelToken = null;
            }
        }