0

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?

Harish Vats
  • 662
  • 6
  • 21
  • "I have tried using MediaProjection API to capture screen and save it" -- what didn't work? Directing the output of the MediaProjection virtual display to a MediaCodec encoder, and streaming the output, is the core part of mirroring. The `screenrecord` shell command will send raw video over USB using a similar approach. Are you having trouble with that part, or with receiving the data and doing something useful with it? – fadden Apr 28 '16 at 21:10
  • @fadden yes how to direct that output to TV without any USB connection? – Harish Vats Apr 29 '16 at 04:56
  • You'd use a network connection. If that's the part you don't understand, you should clarify that in your question. This is a broad topic, and it's unclear what you know how to do and what you don't. – fadden Apr 29 '16 at 20:13

2 Answers2

2

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.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • thanks for the information sir. – Harish Vats Apr 29 '16 at 06:34
  • Is it possible to cast from one android device to other android device without chromecast device? – Harish Vats May 05 '16 at 16:39
  • Not sure what you mean by "Cast" in this context but regardless, Cast SDK doesn't provide any such functionality at all. – Ali Naddaf May 05 '16 at 16:50
  • by cast I mean, I want to make two app Sender and Receiver app. I want to play video/songs stored in android device "A" on another Android device "B". All the controls from device A. If not Cast SDK any other solution possible? – Harish Vats May 06 '16 at 04:02
0

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.

Devendra Singh
  • 2,343
  • 4
  • 26
  • 47
  • I have already done that part, I have casted video from my side to TV and controlled that video. but now I want that whatever I open/close do whatever on my mobile same should be shown on TV ~~~ MIRRORING – Harish Vats Apr 28 '16 at 12:05