当另一个应用开始投放时,如何停止投放? [英] How to stop casting when another app starts casting?

查看:125
本文介绍了当另一个应用开始投放时,如何停止投放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行两个应用程序,两个应用程序都使用Cast SDK v2和Remote Display API.我从应用程序1开始投射,然后转到应用程序2,按下投射按钮并选择一条路线.

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.

预期:应用#2开始投放,应用#1停止投放.

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

实际:我选择了一条路线后,立即调用了应用#2的MediaRouter.Callback.onRouteUnselected().两个应用程序的内容都不会显示在接收方上,但是应用程序1的通知控制器仍然存在.

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.

我在Cast SDK v3中没有看到此行为. Cast SDK v2中有什么方法可以确保在另一个应用开始投射时,先前的投射会话停止?

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?

推荐答案

我还没有做到这一点,但是您可以尝试实现 session.stop ,当另一个启动时.

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

addUpdateListener(listener)

添加一个Session更改时调用的侦听器.变化 以下属性将触发侦听器:statusText, 命名空间,状态和接收器的容量.

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.

侦听器应检查Session的status属性以确定 它的连接状态.布尔参数isAlive在以下版本中已弃用 状态为Session的属性. isAlive参数仍然 为向后兼容而传入,除非为

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);
}

这篇关于当另一个应用开始投放时,如何停止投放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆