使用通用应用程序在WP 8.1预览中捕获视频

时间:2014-08-25 18:40:20

标签: xaml windows-phone-8.1

我在移动设备中初始化视频捕获时遇到问题。我希望捕获视频流以在移动设备中预览,并获取捕获以读取QR码,条形码...

等代码

我已经标记了网络摄像头,麦克风和视频库的功能(我认为它不需要,但我标记为测试)。

MainPage.xaml中

<Page
    x:Class="App2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid>
        <Button Click="Button_Click"/>
        <CaptureElement Grid.Row="1" x:Name="myCaptureElement"/>
    </Grid>
</Page>

MainPage.xaml.css

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();

        this.NavigationCacheMode = NavigationCacheMode.Required;
    }
    public async Task StartCapture()
    {
        try
        {
            var _mediaCapture = new MediaCapture();
            await _mediaCapture.InitializeAsync();

            myCaptureElement.Source = _mediaCapture;
            await _mediaCapture.StartPreviewAsync();
        }
        catch (Exception ex)
        {
            throw;
        }
    }
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        //StartCapture().Wait();
    }
    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        await StartCapture();
    }
}

我已经在点击事件和OnNavigatedTo中进行了测试,但它以相同的方式失败。

如果我在移动设备中进行测试,则在 InitializeAsync调用上按F10时出现以下错误:

{System.UnauthorizedAccessException: Access is denied.
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
    at App2.MainPage.<StartCapture>d__0.MoveNext()}

我已经阅读了大量文章,例如更多Permisions,设置devideId,配置设置等等......所有这些都再次失败。

在某些地方告知这是一个问题与版本回到WP8.1预览并建议安装青色版本和其他人说它不需要

¿我如何捕捉图像? ¿有更多人遇到同样的问题?

非常感谢

0 个答案:

没有答案
相关问题