在Android上立即停止投射的方法是什么?

huangapple go评论54阅读模式
英文:

How to stop casting immediately on Android?

问题

I need to stop casting after the user enabled it inside my app.
The app listened to MediaRouter.Callback as below:

private val mediaRouterCallback = object : MediaRouter.Callback() {
    override fun onRouteChanged(router: MediaRouter?, route: RouteInfo?) {
        super.onRouteChanged(router, route)
       
        // notify observers that casting occurs
    }
}

Now, in the observers, I need to stop casting immediately when the user should not use casting inside the app.

Let's suppose the code below is inside a Fragment and observes the casting event, so what would be the implementation code for stopCasting() method, for example:

when (event) {
    PreventCasting -> {
        stopCasting()
    }
}
英文:

I need to stop casting after the user enabled it inside my app.
The app listened to MediaRouter.Callback as below:

 private val mediaRouterCallback = object : MediaRouter.Callback() {
    override fun onRouteChanged(router: MediaRouter?, route: RouteInfo?) {
        super.onRouteChanged(router, route)
       
        // notify observers that casting occurs
    }
}

Now, in the observers, I need to stop casting immediately when the user should not use casting inside the app.

Let's suppose the code below is inside a Fragment and observes the casting event, so what would be the implementation code for stopCasting() method, for example:

when (event) {
    PreventCasting -> {
         stopCasting()
    }
}

答案1

得分: 1

如果你想停止投射,只需使用 castContext?.sessionManager?.endCurrentSession(true)

英文:

If you want to stop casting you only need to use castContext?.sessionManager?.endCurrentSession(true)

huangapple
  • 本文由 发表于 2023年2月7日 03:03:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75365527.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定