Saturday, January 28, 2017

Chromecast HTML button

Leave a Comment

Is it possible to call chrome cast via a HTML button?

I've written a web page that uses a custom receiver and basically allows a user to show reports to a room of people in the form of stats/charts, but they see controls on their screen.

However because this is PURELY a cast app, I want to show a button on the webpage that shows when the user isn't casting and then disappears when they are not casting.

So something like:

<button id="castStart" style="display:none;">Start</button> <button id="castStop" style="display:none;">Stop</button> 

And then some JS like:

if( CASTAVAILBLE ) {      if( CASTING ) {         $('#castStart').hide();         $('#castStop').show();     } else {         $('#castStart').show();         $('#castStop').hide();     }      $('#castStart').on('click', function(e){         startCasting();         $('#castStart').hide();         $('#castStop').show();     });      $('#castStop').on('click', function(e){         sttopCasting();         $('#castStart').show();         $('#castStop').hide();     }); } 

So basically the plan is to hide and show the buttons based on when they are casting and ONLY if they are ABLE to cast (i.e. the cast extension is installed).

Is this possible?


Update: This seems to do what I want: https://chrome.com/photowall so it is possible!

1 Answers

Answers 1

Casting is part of browser chrome (i.e. "everything that's not the web page" not "Chrome browser") functionality.

If you're looking at displaying different content for desktop and cast version, you can get away with just css media queries

@media tv {   .only-visible-on-chromecast { /*or when a tv is used as a screen ¯\_(ツ)_/¯ */     display: block;   } } 

If you're looking for a javascript implementation of casting functionality, you may want to look into adapting the chromecasts package for browser usage.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment