SystemMediaTransportControls 在 mytoolkit 中以不同的模式错误初始化

The SystemMediaTransportControls were initialized in a different mode error in mytoolkit

当背景音频播放器启动后 运行 mytoolkit 是 return "The SystemMediaTransportControls were initialized in a different mode. Please use the API associated with that mode to complete this operation" 异常。

var url = await MyToolkit.Multimedia.YouTube.GetVideoUriAsync(ID, MyToolkit.Multimedia.YouTubeQuality.Quality480P);

后台播放器未启动时正常。请帮助我,我找不到错误在哪里,有什么解决办法吗...

您是否按照 this guy 对 windows 8 而不是 8.1 的指示进行操作?

"Do NOT use the MediaControl static class to attach handlers for you Windows 8.1 app or you will get the error message"

在您的后台音频播放器代码中使用

var systemMediaControls = SystemMediaTransportControls.GetForCurrentView();
            systemMediaControls.ButtonPressed += systemMediaControls_ButtonPressed;
            systemMediaControls.IsPlayEnabled = true;
            systemMediaControls.IsPauseEnabled = true;
            systemMediaControls.IsNextEnabled = true;
            systemMediaControls.IsPreviousEnabled = true;

async void systemMediaControls_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs args)
    {
        switch (args.Button)
        {
            case SystemMediaTransportControlsButton.Play:
            break;
        }
    }

而不是

MediaControl.PlayPressed += MediaControl_PlayPressed;
             MediaControl.PausePressed += MediaControl_PausePressed;

控制。 我想这对你有帮助..