我想播放扩展名为 .wav 的音频文件。当我按下播放键时,我听不到声音。如何停止音频
代码:
using Plugin.AudioRecorder; // you have to download from nuGetPackage
using Xamarin.Essentials;
private AudioPlayer audioPlayer = new AudioPlayer();
public NewEvent()
{
InitializeComponent();
Permissions.CheckStatusAsync<Permissions.Media>();
audioPlayer.Play("alert.wav");
}
private void StopPlay_Clicked(object sender, EventArgs e)
{
audioPlayer.Stop();
}
问题解决了。我将音频文件放入“Assets”文件夹中。并将属性中音频文件的构建操作更改为 AndroidAsset。现在可以用了