Google Cast:检测加载失败的 QueueItems

Google Cast: Detect QueueItems that fail to load

我有一个 Chrome 发送器应用程序,它使用 Styled Media Receiver 播放排队的音轨列表。

为了排队/自动播放项目,我预先创建了一个 QueueLoadRequest,其中包含列表中每个项目的 URL。在播放期间的某个时刻(例如,URL 已过期),曲目可能无法加载。

我希望能够检测到这种情况 - 队列中的项目未能加载,但我找不到任何可以简洁地执行此操作的东西。

例如,如果您当前正在播放音轨(曲目 1),并且很快会自动前进到 曲目 2,其中有一个 URL 将无法加载:

Media.addUpdateListener() 注册的侦听器将在 track 2 加载失败时被调用,但只会报告 playerState 'Idle'idleReason 永远给出 'Interrupted'.

为了确定是否存在任何类型的错误,当发现 'Idle' 状态时,您必须调用 Media.getStatus().在此调用的成功回调中,如果您再次检查 playerState,它仍然报告为 'Idle',但现在给出的原因是 'Error'。在这一点上,我们必须做出相当大的假设,即这是由媒体 URL 加载失败引起的。

一定有更好的方法吗?

远程调试器日志

当跳到失败轨道时,远程调试器日志显示 401 发生并表明已发送 LOAD_FAILED 消息,但它似乎从未在发件人中实现。

GET http://<REDACTED_URL_THAT_THROWS_A_401> 401 (Unauthorized)g.load @ cast_receiver.js:64X.tc @ cast_receiver.js:119Wc @ player.js:50Nc @ player.js:46Y.O @ player.js:40h.ta @ player.js:58id @ cast_receiver.js:118qd @ cast_receiver.js:126g.Cc @ cast_receiver.js:135X.sb @ cast_receiver.js:106R.tb @ cast_receiver.js:35Db @ cast_receiver.js:24g.dispatchEvent @ cast_receiver.js:23g.ub @ cast_receiver.js:33Db @ cast_receiver.js:24g.dispatchEvent @ cast_receiver.js:23g.ub @ cast_receiver.js:30
cast_receiver.js:40  [ 50.331s] [cast.receiver.MediaManager] Load metadata error: [object Object]$b @ cast_receiver.js:40Yb.hc @ cast_receiver.js:40B.log @ cast_receiver.js:13J @ cast_receiver.js:14X.qb @ cast_receiver.js:123g.qb @ cast_receiver.js:61zb @ cast_receiver.js:20wb @ cast_receiver.js:21(anonymous function) @ cast_receiver.js:19
cast_receiver.js:40  [ 50.890s] [cast.receiver.IpcChannel] IPC message sent: {"namespace":"urn:x-cast:com.google.cast.system","senderId":"SystemSender","data":"{\"type\":\"setappstate\",\"statusText\":\"Now Casting: <REDACTED_AUDIO_TITLE>\"}"}
cast_receiver.js:40  [ 50.918s] [cast.receiver.MediaManager] Sending error message to 
cast_receiver.js:40  [ 50.924s] [cast.receiver.IpcChannel] IPC message sent: {"namespace":"urn:x-cast:com.google.cast.media","senderId":"","data":"{\"requestId\":0,\"type\":\"LOAD_FAILED\"}"}
cast_receiver.js:40  [ 50.934s] [cast.receiver.MediaManager] MediaManager message received
cast_receiver.js:40  [ 50.940s] [cast.receiver.MediaManager] Dispatching MediaManager getStatus event
cast_receiver.js:40  [ 50.945s] [cast.receiver.MediaManager] onGetStatus
cast_receiver.js:40  [ 50.950s] [cast.receiver.MediaManager] onGetStatus: {"mediaSessionId":1,"sessionId":"5D841D2B-AB1E-4CD3-ACC9-B308A164E77C","requestId":70783069}
cast_receiver.js:40  [ 50.957s] [cast.receiver.MediaManager] Sending status message to 11:client-99231
cast_receiver.js:40  [ 50.964s] [cast.receiver.IpcChannel] IPC message sent: {"namespace":"urn:x-cast:com.google.cast.media","senderId":"11:client-99231","data":"{\"type\":\"MEDIA_STATUS\",\"status\":[{\"mediaSessionId\":1,\"playbackRate\":1,\"playerState\":\"IDLE\",\"currentTime\":0,\"supportedMediaCommands\":15,\"volume\":{\"level\":1,\"muted\":false},\"media\":{\"contentId\":\"https://<REDACTED_URL_THAT_THROWS_A_401>\",\"streamType\":\"BUFFERED\",\"contentType\":\"audio/mp3\",\"metadata\":{\"type\":3,\"metadataType\":3,\"title\":\"<REDACTED_AUDIO_TITLE>\",\"artist\":\"<REDACTED_ARTIST>\",\"trackNumber\":2,\"images\":[{\"url\":\"//<REDACTED_IMAGE_URL>\"}]}},\"currentItemId\":2,\"idleReason\":\"ERROR\"}],\"requestId\":70783069}"}

根据上述评论,这已作为针对 Cast SDK 的问题提出。