Euphiny.Maui.Audio.Player 1.3.1

dotnet add package Euphiny.Maui.Audio.Player --version 1.3.1
                    
NuGet\Install-Package Euphiny.Maui.Audio.Player -Version 1.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Euphiny.Maui.Audio.Player" Version="1.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Euphiny.Maui.Audio.Player" Version="1.3.1" />
                    
Directory.Packages.props
<PackageReference Include="Euphiny.Maui.Audio.Player" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Euphiny.Maui.Audio.Player --version 1.3.1
                    
#r "nuget: Euphiny.Maui.Audio.Player, 1.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Euphiny.Maui.Audio.Player@1.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Euphiny.Maui.Audio.Player&version=1.3.1
                    
Install as a Cake Addin
#tool nuget:?package=Euphiny.Maui.Audio.Player&version=1.3.1
                    
Install as a Cake Tool

Maui.Audio.Player

A package which allows you to play audio in your MAUI application. Either use it as a standalone solution or integrate with platform-specific session display implementations such as iOS's NowPlayingInfoCenter and Android's MediaSession.

This package is still in development. Currently, this package is stable and ready to use, but it lacks some nice-to-have features like seeking the audio through the session display notification. If you need such features, you're welcome to submit an issue or PR and I'll take a look into it.

Features

  • Play audio through HTTP streaming.
  • Integrate with NowPlayingInfoCenter or MediaSession.
  • Separated concerns, pick and choose what you need.

Installation

Maui.Audio.Player can be found on NuGet. Install it by using dotnet add package Euphiny.Maui.Audio.Player.

NuGet

Usage

This package provides 3 services, these are:

  1. AudioPlayer, used to actually play audio using the native implementation.
  2. MediaInfoManager, used to set and update the session details using NowPlayingInfoCenter or MediaSession.
  3. AudioPlayerController, the service which combines the AudioPlayer and the MediaInfoManager together to provide an all-in-one api.

To add these services to the dependency container, call UseMauiAudioPlayer in your MauiAppBuilderExtensions.cs file. It is advised to create an AudioPlayerOptions object and use it as an argument to initialize the audio player. Currently only the IconResource is requested on Android, which is used by the media notification as app icon.

public static MauiApp CreateMauiApp()
{
    var audioPlayerOptions = new AudioPlayerOptions();
    
    #if ANDROID
    audioPlayerOptions.IconResource = Resource.Drawable.Icon;
    #endif
    
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()
        .UseMauiAudioPlayer(audioPlayerOptions)
        .ConfigureFonts(fonts =>
        {
            fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
        });
        
    return builder.Build();
}

It is than possible to take IAudioPlayerController as constructor argument and use it to start playing audio:

public void PlayAudio() 
{
    var url = "https://song-url.com";
    var imageUrl = "https://image-url.com";
    var duration = TimeSpan.FromSeconds(150);
    var artists = new List<string>() 
    {
        "Artist 1",
        "Artist 2"
    };
    
    var mediaInfo = new MediaInfo("Name of the song", string.Join(", ", artists), duration, imageUrl);
        
    _audioPlayerController.Start(url, mediaInfo);
}

The AudioPlayerController exposes other methods besides the Start method:

  • Play(), to tell the player to start playing audio, is called internally when starting the player.
  • Pause(), to pause the player
  • Seek(), to move the current position of the player backwards or forwards.

Furthermore, the PlayerInfo property holds the current state of the player, information such as duration, progress and whether the player is playing any audio can be found here.

When the player is done playing the audio stream, the PlaybackEnded event is fired.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.1 157 6/2/2025
1.3.0 109 5/23/2025
1.2.0 148 5/21/2025
1.1.0 228 5/15/2025
1.0.2 153 5/5/2025
1.0.1 146 5/5/2025