Open a YouTube Chromecast from my Android app

I can use my own whitelist to submit my chrome videos, but can I get it to transfer YouTube videos directly from my application?

I assume that all I need to do is to launch the YouTube application remotely and somehow pass the video ID to it, but I can’t find out how to do it.

Has anyone done this from an Android app?

Thanks.

+7
android chromecast google-cast
source share
2 answers

Not sure if you are still looking for a solution to this. The way to do this is as follows:

MimeData data = new MimeData("v=g1LsT1PVjUA", MimeData.TYPE_TEXT); mSession.startSession("YouTube", data); 

The above should create a YouTube session and play the video.

+6
source share

I suspect that Google will want you to launch the YouTube app locally on your mobile device, and then allow the user to transfer video to the ChromeCast device.

However, if you want to hack another solution, here is another option:

To watch YouTube videos on your ChromeCast device, you need to download the following URL on the device: https://www.youtube.com/tv?v=g1LsT1PVjUA

The TV version of the YouTube player is displayed. Now you need to find a way to redirect your recipient's HTML page to this page. This can be done using Javascript on your recipient page. The URL can be passed to the recipient from your mobile application using its own protocol. Check out the Cast SDK tic-tac-toe example on how to create your own protocol.

So, your mobile application will launch your receiver, then you will transfer the video ID to your receiver through the web socket connection created by the Cast SDK. The HTML recipient will then capture the identifier, and then "window.location.href" will load the URL of the YouTube video.

+8
source share

All Articles