Cast Session 终止,错误代码为 2005

Cast Session terminates with error code 2005

我正在尝试构建一个非常基本的概念验证投射应用程序,但我的投射会话一直以错误代码 2005 APPLICATION_NOT_RUNNING 结束。

使用默认媒体接收器应用程序 ID 有效。会话连接正常并播放内容。

但是,通过 Google Cast SDK 开发者控制台将应用程序 ID 注册为远程显示接收器后,Cast 会话在启动后突然终止,如日志所示:

12-02 11:51:12.458 19515-8203/? I/CastService: [instance-65] onApplicationConnected: com.company.app applicationId: 80F9586X, name: Company, images.count: 0, namespaces.count: 4, senderAppIdentifier: null, senderAppLaunchUrl: null Flipgrid 8c487445-82cc-4801-8c5d-8084cfacb4dd true
12-02 11:51:12.489 19068-19068/com.company.app W/CastActivity: onSessionStarted
12-02 11:51:12.563 19515-8203/? I/CastDeviceController: [controller-0291 RCNController] calling Listener.onConnected(true)
12-02 11:51:12.608 19515-8203/? I/CastDeviceController: [controller-0291 RCNController] joinApplicationInternal: appId:80F9586X sessionId: joinOptions:joinOptions(connectionType=INVISIBLE)
12-02 11:51:12.620 19515-8203/? I/CastDeviceController: [controller-0291 RCNController] joinApplicationInternal: appId:80F9586X sessionId: joinOptions:joinOptions(connectionType=INVISIBLE)
12-02 11:51:12.627 19515-8203/? I/CastDeviceController: [controller-0291 RCNController] finishDisconnecting; socketError="0 No error", mDisconnectStatusCode=SUCCESS
12-02 11:51:12.627 19515-8203/? I/CastDeviceController: [controller-0291 RCNController] listener.onDisconnected(SUCCESS)
12-02 11:51:13.159 946-1701/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 142]
12-02 11:51:13.588 19515-8203/? I/CastDeviceController: [controller-0292 RCNController] calling Listener.onConnected(true)
12-02 11:51:13.629 19515-8203/? I/CastDeviceController: [controller-0292 RCNController] joinApplicationInternal: appId:80F9586X sessionId: joinOptions:joinOptions(connectionType=INVISIBLE)
12-02 11:51:13.643 19515-8203/? I/CastDeviceController: [controller-0292 RCNController] joinApplicationInternal: appId:80F9586X sessionId: joinOptions:joinOptions(connectionType=INVISIBLE)
12-02 11:51:13.652 19515-8203/? I/CastDeviceController: [controller-0292 RCNController] finishDisconnecting; socketError="0 No error", mDisconnectStatusCode=SUCCESS
12-02 11:51:13.652 19515-8203/? I/CastDeviceController: [controller-0292 RCNController] listener.onDisconnected(SUCCESS)
12-02 11:51:15.068 377-1305/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback speaker
12-02 11:51:15.072 377-1305/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
12-02 11:51:17.590 19515-8203/? I/CastDeviceController: [controller-0289 API] listener.onApplicationDisconnected(APPLICATION_NOT_RUNNING)
12-02 11:51:17.593 19515-8203/? I/CastService: [instance-65] onApplicationDisconnected: com.company.app 8c487445-82cc-4801-8c5d-8084cfacb4dd APPLICATION_NOT_RUNNING
12-02 11:51:17.596 19068-19068/com.company.app E/AudioAttributes: Invalid stream type -1 for AudioAttributes`
12-02 11:51:17.696 19068-19068/com.company.app W/CastActivity: onSessionEnded error=2005 APPLICATION_NOT_RUNNING

关于可能是什么错误的任何想法?

如果您正在播放媒体而不是 RemoteDisplay(似乎是这种情况),您应该使用 Styled 接收器、默认接收器或您自己的自定义接收器; Remote Display Receiver 适用于 Remote Display API(它允许您在电视上呈现来自您的发送器应用程序的视图),而不适用于常规投射应用程序。