1
나는 현재 Windows 8 IDE 용 Visual Studio Express를 사용하여 Windows 8 태블릿 창 8 태블릿 용 화상 채팅 응용 프로그램을 개발 중입니다. MediaCapture를 사용하여 스트림을 캡처 할 수 없습니다. CaptureElement에서 비디오를 캡처 한 다음 테스트 목적으로 미디어 요소에 표시하려고합니다. 기본적으로 IRandomAccessStream을 바이트로 변환하고 그 반대의 경우 미디어 요소에서 변환하려고합니다. 다음은 내 코드입니다.메트로 응용 프로그램에서 비디오 캡처
public sealed partial class MainPage : Page
{
MediaCapture mediaCapture;
IRandomAccessStream randomAccessStream;
public MainPage()
{
this.InitializeComponent();
mediaCapture = new MediaCapture();
randomAccessStream = new InMemoryRandomAccessStream();
}
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
async private void startCapture(object sender, RoutedEventArgs e)
{
await mediaCapture.InitializeAsync();
capturePreview.Source = mediaCapture;
MediaEncodingProfile profile = MediaEncodingProfile.CreateWmv(VideoEncodingQuality.Auto);
await mediaCapture.StartRecordToStreamAsync(profile, randomAccessStream);
}
async private void stopCapture(object sender, RoutedEventArgs e)
{
await mediaCapture.StopRecordAsync();
await randomAccessStream.FlushAsync();
randomAccessStream.Seek(0);
// want to convert this randomAccessStream into byte[]
mediaElement.SetSource(randomAccessStream, "video/x-ms-wmv");
}
}