×

Nokia MixRadio SDK Explorer

Nokia MixRadio SDK Explorer is a definitive example application demonstrating the use of Nokia MixRadio API. Usage of nearly every method of the API is covered in the application. The application itself is kept clean and simple in order to make the API usage easy to understand and the source code to be readily reusable in any other piece of software.

Getting started

Compatibility

There is a separate Nokia MixRadio SDK Explorer for both Windows Phone 7 and Windows Phone 8 devices and those have been tested on Nokia Lumia 800 and Nokia Lumia 920 devices. Some API calls launch Nokia MixRadio application in Nokia Lumia Windows Phone 8 devices. These calls will launch a web version of Nokia MixRadio in Windows Phone 7.x and non-Nokia Windows Phone 8.x devices, due to Nokia MixRadio application not being available for these devices.

Building the application

Clone the application solution source code and open the NokiaMusicApi.sln file in the Microsoft Visual Studio Express for Windows Phone 8. Set Nokia.Music.TestApp.Wp8 as a StartUp Project from solution explorer. Start building and running the application by hitting F5 or selecting Start Debugging from the Debug menu.

Design

Nokia MixRadio SDK Explorer is a lean example application showing in detail how to fully take advantage of the Nokia MixRadio API. Application, as well as API is first divided in two parts, launchers and API. Using launchers is a simple way of introducing Nokia MixRadio to an application in a fire-and-forget way. A list of available launchers is shown below with screenshots of launchers view and the resulting pages from Nokia MixRadio application.

MusicSearchTask
ShowArtistTask
ShowGigsTask
PlayMixTask
ShowProductTask
ShowMixesTask
 

API view and various result pages shown to demonstrate the API usage offer access to the rest of the Nokia MixRadio API. A list of MusicClient's methods that are covered in code is shown below with a screenshot of API view as well as some additional pages reached and populated using the API.

SearchArtist
Search
GetTopArtists
GetGenres
GetTopProducts
GetNewReleases
GetTopArtistsForGenre
GetArtistProducts
GetSimilarArtists
GetMixGroups
GetMixes
GetArtistSearchSuggestions
GetSearchSuggestions

Code extracts

Following extracts from the source code serve as an example what is to be found in the source code.

Launchers offer a very simple way of integrating Nokia MixRadio in any application. Below you can see all that is needed to launch Nokia MixRadio application to show gigs near the current location of the device.

using Nokia.Music.Phone.Tasks;

namespace Nokia.Music.TestApp 
{ 
    public partial class MainPage : PhoneApplicationPage
    {
        ...

        private void ShowGigsTask(object sender, RoutedEventArgs e)
        {
            ShowGigsTask task = new ShowGigsTask();
            task.Show();
        }

        ...
    }
}

A bit more complex example of Nokia MixRadio API usage is searching for artists and/or products based on a given search term. A screenshot of a search view after a successful search can be seen above.

using Nokia.Music.Phone; 
using Nokia.Music.Phone.Tasks;

namespace Nokia.Music.TestApp
{ 
    public partial class SearchPage : PhoneApplicationPage
    {
        ...

        private bool _artistSearch = false;

        ... 

        private void PerformSearch(object sender, RoutedEventArgs e)
        {
            if (this.SearchTerm.Text.Trim().Length > 0)
            {
                // Scroll to top...
                if (this.Results.Items != null && this.Results.Items.Count > 0)
                {
                    this.Results.ScrollIntoView(this.Results.Items[0]);
                }

                this.Results.ItemsSource = null;
                this.Loading.Visibility = Visibility.Visible;

                this.SearchTerm.IsEnabled = false;
                this.SearchButton.IsEnabled = false;

                if (this._artistSearch)
                {
                    App.ApiClient.SearchArtists(this.ResponseHandler, this.SearchTerm.Text, 0, 20);
                }
                else
                {
                    App.ApiClient.Search(this.ResponseHandler, this.SearchTerm.Text, itemsPerPage: 20);
                } 
            }
        }

        ...

        private void ResponseHandler<T>(ListResponse<T> response)
        {
            Dispatcher.BeginInvoke(() =>
            {
                this.Loading.Visibility = Visibility.Collapsed;
                this.Results.ItemsSource = response.Result;

                if (response.Result != null && response.Result.Count == 0)
                {
                    MessageBox.Show(@"No results found");
                } 
                else if (response.Error != null)
                {
                    MessageBox.Show(response.Error.Message);
                }

                this.SearchTerm.IsEnabled = true;
                this.SearchButton.IsEnabled = true;
            });
        }

        ... 
    }
}

Further reading

You can find a definitive guide to Nokia MixRadio API here at Lumia Library. In addition the source code of Nokia MixRadio SDK Explorer, the GitHub codebase contains source code of Bands Around, which is a small example demonstrating the use of Nokia MixRadio API together with the new Windows Phone 8 Map control in a location aware manner.

Music Explorer example application provides a complex case of integrating Nokia MixRadio API to a software product.

Downloads

This example application is hosted in GitHub, where you can check the latest activities, report issues, browse source, ask questions or even contribute to the project yourself.


Last updated 9 December 2013

Back to top