コード例 #1
0
ファイル: Edit.aspx.cs プロジェクト: thanhphat/ibookstop
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int _count = 0;

            Model.Video model = new Model.Video();

            if (id > 0)
            {
                model = bll.GetModel(this.id, -1, 1, 1);
            }

            model.Title = txtTitle.Text.Trim();
            model.Link = txtLink.Value;
            model.Image = string.Empty;
            model.Intro = txtIntro.Value;

            model.Status = Convert.ToInt32(rdStatus.SelectedValue);

            bll.Update(model, ref _count);

            if (_count > 0)
            {

                JscriptMsg("Cập nhật thành công !", "List.aspx", "Success");
            }
            else
            {
                JscriptMsg("Lỗi xảy ra !", "", "Error");
            }
        }
コード例 #2
0
        /// <summary>
        /// Initialization
        /// </summary>
        public Video_ViewModel()
        {
            __LibraryFile    = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Epitech\\__MyLibrary";
            _NbFilesLoaded   = 0;
            Loading          = true;
            _ProgressTimer   = new DispatcherTimer();
            _Library         = new Model.Library(__LibraryFile, this);
            _Playlist        = new Model.Playlist();
            _Video           = new Model.Video();
            _IsPlaying       = false;
            _IsLoaded        = false;
            _Maximum         = 10;
            _SaveVolume      = 0;
            _SaveWidth       = Video.Media.Width;
            _SaveHeight      = Video.Media.Height;
            _Choice          = 0;
            IsFullScreen     = false;
            _LibrarySearch   = "Custom Search...";
            _GoSearch        = true;
            _WindowStateSave = WindowState.Normal;
            ControlZindex    = 7;

            _ProgressTimer.Interval      = TimeSpan.FromSeconds(1);
            _ProgressTimer.Tick         += ProgressTimer_Tick;
            Video.Media.MediaOpened     += new RoutedEventHandler(EVNT_MediaOpened);
            Video.Media.MediaEnded      += new RoutedEventHandler(EVNT_MediaEnded);
            Video.Media.ScrubbingEnabled = true;
            Video.Media.IsEnabled        = true;

            _ProgressTimer.Start();
            InitCommands();
        }
コード例 #3
0
        /// <summary>
        /// Concat a second video at the end of the main video.
        /// </summary>
        /// <param name="secondVideo">The second video to add at the end of the main one.</param>
        public void concatVideos(Video secondVideo)
        {
            /* Conversion of both videos */
            //this.video.convertVideo();
            //secondVideo.convertVideo();

            /* Settings needed to concatenate the videos */
            String[] inputVideoPaths = new String[2];
            String   outputVideoPath = this.video.filePath;
            String   outputName      = this.video.fileName;
            String   newPath         = "C:\\Users\\Théo\\Desktop\\videos\\final.mp4";
            String   commandConcat   = "- i \"concat:" + this.video.filePath + "|" + secondVideo.filePath + "\" - codec copy " + outputVideoPath;
            long     outputSize      = video.fileSize + secondVideo.fileSize;

            inputVideoPaths[0] = video.filePath;
            inputVideoPaths[1] = secondVideo.filePath;

            var concatSetting = new NReco.VideoConverter.ConcatSettings();

            //concatSetting.ConcatVideoStream = true;
            //concatSetting.ConcatAudioStream = false;
            //concatSetting.VideoCodec = "h264";
            //concatSetting.VideoFrameRate = 30;
            //concatSetting.SetVideoFrameSize(1280, 720);


            processPercentage = "0 %";
            ffMpegConverter.ConvertProgress += updateProgress;
            ffMpegConverter.ConcatMedia(inputVideoPaths, newPath, Format.mp4, concatSetting);


            video = new Model.Video(newPath, "final", outputSize);
        }
コード例 #4
0
        public void PlayVideo(Model.Video media)
        {
            MediaElement.Display(media.Path);
            MediaElement.Show();
            Image.Hide();
            Play();

            IsPlayingMedia = true;
        }
コード例 #5
0
        public System.Collections.ObjectModel.ObservableCollection<Model.Playlist> ExtractPlaylists()
        {
            IEnumerable<System.Xml.Linq.XElement> playlists = XElement.Elements();
            System.Collections.ObjectModel.ObservableCollection<Model.Playlist> playlistsList = new System.Collections.ObjectModel.ObservableCollection<Model.Playlist>();
            if (XElement == null)
                return null;
            try
            {
                /* CREATING AN OBSERVABLECOLLECTION FROM ALL PLAYLIST */

                foreach (var playlist in playlists)
                {
                    IEnumerable<System.Xml.Linq.XElement> medias = XElement.Elements("Media");
                    System.Collections.ObjectModel.ObservableCollection<Model.Media> mediasList = new System.Collections.ObjectModel.ObservableCollection<Model.Media>();

                    /* CREATING AN MEDIA COLLECTION CORRESPONDING TO ALL MEDIAS OF PLAYLIST */

                    foreach (var media in medias)
                    {
                        /* TEST IF XML ELEMENT IS VALID FOR MEDIA */

                        if (media != null && media.Element("Path") != null && media.Element("Type") != null)
                        {
                            Model.Media newMedia = null;

                            switch ((Model.Media.MediaType)Enum.Parse(typeof(Model.Media.MediaType), media.Element("Type").Value))
                            {
                                case Model.Media.MediaType.IMAGE:
                                    newMedia = new Model.Image(media.Element("Path").Value);
                                    break;
                                case Model.Media.MediaType.VIDEO:
                                    newMedia = new Model.Video(media.Element("Path").Value);
                                    break;
                                case Model.Media.MediaType.MUSIC:
                                    newMedia = new Model.Music(media.Element("Path").Value);
                                    break;
                            }

                            if (newMedia != null)
                                mediasList.Add(newMedia);
                        }
                    }

                    /* ADDING NEW PLAYLIST ELEMENT TO SELECTION */

                    playlistsList.Add(new Model.Playlist() { Name = playlist.Element("Name").Value, MediasList = mediasList });
                }
            }
            catch
            { }

            return playlistsList;
        }
コード例 #6
0
        private void getData(int id)
        {
            JavaDLL dll = new JavaDLL();

            Model.Video cate = dll.getVideo(id);
            if (cate != null)
            {
                txtTitle.Text = cate.name;
                txtUrl.Text   = cate.url;
                txtUrl2.Text  = cate.url2;
            }
        }
コード例 #7
0
        public System.Collections.ObjectModel.ObservableCollection <Model.Playlist> GetPlaylists()
        {
            System.Collections.ObjectModel.ObservableCollection <Model.Playlist> playlistsCollection = new System.Collections.ObjectModel.ObservableCollection <Model.Playlist>();

            try
            {
                IEnumerable <System.Xml.Linq.XElement> playlists = xelement.Elements("Playlist");
                foreach (var playlist in playlists)
                {
                    System.Collections.ObjectModel.ObservableCollection <Model.Media> medias = new System.Collections.ObjectModel.ObservableCollection <Model.Media>();
                    IEnumerable <System.Xml.Linq.XElement> elements = playlist.Elements("Element");
                    foreach (var elem in elements)
                    {
                        if (elem != null &&
                            elem.Element("Path") != null &&
                            elem.Element("Stream") != null &&
                            elem.Element("Type") != null)
                        {
                            Model.Media media = null;

                            switch ((Model.Media.MediaType)Enum.Parse(typeof(Model.Media.MediaType), elem.Element("Type").Value))
                            {
                            case Model.Media.MediaType.MUSIC:
                                media = new Model.Music(elem.Element("Path").Value, Boolean.Parse(elem.Element("Stream").Value));
                                break;

                            case Model.Media.MediaType.PICTURE:
                                media = new Model.Picture(elem.Element("Path").Value, Boolean.Parse(elem.Element("Stream").Value));
                                break;

                            case Model.Media.MediaType.VIDEO:
                                media = new Model.Video(elem.Element("Path").Value, Boolean.Parse(elem.Element("Stream").Value));
                                break;
                            }

                            if (media != null)
                            {
                                medias.Add(media);
                            }
                        }
                    }
                    playlistsCollection.Add(new Model.Playlist()
                    {
                        Name   = playlist.Attribute("name").Value,
                        Medias = medias
                    });
                }
            }
            catch { Console.WriteLine("FAILED GetPlaylists catch"); }

            return(playlistsCollection);
        }
コード例 #8
0
        public void GetUploadToken_GivenAVideo_ReturnsValidGUID()
        {
            //arrange
            var service = VideoStoreServiceFactory();

            //act
            var video = new Model.Video()
            {
                Name = "test"
            };
            var token = service.GetUploadToken(video);

            //assert
            Guid.TryParse(token, out _).Should().BeTrue();
        }
コード例 #9
0
        public System.Collections.ObjectModel.ObservableCollection<Model.Playlist> GetPlaylists()
        {
            System.Collections.ObjectModel.ObservableCollection<Model.Playlist> playlistsCollection = new System.Collections.ObjectModel.ObservableCollection<Model.Playlist>();

            try
            {
                IEnumerable<System.Xml.Linq.XElement> playlists = xelement.Elements("Playlist");
                foreach (var playlist in playlists)
                {
                    System.Collections.ObjectModel.ObservableCollection<Model.Media> medias = new System.Collections.ObjectModel.ObservableCollection<Model.Media>();
                    IEnumerable<System.Xml.Linq.XElement> elements = playlist.Elements("Element");
                    foreach (var elem in elements)
                    {
                        if ( elem != null &&
                             elem.Element("Path") != null &&
                             elem.Element("Stream") != null &&
                             elem.Element("Type") != null)
                        {
                            Model.Media media = null;

                            switch ((Model.Media.MediaType)Enum.Parse(typeof(Model.Media.MediaType), elem.Element("Type").Value))
                            {
                                case Model.Media.MediaType.MUSIC:
                                    media = new Model.Music(elem.Element("Path").Value, Boolean.Parse(elem.Element("Stream").Value));
                                    break;
                                case Model.Media.MediaType.PICTURE:
                                    media = new Model.Picture(elem.Element("Path").Value, Boolean.Parse(elem.Element("Stream").Value));
                                    break;
                                case Model.Media.MediaType.VIDEO:
                                    media = new Model.Video(elem.Element("Path").Value, Boolean.Parse(elem.Element("Stream").Value));
                                    break;
                            }

                            if (media != null)
                                medias.Add(media);
                        }
                    }
                    playlistsCollection.Add(new Model.Playlist()
                    {
                        Name = playlist.Attribute("name").Value,
                        Medias = medias
                    });
                }
            }
            catch { Console.WriteLine("FAILED GetPlaylists catch"); }

            return playlistsCollection;
        }
コード例 #10
0
        private void ExecuteOpenVideoFile()
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Filter = "MP4 Files (.mp4)|*.mp4|WMV Files (.wmv)|*.wmv";
            openFileDialog.FilterIndex = 1;

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Model.Video NewVideo = new Model.Video(openFileDialog.FileName);
                VideoList.Add(NewVideo);
                XMLMedia XMLVideo = new XMLMedia();
                XMLVideo.LoadXML("Video.xml");
                XMLVideo.AddMedia(NewVideo);
                XMLVideo.WriteXML("Video.xml");
            }
        }
コード例 #11
0
        public void GetUploadModel_GivenValidToken_ReturnsCorrectVideoModel()
        {
            //arrange
            var service = VideoStoreServiceFactory();

            //act
            var video = new Model.Video()
            {
                Name = "test"
            };
            var token  = service.GetUploadToken(video);
            var result = service.GetUploadModel(token, out Model.Video videoModel);

            //assert
            result.Should().BeTrue();
        }
コード例 #12
0
ファイル: Edit.aspx.cs プロジェクト: thanhphat/ibookstop
        private void ShowInfo()
        {
            Model.Video model = new Model.Video();

            model = bll.GetModel(this.id, -1, 1, 1);

            if (null != model && model.Id > 0)
            {
                txtTitle.Text = model.Title;
                txtLink.Value = model.Link;

                txtIntro.Value = model.Intro;

                rdStatus.SelectedValue = model.Status.ToString();

            }
        }
コード例 #13
0
        public void LoadData()
        {
            Videos    = new System.Collections.ObjectModel.ObservableCollection <Model.Video>();
            VideosTmp = new System.Collections.ObjectModel.ObservableCollection <Model.Video>();
            XML.MediaXML mediaXML = new XML.MediaXML();

            mediaXML.Load("videos.xml");
            List <Tuple <String, Boolean> > medias = mediaXML.GetMedias();

            foreach (var media in medias)
            {
                Model.Video pics_1 = new Model.Video(media.Item1, media.Item2);
                Model.Video pics_2 = new Model.Video(media.Item1, media.Item2);
                VideosTmp.Add(pics_1);
                Videos.Add(pics_2);
            }
        }
コード例 #14
0
        public void AddVideo(Model.Video video)
        {
            XML.MediaXML mediaXML = new XML.MediaXML();

            mediaXML.Load("videos.xml");
            if (!mediaXML.HasMedia(video.Path))
            {
                mediaXML.Add(video.Path, video.Stream);
                mediaXML.WriteInFile("videos.xml");

                if (video.Name.Contains(this._SearchInput))
                {
                    Videos.Add(video);
                }
                VideosTmp.Add(video);
            }
        }
コード例 #15
0
        public static Model.Video FromCore(this Entities.Video video)
        {
            Model.Video result = null;

            if (video != null)
            {
                result = new Model.Video()
                {
                    Id                  = video.Id,
                    Name                = video.Name,
                    UserDescription     = video.UserDescription,
                    AnalyserDescription = video.AnalyserDescription,
                    Priority            = (int)video.Priority
                };
            }

            return(result);
        }
コード例 #16
0
        public static Entities.Video ToCore(this Model.Video video)
        {
            Entities.Video result = null;

            if (video != null)
            {
                result = new Entities.Video()
                {
                    Id                  = video.Id,
                    Name                = video.Name,
                    UserDescription     = video.UserDescription,
                    AnalyserDescription = video.AnalyserDescription,
                    Priority            = (Entities.PriorityEnum)video.Priority
                };
            }

            return(result);
        }
コード例 #17
0
        public void RemoveVideo(Model.Video video)
        {
            XML.MediaXML mediaXML = new XML.MediaXML();

            mediaXML.Load("videos.xml");
            mediaXML.Remove(video.Path);
            mediaXML.WriteInFile("videos.xml");
            String namePathFile = video.Path;

            Videos.Remove(video);


            var medias   = from media in VideosTmp where media.Path.Contains(namePathFile) select media;
            var selected = video;

            foreach (var media in medias)
            {
                selected = media;
            }
            VideosTmp.Remove(selected);
        }
コード例 #18
0
        public void LoadData()
        {
            Videos = new System.Collections.ObjectModel.ObservableCollection<Model.Video>();
            VideosTmp = new System.Collections.ObjectModel.ObservableCollection<Model.Video>();
            XML.MediaXML mediaXML = new XML.MediaXML();

            mediaXML.Load("videos.xml");
            List<Tuple<String, Boolean>> medias = mediaXML.GetMedias();

            foreach (var media in medias)
            {
                Model.Video pics_1 = new Model.Video(media.Item1, media.Item2);
                Model.Video pics_2 = new Model.Video(media.Item1, media.Item2);
                VideosTmp.Add(pics_1);
                Videos.Add(pics_2);
            }
        }
コード例 #19
0
        private void LoadVideoFile(String FileName)
        {
            //TODO CHECK IF MEDIA ALREADY LOADED + LOAD MEDIA

            /* ERASE */

            var Extension = System.IO.Path.GetExtension(FileName).ToUpper();

            if (Extension == ".MP4" || Extension == ".WMV")
            {
                Model.Video NewVideo = new Model.Video(FileName);
                VideoList.Add(NewVideo);
            }
        }
コード例 #20
0
ファイル: Video.cs プロジェクト: thanhphat/ibookstop
        public List<Model.Video> GetList(int _Id, int _Status, int _Start, int _Limit)
        {
            List<Model.Video> ModelList = new List<Model.Video>();

            try
            {

                SqlParameter[] p =  {
                                        new SqlParameter("@Id", SqlDbType.Int, 4),
                                        new SqlParameter("@Status", SqlDbType.Int, 4),
                                        new SqlParameter("@Start", SqlDbType.Int, 4),
                                        new SqlParameter("@Limit", SqlDbType.Int, 4)
                                    };

                p[0].Value = _Id;
                p[1].Value = _Status;
                p[2].Value = _Start;
                p[3].Value = _Limit;

                DataTable dt = db.ExcuteSelectReturnDataTable("Video_Select", CommandType.StoredProcedure, p);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Model.Video model = new Model.Video();

                        model.Ind = Convert.ToInt32(dr["Ind"]);
                        model.Id = Convert.ToInt32(dr["Id"]);
                        model.Title = dr["Title"].ToString();
                        model.Image = dr["Image"].ToString();
                        model.Link = dr["Link"].ToString();
                        model.Intro = dr["Intro"].ToString();
                        model.Status = Convert.ToInt32(dr["Status"]);
                        model.StatusText = dr["Statustext"].ToString();

                        ModelList.Add(model);
                    }

                }

            }
            catch (Exception ex)
            {
                PTSLog.Error(ex.Message);
            }

            return ModelList;
        }
コード例 #21
0
ファイル: ArticleController.cs プロジェクト: vbea/Java21.NET
        public ActionResult Video(int?id, string client, string device)
        {
            int     d   = id ?? 1;
            JavaDLL dll = new JavaDLL();

            Model.Video mod = dll.getVideo(d);
            if (mod == null)
            {
                return(View());
            }
            if (device != null)
            {
                Session["LoginDevice"] = device;
            }
            DataSet userds = dll.getAllUser();//获取所有用户信息

            string[] clients = null;
            if (client != null)
            {
                clients = client.Split('_');
            }
            UserInfo info = (UserInfo)Session["LoginUser"];

            if (info == null || (client != null && !info.ID.Equals(clients[1])))
            {
                if (clients != null && clients.Length == 2)
                {
                    var client_user = from u in userds.Tables[0].AsEnumerable()
                                      where u["psd"].ToString().Equals(clients[0]) && u["id"].ToString().Equals(clients[1])
                                      select new UserInfo
                    {
                        ID       = Convert.ToInt32(u["id"]),
                        UserName = u["name"].ToString(),
                        UserPass = u["psd"].ToString(),
                        Role     = Convert.ToInt32(u["roles"]),
                        Gender   = Convert.ToInt32(u["gender"]),
                        NickName = u["nickname"].ToString(),
                        Email    = u["email"].ToString(),
                        QQ       = "" + u["qq"],
                        Mobile   = "" + u["mobile"],
                        Birthday = Convert.ToDateTime(u["birthday"]),
                        Addr     = "" + u["address"],
                        Valid    = Convert.ToBoolean(u["valid"]),
                        Mark     = "" + u["mark"],
                        HeadImg  = (u["head"].Equals(DBNull.Value) ? "/images/head.jpg" : u["head"].ToString()),
                    };
                    info = client_user.FirstOrDefault <UserInfo>();
                    if (info != null)
                    {
                        info.SetAddress(info.Addr);
                        Session["LoginUser"] = info;
                    }
                }
            }
            //判断是否登录
            if (info != null)
            {
                ViewData.Add("logins", "");
                ViewData.Add("vilid", "");
            }
            else
            {
                ViewData.Add("logins", "你需要登录后才能发表");
                ViewData.Add("vilid", "disabled=disabled");
            }
            int            count    = 0;
            List <Comment> comments = dll.getComments(d, 20, 1, out count);

            //mod.comments = dll.getComments(aid, 10, 1, out count);
            mod.comcount = count;
            //linq级联查询
            var comment = from u in userds.Tables[0].AsEnumerable()
                          join c in comments on u["name"].ToString() equals c.uid
                          orderby c.cdate descending
                          select new Comment {
                id = c.id, aid = c.aid, sid = u["name"].ToString(), uid = u["nickname"].ToString(), comment = Convert.ToBoolean(u["valid"]) ? c.comment : "<span>用户被屏蔽,内容自动删除</span>", cdate = c.cdate, device = c.device, head = u["head"].Equals(DBNull.Value) ? "/images/head.jpg" : u["head"].ToString()
            };

            mod.comments = comment.ToList <Comment>();
            return(View(mod));
        }