Chapter 4.  Building an Audio Player Application

In this chapter, we move back to native Xamarin. We will integrate native audio functions for processing a sound file using the AVFramework in iOS with the AVAudioSessions, AVAudioSettings, and AVAudioRecorder objects. In Android you will use the MediaPlayer object from the Android.Media library.

Expected knowledge:

  • Some knowledge of either iOS AVAudioSessions, AVAudioSettings, and AVAudioRecorder, or the Android MediaPlayer and MediaRecorder classes
  • NSLayoutConstraints

In this chapter, you will learn the following:

  • Project setup
  • Inversion of control with MVVMCross
  • View models with Xamarin native
  • Creating the bindings
  • NSLayoutContraints
  • MVVMCross setup inside the Portable Class Library
  • Setting up MVVMCross with iOS
  • Setting up MVVMCross with Android
  • The SoundHandler interface
  • Implementing the iOS SoundHandler using the AVAudioPlayer framework
  • The Mvx IoC container
  • The audio player
  • A cleaner code approach to NSLayout
  • Creating AudioPlayerPageViewModel
  • Implementing the Android SoundHandler using the MediaPlayer framework
  • XML and Mvx bindings

Solution setup

Now that we are back to Xamarin native, it's time to get your mind out of XAML and back into native iOS and Android. We aren't going to spend much time on user interface design, but more on audio processing using the native frameworks.

Tip

If you are testing this application on your computer, the microphone will still work as it will be using your laptop's microphone.

As we have looked into cross-platform applications and code sharing, we are going to apply some of these principles to native development and setup an MVVM architecture. Let's begin by setting up three different projects, an iOS, Android, and PCL project:

Solution setup
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.254.118