Framework for audio playback
See original GitHub issueDescription
Currently, Maui does not have any audio playback framework. Implementing such an API is relatively simple. However, I noticed that in places like Stackoverflow there are many examples for Xamarin that have memory leaks and other bugs for various reasons. I know that now, when we are approaching the release, it is quite late to add such a large interface, but I think that it is worth considering as part of long-term plans in order to systematize some assumptions.
API content
I think the first step should be classes that allow to:
- Play, pause, stop audio,
- Set position, playback volume,
- Implement custom, low-level filters on the stream.
Then we might consider adding:
- Changing the pitch, panorama of the sound played,
- Recording audio from a microphone,
The most important difficulties
Windows, iOS, Mac, and Android all have different sets of audio formats supported by default. For example, iOS does not natively support the OGG format. Interfaces returning a list of supported codecs / containers and good documentation would be necessary.
If this proposal is accepted, I will gladly implement it.
Public API Changes
We should add custom interface, something like Microsoft.Maui.Media.Audio
Intended Use-Case
Many apps use simple audio for informing users about in-app events. Implementing that option in Maui would simplify the work needed and encourage more developers to use this.
Issue Analytics
- State:
- Created a year ago
- Reactions:15
- Comments:10
Top GitHub Comments
.Net MAUI is in RC Status. in my opinion not having any supported sound library should be addressed. We can use essentials to play a sound using the launcher functionality. But if all I need is a beep in my app, that is not really a good user experience. I know there is already some ideas in the pipeline, but Sound and Media (Camera/Scanner) is a must for all platforms… at least in today’s world.
This is a needed feature. There are tutorials on YouTube (eg. https://youtu.be/3jcVYUE-Tww) featuring MSFT employees such as @jamesmontemagno demonstrating the creation of games. While MAUI wouldn’t be a good solution for most games, basic games, such as card games could be developed using .Net MAUI. Even with these videos describing the creation of real-time games, there is no way to play sounds within .Net MAUI. Without the ability to play sounds, using MAUI for basic games is not practical. Games require sounds. There’s no reason why .Net MAUI couldn’t work as a solution for 2D games, like Solitaire.