How to stop casting when another app starts casting?

房东的猫 提交于 2019-12-10 22:46:56

问题


I run two applications, both of which use Cast SDK v2 and the Remote Display API. I start casting from App #1, then go to App #2, press the cast button and select a route.

Expected: App #2 starts casting, App #1 stops casting.

Actual: Immediately after I select a route, App #2's MediaRouter.Callback.onRouteUnselected() is called. Neither app's content shows up on the receiver, but App #1's notification controller remains.

I haven't seen this behavior in Cast SDK v3. Is there any way in Cast SDK v2 to ensure that a prior cast session stops when another app starts casting?


回答1:


I haven't done this yet but you can try implementing a addUpdateListener and perform session.stop when another one starts.

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

Stop the app method:

function stopApp() {
    session.stop(onSuccess, onError);
}


来源:https://stackoverflow.com/questions/39797951/how-to-stop-casting-when-another-app-starts-casting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!