如何在自定义接收器中捕获媒体事件

如何在自定义接收器中捕获媒体事件

本文介绍了如何在自定义接收器中捕获媒体事件(播放/暂停/下一个等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Chromecast支持同时使用Google Home应用程序和红外遥控器(通过HDMI CEC)进行播放,暂停,下一首,上一首的外部控制.

Google Chromecast supports external control, such as play, pause, next, previous using both the Google Home app and an Infrared remote (over HDMI CEC).

当接收器没有播放媒体时,如何在自定义媒体接收器(使用CAF Receiver API)中捕获这些事件?

How can these events be captured in a custom media receiver (using the CAF Receiver API) when the receiver has no media playing?

推荐答案

在没有媒体播放时,接收方位于 IDLE 状态-表示发送方已连接且接收方应用已加载并正在运行,但当前没有播放,暂停的播放或缓冲操作正在进行中.

When no media is playing, the receiver is in IDLE state - that means that a sender is connected and the receiver app is loaded and running, but there is currently no playback, paused playback or buffering operation ongoing.

消息现在可以被消息拦截或观察.接收者基本上是相同的,无论它们是由发送者应用,Google Home/Assistant还是CEC发布的,您都可以以相同的方式进行处理.

The messages that can now be intercepted/observed by the receiver are basically the same regardless if they have been issued by a sender app, Google home/assistant or CEC - and you can process them the same way.

如果要根据发送消息的设备(或跟踪消息)实施不同的行为,可以查看customData部分-您可以设置发送方应用程序以在其中包含一些数据,但是您对Google Home/Google Assistant或CEC发出的消息的外观没有任何影响:CustomData在此处为空.

If you want to implement different behavior depending on the device that send the message (or track that maybe), you can have a look at the customData section - you can set up your sender app to include some data into that, but you have no influence on how a Google Home / Google Assistant or CEC issued messages look like: CustomData will be empty here.

这篇关于如何在自定义接收器中捕获媒体事件(播放/暂停/下一个等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:14