android - 我无法让 Cast Companion Library 通知发挥作用

标签 android chromecast castcompanionlibrary

我正在使用 Cast Companion 库,它大部分工作正常,我得到了迷你播放器,还有锁屏控件和播放内容的 Activity ,但我永远无法显示通知屏幕。我在初始化时执行以下操作:

mCastMgr.enableFeatures(VideoCastManager.FEATURE_NOTIFICATION |
              VideoCastManager.FEATURE_LOCKSCREEN |
              VideoCastManager.FEATURE_DEBUGGING);

我正在恢复时执行 incrementUiCounter() 操作,并在暂停时执行 decrementUiCounter() 操作。

我没有看到任何错误,我只是没有看到我做错了什么。我唯一缺少的是,当我告诉媒体播放时,我没有传递图像的 URL,因为我的 URL 是我的应用程序的本地资源,我只是不确定如何传递这些 URL。

最佳答案

您是在自己的应用程序中使用它还是与 CastVideos-android 一起使用它?如果您自己的应用程序,我建议您首先尝试 CastVideos-android 应用程序,以确保它适合您。

我建议你打印出BaseCastManager.incrementUiCounter()decrementUiCounter()中的mVisibilityCounter的值来看看当你搬进来的时候并且在不同的 Activity 中,它反射(reflect)了正确的计数器。当该计数器达到零时,应该会显示通知。如果计数器达到零并且未显示通知,我建议您检查 list 文件并查看 list 中是否有以下内容:

<service
    android:name="com.google.sample.castcompanionlibrary.notification.VideoCastNotificationService"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.sample.castcompanionlibrary.action.toggleplayback" />
        <action android:name="com.google.sample.castcompanionlibrary.action.stop" />
        <action android:name="com.google.sample.castcompanionlibrary.action.notificationvisibility" />
    </intent-filter>
</service>

(您可以从 CastVideos-android list 文件中复制并粘贴)。您可能已经从文档中了解了它的内容;那里有一个错误(我计划今晚或明天更新一些东西,文档也会更新);基本上,当计数器达到零时,它会调用通知服务(请参阅VideoCastManager中的onUiVisibilityChanged()),如果未正确设置 list 中的该操作,则通知永远不会获取我们的备忘录!如果这不是问题,请告诉我。

关于android - 我无法让 Cast Companion Library 通知发挥作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22054955/

相关文章:

chromecast - 如何直接从 chromecast 接收器加载元数据?

Android Chromecast 搜索行为 - 从头开始​​重新启动视频

java - Android View 绑定(bind)。如何在 Basic Activity/Fragment 中实现绑定(bind)?

android - TextView1 无法解析为类型

android - 显示具有多个帧的动画 View 的最佳策略是什么?

Android app cast HLS 收到错误消息 No 'Access-Control-Allow-Origin'

android - remoteMediaPlayer.requestStatus(...) 返回状态代码 SIGN_IN_REQUIRED

android - 如何更改 Dialog Cast Companion Library android 上的主题

Android - 电话号码格式化和删除国家/地区代码