jfversluis / Plugin.Maui.Audio

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Speed issues on iOS and Windows

rburnashev85 opened this issue · comments

When I set _audioPlayer.Speed = 0.6 it works on android as expected. On iOS _audioPlayer.Speed is set to 0.60000123 but it sounds at normal speed. On Windows usually it takes from 2 to 10 attempts to set _audioPlayer.Speed to desired value. For widows I use code like this:

 for (int attempt = 1; attempt <= 20; attempt++)
 {
     _audioPlayer.Speed = 0.6;
    
     if (Math.Round(_audioPlayer.Speed, 1) == 0.6)
     {
         break;
     }
     else
     {
         await Task.Delay(10);
     }
 }

It sounds like we have an inconsistency with the accuracy being reported back between Android and iOS which should be easy enough to fix.

As for the behaviour on Windows. Do you see an error or anything reported to the console?

Both for Android and iOS if I set _audioPlayer.Speed = 6 then _audioPlayer.Speed != 0.6. It is something like 0.60000004234. But in Android I hear slower sound. In iOS I hear the sound at original speed.
For Windows it is set exact to 0.6 but not from the first attempt. No any messages in Output window

The same issue. Any update on this?

stackoverflow
rate must be enabled in AVAudioPlayer in order to change the speed (rate) of the audio player.

the following should be set in constructor:
player.EnableRate = true;