The SoundHandler interface
One issue with playing audio across multiple platforms is we can't share much code when processing audio. We must create an interface and register implementations through an IoC container.
Our next step is to create the ISoundHandler
interface. In the AudioPlayer.Portable
project, add in a new folder called Sound
. In this folder, add a new file called ISoundHandler.cs
and implement the following:
public interface ISoundHandler { bool IsPlaying { get; set; } void Load(); void PlayPause(); void Stop(); double Duration(); void SetPosition(double value); double CurrentPosition(); void Forward(); void Rewind(); }
Our interface will describe all the functions we will be using to process our audio streams via the AudioPlayerPage
interface.
Now let's go ahead and start with the iOS implementation.