×

Bands Around

Bands Around is an example application demonstrating the use of Nokia MixRadio API together with the new Windows Phone 8 Map control in a location aware manner. After calculating the device's current location, the app will show bands and artists originating from the vicinity of that spot. The pushpins, representing the bands and artists, are updated on the fly as user moves around the world by flicking and dragging the map. More information on artists is made available in Nokia MixRadio application, which is launched when a pushpin is tapped.

Getting started

Compatibility

Bands Around is compatible with Windows Phone 8 devices and has been tested on Nokia Lumia 920. Windows Phone 7 is not supported as the application is demonstrates the Windows Phone 8 specific MusicClientAsync class that allows use of the Windows RT async/await pattern.

Using the prebuilt installation package

Download the XAP file and install it on your device by using the Application Deployment tool that comes with the Windows Phone 8 SDK.

Building the application

Download the application solution source code and open the BandsAround.sln file in the Microsoft Visual Studio Express for Windows Phone 8. Start building and running the application by hitting F5 or selecting Start Debugging from the Debug menu.

Design

Bands Around is a lean Windows Phone 8 example application demonstrating the basics of Nokia MixRadio API as well as Nokia MixRadio integration with other Windows Phone features such as locationing and maps. When application is launched, a map centered on device's current position fills the screen. Map is then populated with bands originating around that geographic spot, shown on the map as pushpins.

Pushpins representing the bands are updated on the fly as user drags and flicks the map to make a musical journey through the world. Tapping on a pushpin launches Nokia MixRadio app to an artist details view with a possibility to purchase and download tracks and albums from the selected artist.

Searching artists and bands nearby location

Nokia MixRadio API offers a handy method for requesting bands and artists originating nearby a specified location. The code block below shows all there is to do in order to receive a list of artists originating from device's current position from Nokia MixRadio API.

namespace BandsAround { 

    ...

    public partial class MainPage : PhoneApplicationPage
    {
        // MixRadio API with which to request nearby artists
        MusicClientAsync client = null;

        // A collection of artists represented on the map with Pushpins.
        private ObservableCollection<Artist> nearbyArtists = null;

        ...

        public MainPage()
        {
            this.Loaded += MainPage_Loaded;
            ...
        }  

        private async void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            ...

            if (geoLocator == null)
            {
                geoLocator = new Geolocator();
                Geoposition pos = await geoLocator.GetGeopositionAsync();
 
                if (pos != null && pos.Coordinate != null)
                {
                    Map.Center = new GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude);
                    Map.ZoomLevel = 10;
                    GetNearbyArtists();
                }
            }
        }


        private async void GetNearbyArtists()
        {
            ...

            // Sign up for api appId and appCode at http://api.developer.nokia.com
            if (client == null)
            {
                client = new MusicClientAsync(NOKIA_MUSIC_API_APP_ID, NOKIA_MUSIC_API_APP_TOKEN);
            }

            var res = await client.GetArtistsAroundLocation(Map.Center.Latitude, Map.Center.Longitude, 50, 0, 40);
            if (res.Result != null)
            {
                if (nearbyArtists == null)
                {
                    nearbyArtists = new ObservableCollection<Artist>();
                    this.MapItems.ItemsSource = nearbyArtists;
                }

                for (int i = 0; i < res.Result.Count; i++)
                {
                    ...

                    nearbyArtists.Add(res.Result[i]);

                    ...
                }
            }

            ... 
        }  

Further reading

You can find a definitive guide to Nokia MixRadio API here at Lumia Library. In addition to the source code of Bands Around application, the GitHub codebase contains source code of Nokia MixRadio API Test Application, which is a comprehensive example on how to use Nokia MixRadio API.

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

The article Guide to the Windows Phone 8 Maps API provides extensive information on map control and map related features.

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 20 November 2013

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×