Device features
Chromecast / Smart TV
Cast Web Content to TV via JS Bridge
AppMintAppwrightBoth builders - the steps below are the same in each.
1What is Chromecast Support?#
Chromecast support lets users cast video/audio from your app to a TV or smart display. The app provides a JavaScript bridge that your website can call to initiate casting.
Perfect for:
- Video streaming websites
- Music platforms
- Photo galleries
- Presentation tools
- Digital signage control apps
2How It Works#
The generated app injects a JavaScript bridge (window.WebToApk) into your WebView. Your website can call this bridge to trigger native Android casting.
Flow:
- User taps a 'Cast' button on your website
- Your JS calls
window.WebToApk.castMedia(url) - Android opens the native media sharing/casting chooser
- User selects their Chromecast device
- Media plays on the TV
3Add Cast Button to Your Website#
Add a Cast button to your website that calls the JS bridge:
<!-- Add a Cast button -->
<button id="castBtn" onclick="castToTV()">
📺 Cast to TV
</button>
<script>
function castToTV() {
var videoUrl = document.querySelector('video')?.src
|| 'https://yoursite.com/video.mp4';
if (window.WebToApk && window.WebToApk.castMedia) {
window.WebToApk.castMedia(videoUrl);
} else {
alert('Casting is only available in the app');
}
}
</script>4Supported Media Types#
The cast bridge supports these media types:
✅ Direct video URLs (MP4, WebM)
✅ Audio URLs (MP3, AAC, OGG)
✅ HLS streams (.m3u8)
✅ DASH streams (.mpd)
⚠️ DRM-protected content requires additional Chromecast receiver app setup
⚠️ Web pages (HTML) cannot be cast directly - only media URLs
5Detect App Environment#
Your website can detect whether it's running inside the generated app to show/hide the cast button:
// Check if running inside WebToApk app
if (window.WebToApk) {
// Running in the app — show cast button
document.getElementById('castBtn')
.style.display = 'block';
} else {
// Running in a browser — hide cast button
document.getElementById('castBtn')
.style.display = 'none';
}6Fallback for Browser#
If your website is also accessed from a regular browser, the window.WebToApk object won't exist. Always check before calling:
✅ Use feature detection: if (window.WebToApk)
✅ Provide a fallback message for browser users
✅ Consider showing a 'Download our app for casting' banner