我运行两个应用程序,它们都使用 Cast SDK v2 和远程显示
API。我从应用程序 #1 开始转换,然后转到应用程序 #2,按下转换按钮并选择路线。
预期:应用 #2 开始转换,应用 #1 停止转换。
实际:在我选择路线后,应用程序 #2 的 MediaRouter.Callback.onRouteUnselected()
立即被调用。两个应用程序的内容都不会显示在接收器上,但应用程序 #1 的通知 Controller 仍然存在。
我在 Cast SDK v3 中没有看到这种行为。 Cast SDK v2 中是否有任何方法可以确保当另一个应用程序开始转换时先前的转换 session 停止?
最佳答案
我还没有这样做,但你可以尝试实现 addUpdateListener并执行session.stop当另一个开始时。
addUpdateListener(listener)
Adds a listener that is invoked when the Session has changed. Changes to the following properties will trigger the listener: statusText, namespaces, status, and the volume of the receiver.
Listeners should check the status property of the Session to determine its connection status. The boolean parameter
isAlive
is deprecated in favor of the status Session property. The isAlive parameter is still passed in for backwards compatibility, and is true unless
status = chrome.cast.SessionStatus.STOPPED
停止应用程序方法:
function stopApp() {
session.stop(onSuccess, onError);
}
关于android - 当另一个应用程序开始转换时如何停止转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39797951/