Skip to content

rehdi93/Xamarin-Plugins

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleAudioPlayer

SimpleAudioPlayer plays local files and audio data as a stream. This allows you to store audio data in a portable class library and play it on all supported platforms.

Setup

Platform Support

Platform Version
Xamarin.iOS iOS 7+
Xamarin.Android API 10+
Windows 10 UWP 10+
Xamarin.Mac All
Xamarin.tvOS All

API Usage

Call CrossSimpleAudioPlayer.Current from any project or PCL to gain access to APIs

Properties

Duration: length of audio in seconds

CurrentPosition: current playpack position in seconds

Volume: volume of audio between 0 and 1

Balance: balance between left and right as as double, -1 is left only, 0 is both, +1 is right only

IsPlaying: is the audio currently playing

CanSeek: can the playback position be updated

Methods

Load(Stream audioStream): load a compatible (wav, mp3, etc) audio from a stream

Load(string fileName): load a compatible audio file stored in the executing platform project

Play(): play the currently loaded audio

Stop(): stop playback and reset current position to start (0)

Pause(): pause playback (use Play() to resume)

Seek(double position): seek to a specific location in the audio (in seconds)

Example

Coded in the shared PCL using the Xamarin.Forms dependancy service with mysound.wav stored in the PCL as an Embedded Resource

ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
player.Load(GetStreamFromFile("mysound.wav"));
player.Play();

Or to load multiple instances

var player1 = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
var player2 = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
...

For more examples see the Samples folder or check out https://github.com/adrianstevens/Xamarin-Forms/tree/master/DrumPad2

Contributions

Contributions are welcome! If you find a bug want a feature added please report it.

If you want to contribute code please file an issue, create a branch, and file a pull request.

License

MIT License - see LICENSE.txt

About

Crossplatform Plugins for Xamarin and Xamarin.Forms

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.7%
  • Batchfile 0.3%