How can I play a audio file from System.Environment.SpecialFolder.LocalApplicationData in Xamarin Android?
The Error is: Java.IO.IOException: 'setDataSourceFD failed.: status=0x80000000' FD is FileDescriptor? When yes have i to declare it? I've commented him out now, and also in the sample there isn't one....
The file path is consisting of:
string pathToNewFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
string file = Path.Combine(pathToNewFolder, Path.GetFileName(url));
public void PlayAudioFile(string file, int time)
{
var player = new MediaPlayer();
// var fd = global::Android.App.Application.Context.Assets.OpenFd(file);
player.Prepared += (s, e) =>
{
player.SeekTo(Convert.ToInt32(time));
player.Start();
};
player.Reset();
player.SetDataSource(file);
player.Prepare();
}