android - 当另一个应用程序开始转换时如何停止转换?

标签 android chromecast google-cast android-cast-api

我运行两个应用程序,它们都使用 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/

相关文章:

ffmpeg - 某些视频无法通过错误 MEDIA_UNKNOWN 进行 chromecast

ios - 通过 Chromecast 发送自定义 UIViewController

android - 谷歌 Chromecast Android SDK : RemoteMediaPlayer Load() returns Service_Missing error

android - 有没有办法在 Android/iOS 上的 PhoneGap 中实现视频流?

android - 无法将 UI 元素拖动到 Android 布局 Eclipse

android - 在 Android 5.0 上禁用最近的任务按钮

html - Chromecast 无法播放多个 HTML5 视频

java - HttpMethod.releaseConnection() 和 EntityUtils.consume(entity) 的问题

javascript - 调试 Chromecast 应用程序显示错误消息

Chromecast 无法接收自定义消息(CAF 接收器)