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 ...
Get Xamarin Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.