Beispiel #1
0
 public YoutubeSearchPage(ServerConnection serverConnection)
 {
     InitializeComponent();
     youtubeProvider       = new YoutubeProvider();
     this.serverConnection = serverConnection;
     //searchButton.Clicked += searchButton_Click;
     this.Title           = "Kolejkuj";
     this.BackgroundColor = Color.Purple;
 }
Beispiel #2
0
        public async Task CreateYouTube()
        {
            if (string.IsNullOrWhiteSpace(ApiConstants.YouTubeClientId))
            {
                return;
            }
            var youtubsApis = Collection.Values.Where(x => x.ServiceType == ServiceType.YouTube).ToList();

            if (youtubsApis.Any(x => x.Id != YoutubeProvider.DefaultId))
            {
                return;
            }
            var hasGoogle = Collection.Values.Any(x => x.ServiceType == ServiceType.Google);

            //TODO: check for youtube setting.
            //If setting is on, and google is logged in. Then login, create youtube api
            if (hasGoogle)
            {
                if (youtubsApis.Count > 0)
                {
                    Collection.Remove(youtubsApis.First().Id);
                }
                var api     = ApiManager.Shared.CreateApi(MusicPlayer.Api.ServiceType.YouTube);
                var account = await api.Authenticate();

                if (account == null)
                {
                    var youTube = new YoutubeProvider(new NativeMessageHandler());
                    Collection.Add(youTube.Id, youTube);
                    return;
                }
                ApiManager.Shared.AddApi(api);
            }
//			// else just add a normal one too the collection
            else if (youtubsApis.Count == 0)
            {
                var youTube = new YoutubeProvider(new NativeMessageHandler());
                Collection.Add(youTube.Id, youTube);
            }
        }