예제 #1
0
        public MusicContentPaneViewModel(IGrooveClient grooveClient, GrooveApiErrorViewModel errorViewModel)
        {
            _grooveClient   = grooveClient;
            _errorViewModel = errorViewModel;

            Tracks    = new ObservableCollection <Track>();
            Albums    = new ObservableCollection <Album>();
            Artists   = new ObservableCollection <Artist>();
            Playlists = new ObservableCollection <Playlist>();
        }
예제 #2
0
        public UserProfileViewModel(
            WindowsUniversalUserAccountManager accountManager,
            IGrooveClient grooveClient,
            GrooveApiErrorViewModel errorViewModel)
        {
            _accountManager = accountManager;
            _grooveClient   = grooveClient;
            _errorViewModel = errorViewModel;

            _accountManager.UserSignInChange += (manager, userIsSignedIn) => UserSignInUpdateAsync(userIsSignedIn);
        }
        public MainPage()
        {
            InitializeComponent();

            _userAccountManager = new WindowsUniversalUserAccountManager();
            IGrooveClient grooveClient = GrooveClientFactory.CreateGrooveClient(ApplicationClientId, ApplicationClientSecret, _userAccountManager);

            ErrorViewModel            = new GrooveApiErrorViewModel();
            MusicContentPaneViewModel = new MusicContentPaneViewModel(grooveClient, ErrorViewModel);
            PlayerViewModel           = new PlayerViewModel(grooveClient, ErrorViewModel);
            UserProfileViewModel      = new UserProfileViewModel(_userAccountManager, grooveClient, ErrorViewModel);
        }
        public SyncProgressWindow(IGrooveClient client, MusicBeeApiInterface mbApiInterface, SyncDirection syncDirection, List <MusicBeePlaylist> musicBeePlaylists, List <Playlist> groovePlaylists)
        {
            InitializeComponent();

            _syncHelper        = new SyncHelper(client, mbApiInterface, this);
            _syncDirection     = syncDirection;
            _musicBeePlaylists = musicBeePlaylists;
            _groovePlaylists   = groovePlaylists;
            ErrorResponses     = new List <PlaylistActionResponse>();

            ApplyMusicBeeTheme(mbApiInterface);

            StartSync();
        }
예제 #5
0
        public async Task HelpYouGetStarted()
        {
            // Start by registering an Application on the Groove API Program (see https://developer.microsoft.com/dashboard/groove)

            // Create a client
            IGrooveClient client = GrooveClientFactory.CreateGrooveClient(MicrosoftAppClientId, MicrosoftAppClientSecret);

            // Use null to get your current geography.
            // Specify a 2 letter country code (such as "US" or "DE") to force a specific country.
            string country = null;

            // Search for albums in your current geography
            ContentResponse searchResponse = await client.SearchAsync(
                MediaNamespace.music,
                "Foo Fighters",
                filter : SearchFilter.Albums,
                maxItems : 5,
                country : country);

            Console.WriteLine($"Found {searchResponse.Albums.TotalItemCount} albums");
            foreach (Album albumResult in searchResponse.Albums.Items)
            {
                Console.WriteLine(albumResult.Name);
            }

            // List tracks in the first album
            Album           album          = searchResponse.Albums.Items[0];
            ContentResponse lookupResponse = await client.LookupAsync(
                album.Id,
                extras : ExtraDetails.Tracks,
                country : country);

            // Display information about the album
            album = lookupResponse.Albums.Items[0];
            Console.WriteLine($"Album: {album.Name} (link: {album.GetLink(ContentExtensions.LinkAction.Play)}, " +
                              $"image: {album.GetImageUrl(800, 800)})");

            foreach (Contributor contributor in album.Artists)
            {
                Artist artist = contributor.Artist;
                Console.WriteLine($"Artist: {artist.Name} (link: {artist.GetLink()}, image: {artist.GetImageUrl(1920, 1080)})");
            }

            foreach (Track track in album.Tracks.Items)
            {
                Console.WriteLine($"Track: {track.TrackNumber} - {track.Name}");
            }
        }
예제 #6
0
        private async void LoginButton_Click(object sender, EventArgs e)
        {
            UserTokenManager manager = new UserTokenManager();

            bool success = await manager.LoginAsync();

            if (success)
            {
                _client = GrooveClientFactory.CreateGrooveClient(Secret.CLIENTID, Secret.CLIENTSECRET, manager);
                EnableButtons();
            }
            else
            {
                // show error that login had a failure
                OutputTextBox.Text = "Login failure";
            }
        }
        private async void LoginButton_Click(object sender, EventArgs e)
        {
            UserTokenManager manager = new UserTokenManager();

            try
            {
                bool loginSuccess = await manager.LoginAsync();

                if (loginSuccess)
                {
                    _client = GrooveClientFactory.CreateGrooveClient(Secret.CLIENTID, Secret.CLIENTSECRET, manager);
                    WriteOutputLine("Successfully logged in.");
                    OnLoginSuccess();
                }
                else
                {
                    WriteOutputLine("Error while logging in");
                }
            }
            catch (ConfigurationErrorsException ex)
            {
                WriteOutputLine("Could not save refresh token. Please run as admin to allow saving of refresh token, or you will have to manually authenticate with every request.");
            }
        }
예제 #8
0
 public GrooveImageResolver()
 {
     _groove = Ioc.Resolve <IGrooveClient>();
 }
예제 #9
0
 public PlayerViewModel(IGrooveClient grooveClient, GrooveApiErrorViewModel errorViewModel)
 {
     _grooveClient   = grooveClient;
     _errorViewModel = errorViewModel;
 }
예제 #10
0
 public SyncHelper(IGrooveClient client, MusicBeeApiInterface mbApiInterface, SyncProgressWindow window)
 {
     _client         = client;
     _window         = window;
     _mbApiInterface = mbApiInterface;
 }