MixRadio Developers - .Net SDK Example Test App

.Net SDK Example: “SDK Explorer”

MixRadio SDK Explorer is an example application demonstrating the use of MixRadio SDK. Usage of nearly every method 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.

Building the application

Clone the application solution source code and open the MixRadioApi.sln file in the Visual Studio. Set MixRadio.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

The MixRadio SDK Explorer is a lean example application showing in detail how to fully take advantage of the MixRadio SDK. The application, like the SDK is divided in two parts, launchers and API. Using launchers is a simple way of introducing MixRadio to an application in a fire-and-forget way.

Below are some example screenshots of the app launcher section and the resulting pages in MixRadio:




Below are some example screenshots of the app API section and the resulting pages within the app:




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 MixRadio in any application. Below you can see all that is needed to launch MixRadio application to show gigs near the current location of the device.

using MixRadio.Phone.Tasks;

namespace MixRadio.TestApp
{
    public partial class MainPage : PhoneApplicationPage
    {
        ...

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

        ...
    }
}

A bit more complex example of 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 MixRadio;
using MixRadio.Tasks;

namespace MixRadio.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;

                List<string> response = null;

                if (this._artistSearch)
                {
                    response = App.ApiClient.SearchArtistsAsync(this.ResponseHandler, this.SearchTerm.Text, 0, 20);
                }
                else
                {
                    response = App.ApiClient.SearchAsync(this.ResponseHandler, this.SearchTerm.Text, itemsPerPage: 20);
                }

                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;
            }
        }

        ...
    }
}

Downloads

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

Contribute to this article

Want to edit or suggest changes to this content? You can edit and submit changes to this article using GitHub.