Enable screen casting feature of Android from our application

6.3k views Asked by At

I am working on casting application. I am able to cast local videos from my app on TV using chromecast device.

Now I want to cast(mirror) complete android phone on the TV. I know Android provides this as a default feature by using Cast feature in quick Settings where user has to explicitly connect to a Chrome Cast device available.

How can I do the same from my application? I have tried using MediaProjection API to capture screen and save it.

Can anybody show me direction how to do that?

2

There are 2 answers

1
Devendra Singh On

The Google Cast SDK lets you extend your Android, Chrome or iOS app to control a TV or sound system. It supports many media formats, protocols and codecs to ease integration. Use Google's Official Cast SDK and Sample can be found here.

4
Ali Naddaf On

If you mean turning on mirroring programmatically from your app to mirror your phone, you cannot do that. If you want to limit that to your own app, then the closest thing would be to use the RemoteDisplay apis. Using those APIs, you can create a view in your own app and project that on your Cast device, see this tutorial.