private void playMediaCmd() { IEnumerable <Media> lv = ListVideos.Where(m => m.IsSelected == true); IEnumerable <Media> lm = ListSongs.Where(m => m.IsSelected == true); IEnumerable <Media> lp = ListPictures.Where(m => m.IsSelected == true); if (lv.Count() > 0) { _player.Stop(); _media = lv.ElementAt(0); OnOpenMedia(_media.FileName); } else if (lm.Count() > 0) { _player.Stop(); _media = lm.ElementAt(0); OnOpenMedia(_media.FileName); } else if (lp.Count() > 0) { _player.Stop(); _media = lp.ElementAt(0); OnOpenMedia(_media.FileName); } }
private void loadVideosLibrary() { try { using (FileStream stream = new FileStream(@"../../library/videos.xml", FileMode.OpenOrCreate, FileAccess.Read)) { TextReader reader = new StreamReader(stream); XmlSerializer serializer = new XmlSerializer(typeof(List <VideoMedia>)); List <VideoMedia> list = (List <VideoMedia>)serializer.Deserialize(reader); foreach (VideoMedia m in list) { if (m.Title == null) { m.Title = Path.GetFileNameWithoutExtension(m.FileName); } m.Icon = ExtensionStatic.GetIconsFromExtension(Path.GetExtension(m.FileName)); if (m.isDisplayable(_search, _typeFilter)) { ListVideos.Add(m); } } }; } catch (Exception) {} }
private void Button_Click_Delete(object sender, RoutedEventArgs e) { string name = ImageName; string code = ImageCode; if (name.Split('.').Last().Equals("mp4")) { ListVideos.Remove(dictionaryVideos[code]); dictionaryVideos.Remove(code); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ListVideos))); System.IO.File.Delete("C:\\Users\\" + _computer + "\\Desktop\\CMS\\videos\\" + name); logs.Text = "Video deleted"; } else if (name.Split('.').Last().Equals("wav")) { ListAudios.Remove(dictionaryAudio[code]); dictionaryAudio.Remove(code); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ListAudios))); System.IO.File.Delete("C:\\Users\\" + _computer + "\\Desktop\\CMS\\audios\\" + name); logs.Text = "Audio deleted"; } else { ListImages.Remove(dictionaryImages[code]); dictionaryImages.Remove(code); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ListImages))); System.IO.File.Delete("C:\\Users\\" + _computer + "\\Desktop\\CMS\\images\\" + name); logs.Text = "Image deleted"; } }
private void Button_Click_Videos(object sender, RoutedEventArgs e) { string file = GetFile(); if (!file.Equals("")) { string fileName = System.IO.Path.GetFileName(file); if (!File.Exists("C:\\Users\\" + _computer + "\\Desktop\\CMS\\videos\\" + fileName)) { logs.Text = "Copying " + fileName + " to folder "; WebClient wc = new WebClient(); wc.DownloadProgressChanged += DownloadProgress; wc.DownloadFileAsync(new Uri(file), "C:\\Users\\" + _computer + "\\Desktop\\CMS\\videos\\" + fileName); wc.Dispose(); Image = new BitmapImage(new Uri("C:\\Users\\" + _computer + "\\Desktop\\CMS\\images\\video_placeholder.jpg")); Image image = new Image(fileName, Image, true); image.Name = fileName; dictionaryVideos[fileName] = image; ListVideos.Add(image); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ListVideos))); } else { logs.Text = "This file already exists in CMS"; } } }
private void addVideoToPlayList() { IEnumerable <Media> lm = ListVideos.Where(m => m.IsSelected == true); foreach (Media m in lm) { _playlist.ListMedia.Add(m); } }
public static DataTable YouTubeToDataTable() { IEnumerable ien = ListVideos.YourVideos(); var dt = new DataTable(); foreach (object obj in ien) { Type t = obj.GetType(); PropertyInfo[] pis = t.GetProperties(); if (dt.Columns.Count == 0) { foreach (PropertyInfo pi in pis) { if (pi.Name == "Thumbnails") { dt.Columns.Add(pi.Name, Type.GetType("System.String")); } else { dt.Columns.Add(pi.Name, pi.PropertyType); } } } DataRow dr = dt.NewRow(); foreach (PropertyInfo pi in pis) { if (pi.Name == "Rating") { continue; } if (pi.Name == "Thumbnails") { var value = pi.GetValue(obj, null); var thumbs = (ExtensionCollection <MediaThumbnail>)value; dr[pi.Name] = thumbs[4].Url; } else { if (pi.Name == "ResponseUri") { continue; } var value = pi.GetValue(obj, null); dr[pi.Name] = value; } } dt.Rows.Add(dr); } return(dt); }
private void deleteVideoCmd() { List <VideoMedia> tmp = new List <VideoMedia>(); IEnumerable <VideoMedia> lm = ListVideos.Where(m => m.IsSelected == true); foreach (VideoMedia m in lm) { tmp.Add(m); } foreach (VideoMedia m in tmp) { ListVideos.Remove(m); } saveVideos(); }
private void saveVideos() { try { using (FileStream stream = new FileStream(@"../../library/videos.xml", FileMode.Truncate)) { XmlSerializer serializer = new XmlSerializer(typeof(List <VideoMedia>)); serializer.Serialize(stream, ListVideos.ToList()); }; } catch (Exception) { MessageBox.Show("Error occured when saving songs library" + Environment.NewLine + "Be sure you've correct permissions", "Playlist Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public static IEnumerable <Video> Search(string videoQuery, string author, string orderby, bool racy, string time, string category) { YouTubeQuery query = new YouTubeQuery(YouTubeQuery.TopRatedVideo); if (String.IsNullOrEmpty(videoQuery) != true) { query.Query = videoQuery; } if (String.IsNullOrEmpty(author) != true) { query.Author = author; } if (String.IsNullOrEmpty(orderby) != true) { query.OrderBy = orderby; } if (racy == true) { query.SafeSearch = YouTubeQuery.SafeSearchValues.None; } if (String.IsNullOrEmpty(time) != true) { if (time == "All Time") { query.Time = YouTubeQuery.UploadTime.AllTime; } else if (time == "Today") { query.Time = YouTubeQuery.UploadTime.Today; } else if (time == "This Week") { query.Time = YouTubeQuery.UploadTime.ThisWeek; } else if (time == "This Month") { query.Time = YouTubeQuery.UploadTime.ThisMonth; } } if (String.IsNullOrEmpty(category) != true) { QueryCategory q = new QueryCategory(new AtomCategory(category)); query.Categories.Add(q); } return(ListVideos.GetVideos(query)); }
private async Task <ListVideos> GetVidsAsync() { var res = new ListVideos(); var result = new YoutubeResult(); try { res.lsVideos = new List <YoutubeAPIViewModel>(); var path = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=50&playlistId=PLAC325451207E3105&key=AIzaSyB7cEKc5O5lr9aF10Gr3ODo_AFbIGOjjHM"; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsAsync <YoutubeResult>(); foreach (var item in result.items) { var vidRes = new VideoResult(); var uri = $"https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id={item.contentDetails.videoId}&key=AIzaSyB7cEKc5O5lr9aF10Gr3ODo_AFbIGOjjHM"; HttpResponseMessage resp = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { vidRes = await resp.Content.ReadAsAsync <VideoResult>(); var you = new YoutubeAPIViewModel { Id = vidRes.items.FirstOrDefault().id, Title = vidRes.items.FirstOrDefault().snippet.title, Description = vidRes.items.FirstOrDefault().snippet.description, //Tumbnail = vidRes.items.FirstOrDefault().snippet.thumbnails.FirstOrDefault().medium.url }; res.lsVideos.Add(you); } } } } catch (Exception ex) { throw ex; } return(res); }
private void addVideoCmd() { OpenFileDialog dialog = new OpenFileDialog(); bool? res; dialog.Multiselect = true; dialog.Filter = "Video files|*.wmv;*.avi;*.mpg;*.mov;*.asf;*.mkv"; res = dialog.ShowDialog(); if (res == true) { foreach (string file in dialog.FileNames) { VideoMedia tmp = Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))) as VideoMedia; if (tmp != null) { ListVideos.Add(tmp); } } } saveVideos(); }
public MainWindow() { InitializeComponent(); infoVideo = new InfoVideo(this); watchVideo = new WatchVideo(); SenderVideo = new SendVideo(GetVideo); SenderIV = new SendIV(GetIV); List <VideoInfo> lst = new List <VideoInfo> { new VideoInfo { Path = @"E:\HoangTrung\LTUDQL2\LTUDQL2---DACK\1660661\02.mp4", Title = "Mavarl" }, new VideoInfo { Trailer = @"E:\HoangTrung\LTUDQL2\LTUDQL2---DACK\1660661\02.mp4", Title = "Mavarl2" }, new VideoInfo { Trailer = @"E:\HoangTrung\LTUDQL2\LTUDQL2---DACK\1660661\02.mp4", Title = "Thond" }, new VideoInfo { Trailer = @"E:\HoangTrung\LTUDQL2\LTUDQL2---DACK\1660661\02.mp4", }, new VideoInfo { Trailer = @"E:\HoangTrung\LTUDQL2\LTUDQL2---DACK\1660661\02.mp4", }, new VideoInfo { }, new VideoInfo { }, new VideoInfo { }, new VideoInfo { }, new VideoInfo { }, new VideoInfo { }, new VideoInfo { }, new VideoInfo { }, }; var l1 = new ListVideos(this); l1.SetListvideo(lst); l1.SetName("Phim Hành Động"); stackPn.Children.Add(l1); var l2 = new ListVideos(this); l2.SetListvideo(lst); l2.SetName("Phim Ma"); stackPn.Children.Add(l2); lstvideo.Add(l1); lstvideo.Add(l2); //l3.SetListvideo(lst); //l3.SetName("Phim Hoạt Hình"); //l4.SetListvideo(lst); //l4.SetName("Phim Viễn Tưởng"); //l5.SetListvideo(lst); //l5.SetName("Phim Cổ Trang"); //l6.SetListvideo(lst); //l6.SetName("Phim Tào Lao"); }
private static IEnumerable <Video> GetVideos(string videofeed) { YouTubeQuery query = new YouTubeQuery(videofeed); return(ListVideos.GetVideos(query)); }
private static IEnumerable <Video> GetVideos(string videofeed, string userName, string password) { YouTubeQuery query = new YouTubeQuery(videofeed); return(ListVideos.GetVideos(query, userName, password)); }
private void clearVideos() { ListVideos.Clear(); saveVideos(); }