我是 Windows 手机的初学者。我创建了记录器示例,并在 windows phone 7 中成功执行。但我必须在我的应用程序中添加暂停和恢复功能。
注意:我使用麦克风进行录音。
如何将推送和恢复功能放入麦克风进行录音?
或者给我任何在 Windows Phone 中录制的替代解决方案。
这是我的代码..
Microphone mphone;
List<byte[]> memobuffercollection = new List<byte[]>();
DynamicSoundEffectInstance playback;
private void BtnRecords_Click(object sender, RoutedEventArgs e)
{
// Clear the collection for storing the buffers
memobuffercollection.Clear();
// Stop any playback in Progress
playback.Stop();
// Start Recording
mphone.Start();
BtnStop.Opacity = 1;
BtnRecords.Opacity = 0;
}
private void BtnStop_Click(object sender, RoutedEventArgs e)
{
StopRecording();
BtnStop.Opacity = 0;
BtnRecords.Opacity = 1;
}
void StopRecording()
{
// Get the last partial buffer
int sampleSize = mphone.GetSampleSizeInBytes(mphone.BufferDuration);
byte[] extraBuffer = new byte[sampleSize];
int extraBytes = mphone.GetData(extraBuffer);
// Stop Recording
mphone.Stop();
// Create MemoInfo object and add at top of collection
int totalSize = memobuffercollection.Count * sampleSize + extraBytes;
TimeSpan duration = mphone.GetSampleDuration(totalSize);
MemoInfo memoInfo = new MemoInfo(DateTime.UtcNow, totalSize, duration);
memofiles.Insert(0, memoInfo);
// Save Data in IsolatedStorage
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);
}
}
memosListBox.UpdateLayout();
memosListBox.ScrollIntoView(memoInfo);
}
memoinfo 是我的课程,用于为录制的音频提供标题。