我尝试使用以下代码使用 Xamarin 音频记录/播放示例: Example_WorkingWithAudio
在以下Task
我有async
错误:
protected async Task PlayAudioTrackAsync ()
{
audioTrack = new AudioTrack (
// Stream type
Android.Media.Stream.Music,
// Frequency
11025,
// Mono or stereo
ChannelConfiguration.Mono,
// Audio encoding
Android.Media.Encoding.Pcm16bit,
// Length of the audio clip.
buffer.Length,
// Mode. Stream or static.
AudioTrackMode.Stream);
audioTrack.Play ();
await audioTrack.WriteAsync (buffer, 0, buffer.Length);
}
更改为 dot42:
protected async Task PlayAudioTrackAsync()
{
audioTrack = new AudioTrack (AudioManager.STREAM_MUSIC,11025,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
buffer.Length,
AudioTrack.MODE_STREAM
);
audioTrack.Play ();
await audioTrack.WriteAsync(buffer, 0, buffer.Length);
}
如何更改“audioTrack.WriteAsync”?我在这一行有编译器错误。