Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
835 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...