C# 切换到全息模式时,UWP背景音频不工作

C# 切换到全息模式时,UWP背景音频不工作,c#,uwp,hololens,background-audio,C#,Uwp,Hololens,Background Audio,我是UWP的新手。我在一个测试应用程序2D中设计的应用程序,它使用深度链接启动全息应用程序,然后进行一些音频播放。音频播放机制通过后台任务完成。我已经遵循了微软的基本文档,但当我在全息视图中时,音频似乎不会播放。如果用另一个2D UWP应用程序替换全息应用程序,我可以听到音频 后台任务的代码段 protected async override void OnBackgroundActivated(BackgroundActivatedEventArgs args) { base.OnB

我是UWP的新手。我在一个测试应用程序2D中设计的应用程序,它使用深度链接启动全息应用程序,然后进行一些音频播放。音频播放机制通过后台任务完成。我已经遵循了微软的基本文档,但当我在全息视图中时,音频似乎不会播放。如果用另一个2D UWP应用程序替换全息应用程序,我可以听到音频

后台任务的代码段

protected async override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{

    base.OnBackgroundActivated(args);

    IBackgroundTaskInstance taskInstance = args.TaskInstance;

    System.Diagnostics.Debug.WriteLine("Background activated Requested...");

    await Task.Delay(10000);
    MediaPlayer player = new MediaPlayer();
    player.AutoPlay = true;
    SystemMediaTransportControls systemMediaTransportControls = player.SystemMediaTransportControls;
    systemMediaTransportControls.IsPlayEnabled = true;


    var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
    Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Play video");
    player.SetStreamSource(stream);
    player.Play(); // audio playback doesn't work in holographic mode

}
下面是大部分代码。我也愿意分享整个项目

发现MediaPlayer.AudioCategory未设置为Media。这是限制音频覆盖全息应用程序中的游戏媒体流

这就解决了问题