Search code examples
androidchromecastgoogle-cast

How to cast android Activity with CastRemoteDisplay on google cast


I have just read about RemoteDisplay api from google chrome cast. I want to show view inside my Activity to my TV screen using chrome cast device. I try this sample from google. They are using CastRemoteDisplayLocalService to show a CastPresentation which is Dialog.

Here my use case is to show pdf to my chrome cast device and scroll and zoom this by mobile device. I have shown the pdf on chrome cast successfully by adding pdfview inside CastPresentation. But it is not easy to control[Scroll, Zoom]. So it will be easy if I can show view inside my activity to cast like cast screen option does.

My first question is how can is show the view inside Activity to chrome cast?

My second question is remote cast use the Remote Display Receiver and my app have to cast videos and image also.So do i need to add two app in Google Cast SDK Developer Console?


Solution

  • You have to extend CastPresentation which is very similar to an Activity but allows for off-screen rendering. You cannot remotely display an Activity using the Remote Display API. Most of what you can do in an Activity with regards to views, layouts and animation can be done in CastPresentation.

    You can render both video and images using the same remote display receiver. The media player would be part of your CastPresentation view. Typically for video we recommend using an HTML receiver since that will not use the mobile device battery for longer content.