コード例 #1
0
        /// <summary>
        /// Runs the authentication process
        /// </summary>
        public async void RunAuthentication()
        {
            Debug.WriteLine("Started authentication Task.");
            var webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000, Clientid,
                Scope.UserLibraryRead);

            try
            {
                _webControl.Spotify = await webApiFactory.GetWebApi();

                _webControl.InitialSetup();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            if (_webControl.Spotify != null)
            {
                return;
            }
            Debug.WriteLine("_spotify is null");
        }
コード例 #2
0
        public async void RunAuthentication()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "63ac5440d56e4958bacadaf58f993a19",
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState);

            try
            {
                _spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }

            Console.WriteLine("Spotify Working");
            isAuthtenticated = true;
            InitialSetup();
        }
コード例 #3
0
        public static async void Auth()
        {
            _spotify = new SpotifyWebAPI()
            {
                UseAuth = false,
            };

            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                Properties.Settings.Default.SpotifyClientID,
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                _spotify = await webApiFactory.GetWebApi();

                authed = true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }
        }
コード例 #4
0
        private async void AuthConnect()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "09a444084b5d41b28ba2c1e79d34be31",
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(60)
                );

            bool check = false;
            int  count = 0;

            while ((_spotifyWeb == null || check) && count < 15)
            {
                count++;
                check = false;
                try
                {
                    _spotifyWeb = await webApiFactory.GetWebApi();

                    Thread.Sleep(1500);
                }

                catch (Exception ex)
                {
                    check = true;
                    Console.WriteLine(ex.Message);
                }
            }

            id = _spotifyWeb.GetPrivateProfile().Id;
        }
コード例 #5
0
        public static async Task AuthoriseAsync()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8888,
                MYSPOTIFY_CLIENTID,
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.PlaylistModifyPrivate | Scope.PlaylistModifyPublic | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                SPOTIFY_INST = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (SPOTIFY_INST == null)
            {
                return;
            }
        }
コード例 #6
0
        public async void ConnectToAPI()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                data._clientId,
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                _spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }
            else
            {
                currentForm.HideSpotifyButton();
                Console.WriteLine("Connected to Spotify.");
            }
        }
コード例 #7
0
    public async void ImplicitGrantAuthShowDialog()
    {
        WebAPIFactory webApiFactory = new WebAPIFactory(
            redirectUriLocal,
            8080,
            clientId,
            Scope.PlaylistModifyPrivate | Scope.PlaylistModifyPublic | Scope.PlaylistReadCollaborative |
            Scope.PlaylistReadPrivate | Scope.Streaming | Scope.UserFollowModify |
            Scope.UserFollowRead | Scope.UserLibraryModify | Scope.UserLibraryRead |
            Scope.UserModifyPlaybackState | Scope.UserReadBirthdate | Scope.UserReadEmail |
            Scope.UserReadPlaybackState | Scope.UserReadPrivate | Scope.UserReadRecentlyPlayed |
            Scope.UserTopRead,
            TimeSpan.FromSeconds(20),
            "&show_dialog=true"
            );

        try
        {
            //This will open the user's browser and returns once
            //the user is authorized
            _spotify = await webApiFactory.GetWebApi();
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message.ToString());
            Debug.LogError(ex.StackTrace);
            ImplicitGrantAuth();
        }

        if (_spotify == null)
        {
            return;
        }
    }
コード例 #8
0
        public static async void RunAuthentication()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                Bot.Config.SpotifyAPIKey, Scope.Streaming | Scope.UserLibraryRead | Scope.PlaylistReadPrivate);

            try
            {
                spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                Console.WriteLine("SpotifyWebAPI-Init failed. Message:");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Writing log...");
                DiscordBotLog.AppendLog(DiscordBotLog.BuildRuntimeExceptionMessage(ex));
            }

            if (spotify == null)
            {
                return;
            }

            InitialSetup();
        }
コード例 #9
0
        private async void RunAuthentication()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "26d287105e31491889f3cd293d85bfea",
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative);

            try
            {
                _spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }


            InitialSetup();
        }
コード例 #10
0
        public async Task MainAsync()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8500,
                "826dee0fe8264cd58a31afda79f2128e",
                //Scope.UserReadPrivate,
                Scope.PlaylistModifyPublic,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                _spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }
        }
コード例 #11
0
        public async Task <bool> Login()
        {
            try
            {
                var url       = ConfigurationManager.AppSettings[@"Url"];
                var porta     = Convert.ToInt32(ConfigurationManager.AppSettings[@"Porta"]);
                var clienteId = ConfigurationManager.AppSettings[@"ClienteIdSpotify"];

                var webApiFactory = new WebAPIFactory(
                    url,
                    porta,
                    clienteId,
                    Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                    Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                    Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState
                    );

                spotifyWebApi = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(spotifyWebApi != null);
        }
コード例 #12
0
        /// <summary>
        /// Getting the current state of the party's playlist
        /// </summary>
        private async Task RunSpotifyAuthentication()
        {
            var webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "cfbe22855aaf48518cf3009a0ff87b9e",
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState | Scope.PlaylistModifyPublic);

            try
            {
                _spotify = await webApiFactory.GetWebApi();

                _dataStorage._profile = await _spotify.GetPrivateProfileAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }
        }
コード例 #13
0
        public async Task <SpotifyWebAPI> ConnectToSpotifyAsync(SpotifyWebAPI _spotify)
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                44333,
                SPOTIFY_API_KEY,
                Scope.PlaylistModifyPrivate | Scope.PlaylistModifyPublic | Scope.Streaming | Scope.UserFollowModify |
                Scope.UserFollowRead | Scope.UserLibraryRead | Scope.UserReadPrivate | Scope.UserTopRead,
                TimeSpan.FromSeconds(20));

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                _spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                ViewBag.AuthError = ex.Message;
            }

            if (_spotify == null)
            {
                throw new NullReferenceException();
            }

            return(await Task.FromResult <SpotifyWebAPI>(_spotify));
        }
コード例 #14
0
ファイル: Spotify.cs プロジェクト: vicsufer/SpotOsu
        public Spotify(string clientID)
        {
            _spotify = new SpotifyWebAPI();
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                clientID,
                Scope.PlaylistModifyPublic | Scope.PlaylistModifyPrivate,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                _spotify = (webApiFactory.GetWebApi()).Result;
            }
            catch (Exception ex)
            {
                throw new SpotifyException("Unable to connect");
            }

            if (_spotify == null)
            {
                return;
            }
        }
コード例 #15
0
        private async void RunAuthentication()
        {
            var webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "cfbe22855aaf48518cf3009a0ff87b9e",
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState | Scope.PlaylistModifyPublic);

            try
            {
                _spotify = await webApiFactory.GetWebApi();

                //_dataStorage.Spotify = _spotify;
                _dataStorage._profile = await _spotify.GetPrivateProfileAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            if (_spotify == null)
            {
                return;
            }
            _usersRatingForASong.partyID = _dataStorage.CurrentSelectedPartyId;
            _usersRatingForASong.userID  = _dataStorage.UserId;

            getSongsBtn_Click(new object(), new EventArgs());
        }
コード例 #16
0
ファイル: SpotifyHelper.cs プロジェクト: Tfair5597/Echobox
        public static async Task <SearchItem> GrabArtists(string Search) //search for first 50 artists by name
        {
            var artistGetter = new SpotifyWebAPI();



            //implict grant auth
            WebAPIFactory webAPIFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "e81fba25bb5742d0a872e6813c55eb49",
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(20));

            try
            {
                artistGetter = await webAPIFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString() + " this is what went wrong."); //display exception description.
            }

            if (Search != "" || Search != null)
            {
                SearchItem artistsToReturn = artistGetter.SearchItems(Search, SearchType.Artist, 50);


                return(artistsToReturn);
            }
            else
            {
                throw new Exception("Error-B182S4139GA921P - User failed to input a genre");
            }
        }
コード例 #17
0
    /// <summary>
    /// Connectes to the WebHelper with your ClientId
    /// </summary>
    /// <param name="clientId">Custom client id</param>
    /// <returns></returns>
    private bool ConnectSpotifyWebHelper(string clientId, int port = 8000)
    {
        if (!SpotifyLocalAPI.IsSpotifyWebHelperRunning())
        {
            Analysis.LogError("SpotifyWebHelper isn't running!");
            return(false);
        }

        WebAPIFactory webApiFactory = new WebAPIFactory(
            "http://localhost",
            port,
            clientId,
            Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
            Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
            Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState | Scope.Streaming,
            m_proxyConfig);

        try
        {
            m_webAPI = webApiFactory.GetWebApi().Result;
        }
        catch (Exception ex)
        {
            Analysis.LogError($"Unable to connect to WebAPI - {ex}");
        }

        return(m_webAPI != null);
    }
コード例 #18
0
        /// <summary>
        /// fait l authentification pour Spotify, retourne True si l operation reussi
        /// et false sinon
        /// </summary>
        /// <returns>Task<bool></returns>
        public async Task <bool> RunAuthentication()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                7000,
                "8554a963221c499fa356f8b4a95e79f8",
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState);

            try
            {
                m_spotifyWebAPI = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (m_spotifyWebAPI == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #19
0
ファイル: Form1.cs プロジェクト: exp111/SpotifySongAdder
        private async void button1_ClickAsync(object sender, EventArgs e)
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "47c0cc6d128c4eb587f7a85a398d0a96",
                Scope.PlaylistReadCollaborative | Scope.PlaylistReadPrivate |
                Scope.UserReadPrivate |
                Scope.PlaylistModifyPrivate | Scope.PlaylistModifyPublic,
                TimeSpan.FromSeconds(20));

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                _spotifyWebAPI = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (_spotifyWebAPI == null)
            {
                return;
            }

            //Change Status Label
            statusInfoLabel.Text      = "Connected";
            statusInfoLabel.ForeColor = Color.Green;

            //Get Profile & Playlists
            _profile = _spotifyWebAPI.GetPrivateProfile();
            GetPlaylists();
        }
コード例 #20
0
        public static async void Authenticate(SpotifyWebAPI spotifyAPI)
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost:8000",
                8000,
                "87a1fe44c407454f9b466def737c236a",
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                spotifyAPI = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }

            if (spotifyAPI == null)
            {
                return;
            }
        }
コード例 #21
0
        public async void Init()
        {
            var webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                ConfigurationManager.AppSettings["SpotifyClientID"],
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                _spotify = await webApiFactory.GetWebApi();

                _user            = _spotify.GetPrivateProfile();
                tracksToDownload = new List <string>();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (_spotify == null)
            {
                return;
            }
        }
コード例 #22
0
        private static async void Authenticate()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost/",
                int.Parse(ConfigurationManager.AppSettings["spotify_api_port"]), // def. 8000
                ConfigurationManager.AppSettings["spotify_client_id"],
                Scope.UserReadPlaybackState,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once the user is authorized.
                _spotify = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (_spotify == null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("AUTH ERROR (1)");
                return;
            }
        }
コード例 #23
0
        public async static void AuthenticateSpotifyWeb()
        {
            //Check first if we already have a token from Spotify.
            if (ApplicationData.Default.SpotifyToken != "")
            {
                spotWeb             = new SpotifyWebAPI();
                spotWeb.AccessToken = ApplicationData.Default.SpotifyToken;
                spotWeb.TokenType   = "Bearer";
                SpotifyAPI.Web.Models.PrivateProfile pp = spotWeb.GetPrivateProfile();
                if (!pp.HasError())
                {
                    // success

                    return;
                }
                else
                {
                    //failed, is token invalid ?
#if DEBUG
                    MessageBox.Show("Auth from saved token failed.");
#endif
                    spotWeb.Dispose();
                }
            }



            System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => System.Windows.MessageBox.Show("Please sign in, to be able to show your play lists.")),
                                                                              System.Windows.Threading.DispatcherPriority.Normal);
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "3a922edff6af43e9be7abb98cf217220",
                Scope.UserReadPrivate | Scope.PlaylistReadPrivate | Scope.UserLibraryRead | Scope.UserReadRecentlyPlayed | Scope.UserTopRead,
                TimeSpan.FromSeconds(60)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                spotWeb = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                spotWeb = null;
                MessageBox.Show(ex.Message);
            }

            if (spotWeb == null)
            {
                return;
            }

            Console.WriteLine("Token retreived succesfully from spotify web service.");
            ApplicationData.Default.SpotifyToken = spotWeb.AccessToken;
            ApplicationData.Default.Save();
            return;
        }
コード例 #24
0
 public MainWindowScene()
 {
     InitializeComponent();
     webApiFactory = new WebAPIFactory(
         "http://localhost",
         8000,
         MainWindow.clientID,
         Scope.PlaylistModifyPrivate | Scope.PlaylistReadPrivate | Scope.UserLibraryRead | Scope.PlaylistModifyPublic |
         Scope.UserFollowRead | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
         Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState,
         TimeSpan.FromSeconds(60));
 }
コード例 #25
0
        public async Task <ActionResult> Index()
        {
            var _webApiFactory = new WebAPIFactory(
                "http://localhost",
                2826,
                "33c0ac01baa6477da389527c1c6cef90",
                Scope.UserReadPrivate | Scope.PlaylistReadPrivate,
                TimeSpan.FromSeconds(20)
                );

            try
            {
                //This will open the user's browser and returns once
                //the user is authorized.
                var _spotify = _webApiFactory.GetWebApi().Result;
            }
            finally
            {
            }

            using (var client = new HttpClient())
            {
                var headers = client.DefaultRequestHeaders;
                headers.Add("Authorization", string.Format("Bearer {0}", Request.QueryString["access_token"].Value));
                HttpResponseMessage message = await client.GetAsync("https://api.spotify.com/v1/me/playlists");

                using (var responseStreamAllPlaylists = await message.Content.ReadAsStreamAsync())
                    using (var readerAllPlaylists = new StreamReader(responseStreamAllPlaylists))
                    {
                        string allplaylist;

                        string allPlaylistsString = readerAllPlaylists.ReadToEnd();

                        var allPlaylistsJson = JObject.Parse(allPlaylistsString);
                    }
            }



            FullTrack track = null; // _spotify.GetTrack("3Hvu1pq89D4R0lyPBoujSv");
            var       user  = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var spotifyUsername = user == null ? "" : user.Logins.First().ProviderKey;

            return(View(new HomeViewModel {
                SpotifyUsername = spotifyUsername, Track = null                             /*track.Name*/
            }));
        }
コード例 #26
0
        /// <summary>
        /// Connects to the API.
        /// </summary>
        /// <remarks>
        /// If the connexion fails, a message box will open to inform the user.
        /// </remarks>
        private async void connect()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory("http://localhost", 8888, "6ac9eb8c694441748f29683de12b50b7", SpotifyAPI.Web.Enums.Scope.UserReadPrivate, TimeSpan.FromSeconds(25));

            try
            {
                _spotifyAPI = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                _spotifyAPI = null;
                // Raise the flag
                problemDuringConnexionFlag = true;
                Console.WriteLine("Connexion failed at some point.");
                Console.WriteLine(ex.Message);
            }
        }
コード例 #27
0
        static SpotifyService()
        {
            _clientId = ConfigurationManager.AppSettings["SpotifyAPI.ClientID"];

            _spotifyApiFactory = new WebAPIFactory("http://localhost/", 8000, _clientId, SpotifyScopes, Timeout.InfiniteTimeSpan, new ProxyConfig());

            //_spotify = new SpotifyWebAPI(new ProxyConfig());



            //_spotify.OnPlayStateChange += SpotifyLocalOnOnPlayStateChange;
            //_spotify.OnTrackChange += SpotifyLocalOnOnTrackChange;
            //_spotify.OnTrackTimeChange += SpotifyLocalOnOnTrackTimeChange;
            //_spotify.OnVolumeChange += SpotifyLocalOnOnVolumeChange;

            TryConnect();
        }
コード例 #28
0
ファイル: SpotifyHelper.cs プロジェクト: Tfair5597/Echobox
        public static async Task <string> GetGenre() //get first recommended genre
        {
            var    genreGetter   = new SpotifyWebAPI();
            string GenreToReturn = "";


            //implict grant auth
            WebAPIFactory webAPIFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "e81fba25bb5742d0a872e6813c55eb49",
                Scope.UserReadPrivate,
                TimeSpan.FromSeconds(20));

            try
            {
                genreGetter = await webAPIFactory.GetWebApi();
            }
            catch (Exception ex)
            {
            }

            if (genreGetter == null)
            {
                throw new NullReferenceException("Something went wrong... Sorry! Make sure you are authorized correctly.");
            }

            Task <RecommendationSeedGenres> asyncronousGenre = genreGetter.GetRecommendationSeedsGenresAsync();

            genreGetter.UseAuth = true;
            string AccessTest = genreGetter.AccessToken;

            RecommendationSeedGenres ReccoGenres = asyncronousGenre.Result;

            string[] arrayOfGenres = new string[145];


            arrayOfGenres = ReccoGenres.Genres.ToArray();
            Random rand = new Random();

            GenreToReturn = arrayOfGenres[rand.Next(146)];

            return(GenreToReturn);
        }
コード例 #29
0
        /// <summary>
        ///     Leitet die Authentifizierung des Nutzers auf der Spotify-Authentifizierungsseite ein
        /// </summary>
        public async void Authenticate()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                Constants.SpotifyApiKey,
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState | Scope.UserModifyPlaybackState);

            try
            {
                _spotifyWebApi = await webApiFactory.GetWebApi();
            }
            catch (Exception e)
            {
                Console.WriteLine("Spotify could not connect: " + e.Message);
            }
        }
コード例 #30
0
ファイル: SpotifyApi.cs プロジェクト: rcoliveira2016/APS
        public async Task <bool> Login()
        {
            WebAPIFactory webApiFactory = new WebAPIFactory(
                "http://localhost",
                8000,
                "26d287105e31491889f3cd293d85bfea",
                Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibraryRead |
                Scope.UserFollowRead | Scope.UserReadBirthdate | Scope.UserTopRead | Scope.PlaylistReadCollaborative |
                Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState);

            try
            {
                spotifyWebApi = await webApiFactory.GetWebApi();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(spotifyWebApi != null);
        }