GitXplorerGitXplorer
j

Plugin.Maui.Audio

public
267 stars
47 forks
43 issues

Commits

List of commits on branch main.
Verified
ba47f6086fec6d7ee2a389abb502c148971ac3e2

Correct Android speed range (#150)

bbillylo1 committed a day ago
Verified
6ce09e0ab5314c5043313ee87c72e36a1ad2fdd6

Update Info.plist to allow background audio recording permission (#143)

BBenBtg committed 2 months ago
Verified
8afcfb9198b44e8ebe87729be42fd2e513c1caa5

Fix the issue of the audio recording segment repeating at the end on the Android platform (#129)

tt871005y committed 4 months ago
Verified
2b53e193033a09b3c570ccec0d82a1817aacbb68

Fix android crash Dispose() call in PlaybackEnded event (#122)

nndegheselle committed 4 months ago
Verified
7fb26014b7e658aaa2bd1d3a15041f0e49c1ae45

Fixed CurrentPosition on android platform (#116)

tt871005y committed 5 months ago
Verified
fe3bafe8e1db601373db69c049bc21e908e60f31

Remove the dependency on Maui controls (#124)

bbijington committed 5 months ago

README

The README file for this repository.

Plugin.Maui.Audio

Plugin.Maui.Audio provides the ability to play and record audio inside a .NET MAUI application.

Getting Started

API Usage

Plugin.Maui.Audio provides the AudioManager class that allows for the creation of AudioPlayers and AudioRecorders. The AudioManager can be used with or without dependency injection.

AudioManager

There are two different ways in which you can interact with the AudioManager implementation provided by this plugin, they are:

Dependency Injection

You will first need to register the AudioManager with the MauiAppBuilder based on the following example:

builder.AddAudio();

[!NOTE]
You can also customize the shared settings for both audio playback and recording.

You can then enable your classes to depend on IAudioManager as per the following example.

public class AudioPlayerViewModel
{
    readonly IAudioManager audioManager;

    public AudioPlayerViewModel(IAudioManager audioManager)
    {
        this.audioManager = audioManager;
    }

    public async void PlayAudio()
    {
        var audioPlayer = audioManager.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("ukelele.mp3"));

        audioPlayer.Play();
    }
}

Straight usage

Alternatively if you want to skip using the dependency injection approach you can use the AudioManager.Current property.

public class AudioPlayerViewModel
{
    public async void PlayAudio()
    {
        var audioPlayer = AudioManager.Current.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("ukelele.mp3"));

        audioPlayer.Play();
    }
}

Now that you know how to use the AudioManager class, please refer to the following sections:

Acknowledgements

This project could not have came to be without these projects and people, thank you! <3

SimpleAudioPlayer for Xamarin

Basically this plugin, but then for Xamarin. We have been using this in our Xamarin projects with much joy and ease, so thank you so much Adrian (and contributors!) for that. Find the original project here where we have based our project on and evolved it from there.

The Happy Ukelele Song

As a little sample song we wanted something Hawaii/Maui themed obviously, and we found The Happy Ukelele Song which seems to fit that description. Thank you Stanislav Fomin and AudioHero for making it available.