Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
873 views
in Technique[技术] by (71.8m points)

google cast - Open Chromecast YouTube video from my Android app

I'm able to use my own whitelisted url for feeding my chromecast videos, but can I make it stream a YouTube video directly from my app?

I assume all I would need is to launch the YouTube app remotely and feed it a video ID somehow, but I can't find out how to do that.

Has anyone done this from an Android app?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I suspect Google would want you to launch the YouTube app locally on the mobile device and then let the user cast the video to the ChromeCast device.

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

To view a YouTube video on your ChromeCast device you need to load a URL like this on the device: https://www.youtube.com/tv?v=g1LsT1PVjUA

This will display the TV version of the YouTube player. Now you have to find a way for your receiver HTML page to redirect to that page. This can be done with some Javascript in your receiver page. The URL could be passed to the receiver from you mobile app by using your own protocol. Look at the Cast SDK tic-tac-toe example on how to make your own protocol.

So your mobile app will launch your receiver, then you will pass the video id to your receiver over the web socket connection created by the Cast SDK. The receiver HTML will then grab the id and then use "window.location.href" to load the YouTube video URL.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...