Exemplo n.º 1
0
        public VideosEntry SearchVideos(string query)
        {
            SearchResource.ListRequest listRequest = _service.Search.List("snippet");
            listRequest.Q          = query;
            listRequest.MaxResults = 5;
            listRequest.Type       = "video";

            SearchListResponse resp = listRequest.Execute();

            List <VideoInfo> pool = new List <VideoInfo>();

            foreach (var result in resp.Items)
            {
                pool.Add(new VideoInfo {
                    id        = result.Id.VideoId,
                    title     = result.Snippet.Title,
                    thumbnail = result.Snippet.Thumbnails.Default__.Url
                });
            }
            VideosEntry videos = new VideosEntry {
                selected = pool[0],
                pool     = pool
            };

            return(videos);
        }
Exemplo n.º 2
0
        public static VideosEntry getNext()
        {
            VideosEntry first = playlistState[0];

            playlistState.RemoveAt(0);
            current = first;

            Console.WriteLine(" --- > Pobranie z playlisty. | Ilość: " + playlistState.Count);
            update();
            return(first);
        }
Exemplo n.º 3
0
        public sealed override void Update(List <SpeechResult> results)
        {
            Results = results;

            foreach (var res in results)              //ignore interim results
            {
                if ((ResultType)res.type == ResultType.INTERIM)
                {
                    return;
                }
            }

            //sort in place by confidence (DESC)
            results.Sort((res1, res2) => res1.confidence > res2.confidence ? 0 : 1);

            foreach (var res in results)
            {
                if (regex.IsMatch(res.result))
                {
                    var match = regex.Match(res.result);
                    if (match.Success && match.Groups.Count > 0)
                    {
                        var user_query = match.Groups[match.Groups.Count - 1].Value;

                        VideosEntry videos = YouTube.Instance().SearchVideos(user_query);
                        if (Playlist.getCurrent() == null)
                        {
                            SendData(new SongRequestSchema {
                                res    = "request_song",
                                videos = videos,
                            });
                            Playlist.setCurrent(videos);
                        }
                        else
                        {
                            Playlist.add(videos);
                        }
                        Finished = true;
                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
 public static void clear()
 {
     current = null;
     playlistState.Clear();
 }
Exemplo n.º 5
0
 public static void add(VideosEntry videos)
 {
     playlistState.Add(videos);
     Console.WriteLine(" --- > Dodanie do playlity. | Ilość: " + playlistState.Count);
     update();
 }
Exemplo n.º 6
0
 public static void setCurrent(VideosEntry videos)
 {
     Playlist.current = videos;
     update();
 }