-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
play() not working on Xiaomi devices #53
Comments
I have a similar issue, but using an OnePlus 6 with Android 10.0. First I thought it was because of Android 10.0. But in the simulator with Android 10.0 it works fine. Also tested on a Samsung Galaxy 5 with Android 9. There it works fine. |
Yes. The same code works on UWP. I've spent almost a week testing on Xiaomi phones. |
I tested on LG G6 with Android 8 and it works fine. But on Samsung S20 Ultra and OnePlus with Android 10, the devices dont play audio. |
I have the same problem. I may be mistaken, but the problem seems to be because of the format (.wav). I can't play the recorded file on any external player on Xiaomi phones, on others I can. |
I also have a similar problem on a redmi note 8, I can't play the recorded audio, but also the sample app doesn't recognize silences, I have to manually stop the recording... |
Not working on Xiaomi Redmi Note 9 Pro either. Anyone found a solution? I tried using Samsung S8 using Android 9 and it's working fine. |
The problem on this devices arises from the fact that the code in WaveRecorder is wrong as it overwrites the first bytes of audio data with the header (stream Writes do not insert, but replace). I guess that since the header is not correct with the size of the file on some platforms this causes problems reading the file. I fixed this by changing the OnBroadcast by making it write on a MemoryStream instead of the file and then StopRecording is changed roughly as follows: private void StopRecorder()
{
try
{
if (_audioStream != null)
{
_audioStream.OnBroadcast -= OnStreamBroadcast;
_audioStream.OnActiveChanged -= StreamActiveChanged;
using (var fileStream = new FileStream(_filePath, FileMode.Create, FileAccess.Write))
{
using (var fileWriter = new BinaryWriter(fileStream, Encoding.UTF8))
{
//now that audio is finished recording, write a WAV/RIFF header at the beginning of the file
AudioFunctions.WriteWavHeader(fileWriter, _audioStream.ChannelCount, _audioStream.SampleRate,
_audioStream.BitsPerSample, _byteCount);
_memoryAudioStream.Seek(0, SeekOrigin.Begin);
_memoryAudioStream.CopyTo(fileStream);
}
}
}
} Sorry if I am not clear but it's the end of the day and I spent one full day on this. |
Guys check out #64 for the updated code |
Hi folks how did you manage to use this? The NuGet package hasn't been updated so I'm not sure how to get these changes into my project |
I suggest you use the source direcly. This project is abandoned. |
@mattiascibien can you explain how to use a source directly in a pcl project, thanks. |
@josecfvalente donwload the full project form github and add all the .cs files in visual studio. Simple as that. |
I have tested these functions on several devices that are Redmi Note 7, Redmi Y1, Vivo V5 and iPhone6.
I found that audio recording feature works fine. The recorded audio file is being stored as well. But player function is not working on Redmi note 7 and Redmi Y1. On other devices, it works well.
The code is same as stated in the sample application.
Thank you.
The text was updated successfully, but these errors were encountered: