public VideoList Get() { var videoList = new VideoList(); var connString = SqlDatabase.GetConnectionString(); var conn = new SqlConnection(connString); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT [Id], [Title], [Key] FROM Videos"; conn.Open(); using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { while (reader.Read()) { var temp = new Video { Id = reader.GetInt32(0), Title = reader.GetString(1), Key = reader.GetString(2) }; videoList.Add(temp); } } } return(videoList); }
async Task <VideoList> getYoutube() { // var url = "http://www.youtube.com/playlist?list=UUy2j4l0auN8DJaQ6itwVWFA"; // var url = "http://www.youtube.com/watch?v="; // タイトル一覧を取得する var youtube = new YouTubeService(new Google.Apis.Services.BaseClientService.Initializer() { ApiKey = "", // Google API key ApplicationName = "VS100Watcher" }); var videos = new VideoList(); var req = youtube.Search.List("snippet"); req.ChannelId = "UCy2j4l0auN8DJaQ6itwVWFA"; // "VisualStudioJapan" のチャンネルID var res = new Google.Apis.YouTube.v3.Data.SearchListResponse(); do { req.PageToken = res.NextPageToken; res = await req.ExecuteAsync(); // Youtube のサムネールをリスト化する foreach (var it in res.Items) { var vi = new Video() { Result = it }; // var cl = new HttpClient(); // var data = await cl.GetByteArrayAsync(vi.ThumUrl); // var bmp = new BitmapImage(); // var mem = new MemoryStream(data); // await bmp.SetSourceAsync( mem.AsRandomAccessStream() ); // vi.ThumImage = bmp; videos.Add(vi); } } while (res.NextPageToken != null && res.NextPageToken != ""); // 番号でソートする var lst = new VideoList(); foreach (var it in videos.OrderBy(x => { if (x.Title.StartsWith("VS100")) { return(x.Title.Replace(" ", "").Replace("-", "")); } else { return(x.Title); } })) { lst.Add(it); Debug.WriteLine(it.Title); } return(lst); }
public void CreateVideo(string name, string genre) { var tempVideo = new Video() { id = availableID, name = name, genre = genre }; availableID++; VideoList.Add(tempVideo); }
private async void LoadData() { HttpClient client = new HttpClient(); var json = await client.GetStringAsync(new Uri("http://localhost:5000/api/Media/movies")); var movielist = JsonConvert.DeserializeObject <IList <Movie> >(json); foreach (var movie in movielist) { VideoList.Add(movie); } FillCategoryListVideoList(); }
public async Task <bool> GetListVideoOnChanel(string ChanelName, CancellationToken token) { if (token.IsCancellationRequested) { throw new OperationCanceledException(); } List <YoutubeVideo> listVideo; try { //----- get all list video on channel-----------// listVideo = await youtubeManager.GetListVideos(ChanelName, token); if (token.IsCancellationRequested) { throw new OperationCanceledException(); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { //-------remove video on list-----------// for (int i = VideoList.Count - 1; i >= 0; i--) { VideoList.RemoveAt(i); } //--- add list video-----// for (int i = 0; i < listVideo.Count; i++) { VideoList.Add(listVideo[i]); } } catch (Exception ex) { throw new OperationCanceledException(); } } ); } catch (Exception ex) { throw new OperationCanceledException(); } return(true); }
/// <summary> /// 展示选择检测列表数量 /// </summary> /// <param name="obj"></param> private void ShowReceiveInfo(ObservableCollection <MetaViewModel> obj) { if (obj.Count == 0) { ReceiveStr = "您还未选择文件"; } else { ReceiveStr = "共选择了" + obj.Count + "个文件"; foreach (var item in obj) { VideoList.Add(item); } } }
public void Load(SearchResult SearchInfo) { this.SearchInfo = SearchInfo; foreach (Album item in SearchInfo.Albums) { AlbumList.Add(new SearchItem(item.Title, item.Artists[0].Name, TimeHelper.ConverIntToString(item.Duration))); } foreach (Track item in SearchInfo.Tracks) { TrackList.Add(new SearchItem(item.Title, item.Artists[0].Name, TimeHelper.ConverIntToString(item.Duration))); } foreach (Video item in SearchInfo.Videos) { VideoList.Add(new SearchItem(item.Title, item.Artists[0].Name, TimeHelper.ConverIntToString(item.Duration))); } }
public void Add(VideoViewModel vm) { VideoList.Add(vm); SelectedList = vm; }