Windows phone 7 在silverlight wp7中录制扬声器发出的声音
我需要在一个文件中记录不同的声音。文件可能是.mp3、.wav等。如何在windows phone 7中实现此功能?在windows phone中有一种简单的方法。您基本上使用的是框架提供的麦克风类。有关此主题的精彩文章,请访问 无效OnRecordButtonClickobject发送方,RoutedEventArgs参数 { 如果麦克风.State==麦克风状态.Stopped { //清除用于存储缓冲区的集合 备忘录收集。清晰Windows phone 7 在silverlight wp7中录制扬声器发出的声音,windows-phone-7,Windows Phone 7,我需要在一个文件中记录不同的声音。文件可能是.mp3、.wav等。如何在windows phone 7中实现此功能?在windows phone中有一种简单的方法。您基本上使用的是框架提供的麦克风类。有关此主题的精彩文章,请访问 无效OnRecordButtonClickobject发送方,RoutedEventArgs参数 { 如果麦克风.State==麦克风状态.Stopped { //清除用于存储缓冲区的集合 备忘录收集。清晰 // Stop any playbac
// Stop any playback in progress (not really necessary, but polite I guess)
playback.Stop();
// Start recording
microphone.Start();
}
else
{
StopRecording();
}
// Update the record button
bool isRecording = microphone.State == MicrophoneState.Started;
UpdateRecordButton(isRecording);
}
void StopRecording()
{
// Get the last partial buffer
int sampleSize = microphone.GetSampleSizeInBytes(microphone.BufferDuration);
byte[] extraBuffer = new byte[sampleSize];
int extraBytes = microphone.GetData(extraBuffer);
// Stop recording
microphone.Stop();
// Create MemoInfo object and add at top of collection
int totalSize = memoBufferCollection.Count * sampleSize + extraBytes;
TimeSpan duration = microphone.GetSampleDuration(totalSize);
MemoInfo memoInfo = new MemoInfo(DateTime.UtcNow, totalSize, duration);
memoFiles.Insert(0, memoInfo);
// Save data in isolated storage
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = storage.CreateFile(memoInfo.FileName))
{
// Write buffers from collection
foreach (byte[] buffer in memoBufferCollection)
stream.Write(buffer, 0, buffer.Length);
// Write partial buffer
stream.Write(extraBuffer, 0, extraBytes);
}
}
// Scroll to show new MemoInfo item
memosListBox.UpdateLayout();
memosListBox.ScrollIntoView(memoInfo);
}