Floating FB popout byF5debug

Programmatically using Nokia MixRadio API in your Windows Phone application

 

In this tutorial you are going to see how to use the Nokia MixRadio Api in the Windows Phone Application. Those who don't know what Nokia MixRadio is all about, earlier it was called Nokia Music API. This API is a service from Nokia which can be used in any platform as its not specific to Windows Phone or Windows 8 but it is also available to Android and other platforms. With this API we can showcase the music contents, charts, mixes and do search with the API which allows users to get the specific level of information that is required to list down the music.

With Nokia MixRadio users can have a experience with music from more than 200 countries with more than 3 million global artists and increasing. This service API is available free of cost from Nokia and can be integrated with any commercial and non commercial apps in any platforms. Ok lets see how we can use it in our application, to start with before we start our development we need to register with Nokia API and get Client information that need to be used in the application. Follow the below steps and get the client ID from the Nokia portal.

Steps:

Step 1 – Navigate to the portal https://account.mixrad.io/developer and sign in with the Nokia account or if you are new user register newly

Step 2 – Once signed in with your user credentials click on Add new app as shown in the screen below.

image

Step 3 – Add the information required like App name, app description and if required an OAuth login provide the return path.

Step 4 – On providing valid information you can click on save and you get Client ID and Client Secret which we need to use in your application as shown in the screen below.

image

 

Step 5 – Navigate to Visual Studio 2012 IDE and start a new project and add a Nuget package NokiaMusic by searching from the list or go to Package Manager console and execute the package name “Install-Package NokiaMusic” as shown in the screen below.

image

Step 6 – Now we are all set, we need to register the API and start getting the content. To start with first create a MusicClient instance and get the data asynchronously from the API source, remember you need to have the ClientID in place to input to the MusicClient Class as it requires the authentication to take place once the API is called to reply back with the response. 

Code:

private async void Button_Click(object sender, RoutedEventArgs e)
       {
           Nokia.Music.MusicClient Nclient = new Nokia.Music.MusicClient("b4825701f1bf9d9aa19f2ee0afb9aa3a");

           var genre = await Nclient.GetGenresAsync();

           foreach (var item in genre)
           {
               // Get the list here and do what ever you want
           }

       }

image
Step 7 – Now we get the details, we can showcase in the User Interface, lets had a small listing and then add the list with the information about the Genres which we query from the Nokia Music API using the MusicClient class as shown in the code below.

private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Nokia.Music.MusicClient Nclient = new Nokia.Music.MusicClient("b4825701f1bf9d9aa19f2ee0afb9aa3a");

            var genre = await Nclient.GetGenresAsync();

            foreach (var item in genre)
            {
                // Get the list here and do what ever you want
                ListCollection.Items.Add(item.Name);

            }

        }

 

Step 8 – Ok we are good to go and get the list of Genres, now if you want to search for a particular Genre we can do that as well and many other API methods which gives us a list of results. The main list of classes that you need to be aware of are as below (from Nokia reference)

Name Description
MusicClient The main class used for interacting with Nokia MixRadio.
Response Contains properties for getting details about the API response.
ListResponse Extends the Response class with details for API responses that contain lists.
MusicItem Base class for items from the MixRadio API that can be searched, such as Artists, Mixes and Products.
Artist Represents a musical artist in the Nokia MixRadio Catalog.
Genre Represents a musical genre in the Catalog such as "Rock".
MixGroup Represents a collection of Mixes. An example MixGroup would be "New Releases" that has Mixes such as "Pop New Releases", "Rock New Releases", etc.
Mix Represents a collection of tracks that can be played through the Nokia MixRadio Windows Phone app.
Product Represents a purchasable music content such as albums, singles or individual tracks in the Catalog.
Price Contains a currency code and numeric value for a Product.
Category Enumeration Denotes the category of an item in the Catalog.
CountryResolver Advanced class for validating a country has availability for the Nokia MixRadio API.
About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter