本文介绍了谷歌Chromecast SDK TearDown在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 使用iOS发件人API框架,当我的应用程序进入后台时,SDK会删除所有连接,并且在将应用程序放回前台之前我无法启动任何其他媒体。我的应用程序播放音频,并允许在后台运行和流式传输。是否可以选择告诉Googlecast框架保持套接字打开?Using the iOS Sender API Framework, when my application goes in the background, the SDK tears down all connections and I cannot launch any more media until the app is put back in the foreground. My app plays audio and is allowed to run and stream in the background. Is there an option to tell Googlecast framework to keep the sockets opened?这是登录后台的日志:信息:将辞职活动信息:现在在后台罚款: - [GCKCastSocket disconnect] disconnectFINE: -[GCKCastSocket disconnect] disconnect精细: - [GCKCastSocket doTeardownWithError:] doTeardownWithErrorFINE: -[GCKCastSocket doTeardownWithError:] doTeardownWithError精细: - [GCKCastSocket doTeardownWithError:]通知委托说套接字是已断开连接FINE: -[GCKCastSocket doTeardownWithError:] notifying delegate that socket is disconnected精细: - [GCKHeartbeatChannel didDisconnect]已断开连接 - 必要时停止心跳计时器FINE: -[GCKHeartbeatChannel didDisconnect] disconnected - stopping heartbeat timer if necessary精细: - [GCKCastSocket socketDidDisconnect:withError:] socketDidDisconnect:withError:(null)FINE: -[GCKCastSocket socketDidDisconnect:withError:] socketDidDisconnect:withError: "(null)"然后当应用程序恢复时: INFO:进入前台Then when the app resumes:INFO: Going into foreground FINE: - [GCKCastSocket doTeardownWithError:] doTeardownWithErrorFINE: -[GCKCastSocket doTeardownWithError:] doTeardownWithError FINE: - [GCKCastSocket doTeardownWithError:]通知委托,套接字已断开连接FINE: -[GCKCastSocket doTeardownWithError:] notifying delegate that socket is disconnected精细: - [GCKC astSocket connectToHost:port:withTimeout:]在端口8009l上连接到192.168.1.4...FINE: -[GCKCastSocket connectToHost:port:withTimeout:] Connecting to "192.168.1.4" on port 8009l...信息:变为活动精细: - [GCKCastSocket socket:didConnectToHost:port:] socketDidConnect:FINE: -[GCKCastSocket socket:didConnectToHost:port:] socketDidConnect:精细: - [GCKCastSocket socketDidSecure:] socketDidSecure:FINE: -[GCKCastSocket socketDidSecure:] socketDidSecure:精细: - [GCKCastSocket套接字:didReadData:withTag:]前缀读取,预期消息长度= 1307FINE: -[GCKCastSocket socket:didReadData:withTag:] prefix read, expected message length=1307精细: - [GCKDeviceAuthChannel didReceiveBinaryMessage:]正版Google设备didDeviceAuthenticated = YESFINE: -[GCKDeviceAuthChannel didReceiveBinaryMessage:] Genuine Google device didDeviceAuthenticated=YES精细: - [GCKDeviceManager deviceAuthChannelDidAuthenticate:]正宗设备,连接接收器频道FINE: -[GCKDeviceManager deviceAuthChannelDidAuthenticate:] Authentic device, connecting receiver channel精细: - [GCKCastSocket套接字:didReadData:withTag:]前缀读取,预期消息长度= 474FINE: -[GCKCastSocket socket:didReadData:withTag:] prefix read, expected message length=474精细: - [GCKDeviceManager receiverControlChannel:didReceiveStatusForApplication:]应用程序到join(CC1AD845)可用FINE: -[GCKDeviceManager receiverControlChannel:didReceiveStatusForApplication:] Application to join (CC1AD845) is available FINE: - [GCKDeviceManager connectAndNotifyDidConnectToApplication:launc hedApplication:]连接到应用程序< 0x1467c8f0:GCKApplicationMetadata>默认媒体接收器(CC1AD845),传输ID web-11FINE: -[GCKDeviceManager connectAndNotifyDidConnectToApplication:launchedApplication:] Connected to application <0x1467c8f0:GCKApplicationMetadata> Default Media Receiver (CC1AD845), transport ID web-11精细: - [GCKCastSocket socket:didReadData:withTag: ]前缀读取,预期消息长度= 135FINE: -[GCKCastSocket socket:didReadData:withTag:] prefix read, expected message length=135罚款: - 收到[GCKMediaControlChannel didReceiveTextMessage:]消息:{type:MEDIA_STATUS,status:[] ,requestId:6}FINE: -[GCKMediaControlChannel didReceiveTextMessage:] message received: {"type":"MEDIA_STATUS","status":[],"requestId":6}推荐答案使用iOS Sender API 2.0版, GCKCastSocket 在收到 UIApplicationDidEnterBackgroundNotification 时关闭,这不是可以配置的东西。With the version 2.0 of the iOS Sender API, the GCKCastSocket is closed upon receiving a UIApplicationDidEnterBackgroundNotification and this is not something that can be configured.这意味着: 当应用在后台时,没有新媒体可以从应用推送到chromecast 无法实现锁定屏幕控制替代方案(仅限自定义接收方):Alternatives (custom receiver only): 发送要播放的媒体列表到接收者 直接从接收器从云端获取新媒体参见这个问题或 this one for more details。See also this question or this one for more details. 这篇关于谷歌Chromecast SDK TearDown在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-15 05:08