1

I am interested is there a way to play mp3 files from the phone internal memory using the built in native audio player. I am asking this, because I want to implement an equalizer too, so I am guessing I will have to work with streams.

I know for the MediaPlayer, and the Plugin.Maui.Audio, but I don't know how could I integrate the equalizer in the process.

Any nuget package that can be used as equalizer?

UPDATE:

Reading and search lead me to this plugin. I imported it to my project an tried to add an equalizer to the constructor. For test I wanted to adjust the frequency what I did at the end, but cant figure it out which band does what. Tried to read the documentation of the java implementation, but not got any smarter.

internal AudioPlayer(Stream audioStream)
{
    player ??= new MediaPlayer();
    player.Completion += OnPlaybackEnded;

    if (OperatingSystem.IsAndroidVersionAtLeast(23))
    {
        stream = new MemoryStream();
        audioStream.CopyTo(stream);
        var mediaDataSource = new StreamMediaDataSource(stream);

        equalizer ??= new Equalizer(0, player.AudioSessionId);
        equalizer.SetEnabled(true);

        //what am I setting here, because this works the sound changed ???
        //equalizer.SetBandLevel(0, -1000);
        //equalizer.SetBandLevel(1, -500);
        //equalizer.SetBandLevel(2, -250);
        //equalizer.SetBandLevel(3, 500);
        //equalizer.SetBandLevel(4, 1000);

        player.SetDataSource(mediaDataSource);
        player.Prepare();
    }
    else
    {
        PreparePlayerLegacy(audioStream);
  

} }

Wasyster
  • 2,279
  • 4
  • 26
  • 58

1 Answers1

0

On Android, you can use the MediaPlayer class to play sound. The MediaPlayer class can play audio and video files, and it provides a rich set of features such as seeking, looping, and volume control.

On iOS, you can use the AVFoundation framework to play sound. The AVFoundation framework provides classes for playing, recording, and editing audio and video. To play a sound on iOS, you can use the AVPlayer class.

About using the Equalizer you can check that if the MediaPlayer and AVFoundation support the equalizer. MediaPlayer has the Equalizer you can refer to Equalizer for MediaPlayer for more information.

Guangyu Bai - MSFT
  • 2,555
  • 1
  • 2
  • 8
  • I looked up for Plugin.Maui.Audio source code. I can see that Android has a class that provides the Android.Media.Audiofx library for equilizer. What I can't see how to connect it. – Wasyster Jun 17 '23 at 13:50
  • You can ask for the equalizer support for the Plugin.Maui.Audio on the GitHub. – Guangyu Bai - MSFT Jun 19 '23 at 03:35