[英]NWaves Xamarin Android not play wav file
try
{
using (var stream = new FileStream(fistBank, FileMode.Open))
{
var waveFile = new WaveFile(stream);
signal = waveFile[Channels.Left];
}
}
catch(Exception ex)
{
Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show();
}
Added to the project, added permissions for reading files, I get the path to the file.添加到项目中,添加了读取文件的权限,我得到了文件的路径。 I press the button and silence... The file does not play... It does not even generate signals from examples
我按下按钮并静音...文件不播放...它甚至不会从示例中生成信号
I check the wiki of NWaves.我查看了 NWaves 的 wiki。 Playing and recording work only on Windows, since they use winmm.dll and MCI commands.
播放和录制仅适用于 Windows,因为它们使用 winmm.dll 和 MCI 命令。 You could use
MediaPlayer
in Xamarin.Android instead.您可以在 Xamarin.Android 中使用
MediaPlayer
。
string fileName = "WAV_1MG.wav";
var player = new MediaPlayer();
var fd = Application.Context.Assets.OpenFd(fileName);
player.Prepared += (s, e) =>
{
player.Start();
};
player.SetDataSource(fd.FileDescriptor, fd.StartOffset, fd.Length);
player.Prepare();
WAV_1MG.wav
file is in the Android Assets
folder with the AndroidAsset
Build Action. WAV_1MG.wav
文件位于带有AndroidAsset
构建操作的 Android Assets
文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.