\n\n```\n\nBoom. Load this on an iPad, tap the AirPlay button, and select your receiver. It supports seeking, playback controls, and even multi-room audio if your setup allows. But what if you're on desktop Safari? Still works for AirPlay to nearby devices.\n\nPro tip: Set `pip: true` alongside for picture-in-picture fallback. Users love options.\n\n---\n\n## Chromecast Integration with Plyr {#chromecast-integration}\n\n**Plyr Chromecast** isn't quite as \"set it and forget it\" as AirPlay, but it's solidly built-in thanks to community efforts. Back in 2015, folks requested Google Cast support in [issue #112](https://github.com/sampotts/plyr/issues/112), and it finally landed with [PR #706](https://github.com/sampotts/plyr/pull/706) merging into master around 2020.\n\nThe plugin lives at `plugins/google-cast.js`. It adds a `'googlecast'` control that shows up only on Chrome (desktop, Android, iOS)—smart, since Cast shines there. No bloat for other browsers. You'll need the Google Cast SDK, but Plyr wraps it neatly.\n\nDoes it replace third-party libs like Shaka Player? For basic MP4/WebM casting from Plyr, yes. Forget wrestling with raw Cast APIs.\n\n---\n\n## Adding the Google Cast Plugin {#adding-googlecast-plugin}\n\nTo enable **Chromecast in Plyr**, first build Plyr from source or use a custom dist. Clone the repo: `git clone https://github.com/sampotts/plyr.git`, then `npm install && gulp`.\n\nInclude the plugin in your controls—but check for Chrome:\n\n```javascript\nconst player = new Plyr('#player', {\n controls: [\n 'play', 'progress', 'current-time', 'mute', 'volume',\n ...(window.chrome ? ['googlecast'] : []),\n 'fullscreen'\n ]\n});\n```\n\nGet your Google Cast app ID from the [Cast Developer Console](https://cast.google.com/publish). Pass it via `googlecast: { appId: 'YOUR_APP_ID' }` in options. Initialize, and the Cast button appears. Tap it, select your Chromecast device, and stream away.\n\nOn Android TV or Nest Hub? Handles it. But HLS/DASH or YouTube providers? Those need extra work—stick to progressive downloads for now.\n\n---\n\n## Code Examples for AirPlay and Chromecast {#code-examples}\n\nWant a full demo? Check this [working Plyr AirPlay example on CodePen](https://codepen.io/xavianaxw/pen/QVNyrQ). It mirrors the official config, with AirPlay lighting up on iOS.\n\nFor Chromecast, here's a beefed-up snippet:\n\n```html\n\n\n\n \n\n\n \n \n \n \n \n\n\n```\n\nTest on Chrome with a Chromecast nearby. AirPlay? Fire up Safari. Both buttons coexist peacefully.\n\n---\n\n## Limitations and Browser Compatibility {#limitations}\n\nNot everything's perfect. AirPlay shines on Apple ecosystems—expect quirks on Windows via emulators. One [ongoing issue](https://github.com/sampotts/plyr/issues/2819) notes seekbar glitches post-connection (duration shows 00:00). Workaround: Ensure your video has proper duration metadata.\n\nChromecast? Chrome-only party. Firefox/Edge users get nada from `'googlecast'`. Supports HTML5 basics only—no live streams or adaptive bitrate yet. And always load the Cast SDK first to avoid console errors.\n\nMobile? Android Chrome casts fine, but iOS Chrome falls back gracefully. Build custom for edge cases.\n\n---\n\n## Troubleshooting Common Issues {#troubleshooting}\n\nAirPlay not showing? Verify HTTPS—AirPlay hates plain HTTP. Or toggle `enabled: true` in fullscreen options for iOS native hints.\n\nChromecast silent? Double-check your app ID and Cast SDK load order. Console logging via `player.on('googlecast-*', e => console.log(e))` helps debug sessions.\n\nPlayer unresponsive after cast? Destroy/recreate on disconnect: `player.destroy(); new Plyr(...)`. Common gotcha.\n\nStuck? Dive into [Plyr options docs](https://github.com/sampotts/plyr#options) or the repo issues.\n\n---\n\n## Sources {#sources}\n\n1. **Plyr GitHub Repository** — Core documentation on AirPlay controls and player options: https://github.com/sampotts/plyr\n2. **Plyr Options Documentation** — Details controls array including airplay and custom plugins: https://github.com/sampotts/plyr#options\n3. **Google Cast Support PR #706** — Merged pull request adding googlecast plugin implementation: https://github.com/sampotts/plyr/pull/706\n4. **Google Cast Feature Request #112** — Original issue discussing Chromecast integration needs: https://github.com/sampotts/plyr/issues/112\n5. **Plyr AirPlay CodePen Demo** — Working example configuration for AirPlay button: https://codepen.io/xavianaxw/pen/QVNyrQ\n\n---\n\n## Conclusion {#conclusion}\n\nPlyr makes **AirPlay** dead simple with zero extras, while **Chromecast** requires a quick plugin tweak and Chrome check—both baked into the official codebase. Skip third-party headaches; a custom build or smart controls array gets you casting videos effortlessly. Grab the repo, test on real devices, and your players will handle modern streaming like pros. Questions? The GitHub community has your back."},{"@type":"QAPage","@context":"https://schema.org","mainEntity":{"name":"How to add AirPlay and Chromecast support to Plyr.io?","text":"How to add AirPlay and Chromecast support to Plyr.io? Is there a built-in way to enable these features, or do I need third-party libraries or custom JavaScript solutions?","@type":"Question","acceptedAnswer":{"text":"Plyr provides built-in AirPlay support by including 'airplay' in controls—no extra setup. Chromecast uses the official 'googlecast' plugin from PR #706; add conditionally in Chrome with Google Cast SDK for seamless integration.","@type":"Answer","upvoteCount":6,"dateCreated":"2026-01-26T15:40:37.672Z","datePublished":"2026-01-26T15:40:37.672Z","dateModified":"2026-01-26T15:40:37.672Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"url":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr/#message-6c59356b-c322-4b5e-a9ea-f789a12b8180"},"@id":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr","answerCount":1,"dateCreated":"2026-01-26T15:40:37.672Z","datePublished":"2026-01-26T15:40:37.672Z","dateModified":"2026-01-26T15:40:37.672Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}]},"mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr"},"inLanguage":"en","dateCreated":"2026-01-26T15:40:37.672Z","datePublished":"2026-01-26T15:40:37.672Z","dateModified":"2026-01-26T15:40:37.672Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"@id":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr"},{"@type":"CollectionPage","@id":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr/#related-questions","name":"How to Add AirPlay & Chromecast to Plyr Player","description":"Enable built-in AirPlay support in Plyr and add Chromecast via official plugin. No third-party libraries needed—just include controls and build Plyr for seamless video casting on iOS, Safari, and Chrome.","url":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr","inLanguage":"en","mainEntity":{"@type":"ItemList","@id":"https://neuroanswers.net/c/web/q/add-airplay-chromecast-plyr/#related-questions","itemListElement":[{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/fix-webpack-module-parse-failed-image-import-error","name":"Fix Webpack Module Parse Failed Image Import Error","position":1,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/fix-webpack-module-parse-failed-image-import-error","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/fix-webpack-module-parse-failed-image-import-error"},"inLanguage":"en","dateCreated":"2026-01-06T10:13:33.478Z","datePublished":"2026-01-06T10:13:33.478Z","dateModified":"2026-01-06T10:13:33.478Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"Fix Webpack Module Parse Failed Image Import Error","description":"Resolve Webpack 'Module parse failed: import/export only with sourceType module' error on image imports. Fix asset loader regex in webpack.config.js, handle dynamic DOM content display, and avoid loader pitfalls for smooth bundling.","keywords":["webpack","module parse failed","webpack error","webpack loader","webpack asset","webpack config","image import webpack","webpack javascript","asset/resource","webpack babel","webpack dev server"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/trigger-css-fade-in-animation-javascript-page-load-link-click","name":"Trigger CSS Fade-In Animation with JavaScript on Page Load & Link Click","position":2,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/trigger-css-fade-in-animation-javascript-page-load-link-click","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/trigger-css-fade-in-animation-javascript-page-load-link-click"},"inLanguage":"en","dateCreated":"2025-12-27T10:12:02.811Z","datePublished":"2025-12-27T10:12:02.811Z","dateModified":"2025-12-27T10:12:02.811Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"Trigger CSS Fade-In Animation with JavaScript on Page Load & Link Click","description":"Learn how to trigger a CSS fade-in animation using JavaScript on initial page load and when specific links are clicked. Fix common issues with DOMContentLoaded and event delegation.","keywords":["css animation","fade in css","javascript animation","trigger css animation","page load animation","link click animation","css fade in effect","javascript on page load","event delegation","DOMContentLoaded"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/fix-slow-css-js-hostinger-pagespeed-insights","name":"Fix Slow CSS/JS on Hostinger: Boost PageSpeed Score","position":3,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/fix-slow-css-js-hostinger-pagespeed-insights","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/fix-slow-css-js-hostinger-pagespeed-insights"},"inLanguage":"en","dateCreated":"2026-01-01T15:40:49.234Z","datePublished":"2026-01-01T15:40:49.234Z","dateModified":"2026-01-01T15:40:49.234Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"Fix Slow CSS/JS on Hostinger: Boost PageSpeed Score","description":"Diagnose why PageSpeed Insights flags slow CSS/JS on Hostinger sites. Improve Speed Index with CDN, minification, caching, Brotli, critical CSS, defer JS, and TTFB fixes for better performance.","keywords":["pagespeed insights","hostinger","slow css js","speed index","ttfb","cdn","css optimization","js optimization","litespeed cache","minify css","server response time","web performance"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/react-window-virtualization-dynamic-lists-media","name":"React Window Virtualization for Dynamic Lists with Media","position":4,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/react-window-virtualization-dynamic-lists-media","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/react-window-virtualization-dynamic-lists-media"},"inLanguage":"en","dateCreated":"2026-01-14T13:56:19.646Z","datePublished":"2026-01-14T13:56:19.646Z","dateModified":"2026-01-15T06:53:59.707Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"React Window Virtualization for Dynamic Lists with Media","description":"Fix layout shakes in react window and react virtualized for dynamic React lists with frequent updates, images, buttons. Code examples, react-virtuoso alternative, patterns for smooth performance.","keywords":["react window","react windows","react virtualized","react virtualization","fixedsizelist react window","react virtualized auto sizer","dynamic list react","react window virtualization","virtualized list react"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/fix-svg-text-editor-partial-formatting-tspan","name":"Fix SVG Text Editor: Partial Formatting with tspan","position":5,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/fix-svg-text-editor-partial-formatting-tspan","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/fix-svg-text-editor-partial-formatting-tspan"},"inLanguage":"en","dateCreated":"2025-10-18T23:09:39.604Z","datePublished":"2025-10-18T23:09:39.604Z","dateModified":"2025-12-29T19:16:59.830Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"Fix SVG Text Editor: Partial Formatting with tspan","description":"Fix JavaScript SVG text editor issues where formatting applies to entire elements instead of selections. Use tspan for partial styling, prevent text collapse, with step-by-step code using Selection API.","keywords":["svg text editor","partial text formatting","tspan","svg selection","contenteditable overlay","split text into tspan","selection range api","svg text collapse","javascript svg text"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/setting-checkbox-states-jquery-modal-windows","name":"Setting Checkbox States in jQuery Modal Windows","position":6,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/setting-checkbox-states-jquery-modal-windows","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/setting-checkbox-states-jquery-modal-windows"},"inLanguage":"en","dateCreated":"2026-02-02T12:43:02.399Z","datePublished":"2026-02-02T12:43:02.399Z","dateModified":"2026-02-02T12:43:02.399Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"Setting Checkbox States in jQuery Modal Windows","description":"Learn how to properly set checkbox states in jQuery modal windows using .prop() method and proper event timing for reliable form behavior.","keywords":["jquery checkbox","jquery modal","jquery checkbox checked","jquery modal window","jquery prop checked","jquery set checkbox","jquery checkbox modal","jquery modal checkbox","modal checkbox state","jquery form handling","jquery dom manipulation"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/check-element-visibility-javascript-css-properties","name":"Check Element Visibility with JavaScript: CSS Properties Guide","position":7,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/check-element-visibility-javascript-css-properties","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/check-element-visibility-javascript-css-properties"},"inLanguage":"en","dateCreated":"2026-02-09T11:17:18.936Z","datePublished":"2026-02-09T11:17:18.936Z","dateModified":"2026-02-09T11:17:18.936Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"Check Element Visibility with JavaScript: CSS Properties Guide","description":"Learn how to check if DOM elements are visible using pure JavaScript. Examine display, visibility, opacity and other CSS properties that affect visibility.","keywords":["javascript display","element is visible","check element visible","visibility css","display none css","javascript hidden","hide javascript","css visibility hidden","javascript style display","element visibility javascript","checkvisibility javascript","dom visibility javascript","javascript getComputedStyle","javascript offsetWidth","viewport visibility javascript"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/html-minlength-attribute-why-not-working-alternatives","name":"HTML minlength Attribute: Does It Exist & Why It Fails","position":8,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/html-minlength-attribute-why-not-working-alternatives","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/html-minlength-attribute-why-not-working-alternatives"},"inLanguage":"en","dateCreated":"2026-01-29T16:46:12.796Z","datePublished":"2026-01-29T16:46:12.796Z","dateModified":"2026-01-29T16:46:12.796Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"HTML minlength Attribute: Does It Exist & Why It Fails","description":"Yes, HTML5 has minlength for input fields like text and password. Learn why minlength validation might not work (wrong types, no required), browser support, and alternatives like pattern regex, min attribute, or JavaScript setCustomValidity for robust form checks.","keywords":["html minlength","minlength attribute","input minlength","minlength not working","html form validation","pattern attribute","browser support minlength","javascript validation","html input validation","minlength alternatives"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/how-to-iterate-javascript-object-parts-for-loops","name":"How to Iterate Over JavaScript Objects in Parts Using For Loops","position":9,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/how-to-iterate-javascript-object-parts-for-loops","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/how-to-iterate-javascript-object-parts-for-loops"},"inLanguage":"en","dateCreated":"2026-01-21T10:48:04.361Z","datePublished":"2026-01-21T10:48:04.361Z","dateModified":"2026-01-21T10:48:04.361Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"How to Iterate Over JavaScript Objects in Parts Using For Loops","description":"Learn efficient techniques to iterate through JavaScript object properties in chunks using Object.keys(), Object.entries(), and custom chunked iteration methods.","keywords":["javascript objects","javascript object iteration","javascript object properties","javascript object keys","javascript object values","javascript object foreach","javascript json object","javascript object function","object iteration","chunked iteration","for loops"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/i18next-attribute-interpolation-laravel-validation","name":"i18next Attribute Interpolation: Laravel-Style Validation Messages","position":10,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/i18next-attribute-interpolation-laravel-validation","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/i18next-attribute-interpolation-laravel-validation"},"inLanguage":"en","dateCreated":"2026-01-20T16:57:19.494Z","datePublished":"2026-01-20T16:57:19.494Z","dateModified":"2026-01-20T16:57:19.494Z","author":[{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}}],"publisher":{"@type":"Organization","@id":"https://neuroanswers.net/about","name":"NeuroAnswers","url":"https://neuroanswers.net/about","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/logo.png","width":"512","height":"512"}},"headline":"i18next Attribute Interpolation: Laravel-Style Validation Messages","description":"Learn how to implement automatic attribute interpolation in i18next validation error messages similar to Laravel's :attribute placeholder system.","keywords":["i18next","i18next interpolation","attribute interpolation","laravel validation","validation error messages","i18next postprocessor","i18next custom plugins","translation interpolation","i18next js","laravel :attribute"],"image":[],"articleBody":""}}]}}]}
Web

How to Add AirPlay & Chromecast to Plyr Player

Enable built-in AirPlay support in Plyr and add Chromecast via official plugin. No third-party libraries needed—just include controls and build Plyr for seamless video casting on iOS, Safari, and Chrome.

1 answer 6 views

How to add AirPlay and Chromecast support to Plyr.io? Is there a built-in way to enable these features, or do I need third-party libraries or custom JavaScript solutions?

Plyr provides built-in AirPlay support that kicks in automatically on devices like iOS and Safari—no extra setup required beyond including 'airplay' in your controls array. For Chromecast, there’s an official plugin merged into Plyr’s codebase via pull request #706, letting you add a 'googlecast' button conditionally in Chrome browsers. You won’t need third-party libraries; just build Plyr with the plugin or grab the latest dist for seamless casting from Plyr players.


Contents


AirPlay Support in Plyr

Ever fired up a video player on your iPhone and seen that little AirPlay icon pop up in the controls? That’s Plyr doing its thing. Out of the box, Plyr AirPlay integration is native and hassle-free. The player detects AirPlay-capable devices—like Apple TVs or HomePods—and renders the button automatically if your controls array includes 'airplay'.

According to the official Plyr documentation, the default controls list already features it: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']. No custom JavaScript hacks. Just initialize your player, and on supported hardware, it appears. Tested this on iOS Safari? Works like a charm for mirroring video or audio to your TV.

Why does this matter for developers? It means fewer lines of code and better user experience without forcing users to hunt for casting options. Plyr handles the HTML5 Media Session API under the hood, so your videos stream smoothly via AirPlay 2.


Enabling AirPlay in Your Plyr Player

Getting AirPlay up and running takes seconds. Start with the basic Plyr setup from the Plyr GitHub repo. Grab the CDN link: <link rel="stylesheet" src="https://cdn.plyr.io/3.7.8/plyr.css" /> and the JS.

Here’s a quick embed:

html
<video id="player" playsinline controls>
 <source src="your-video.mp4" type="video/mp4" />
</video>

<script src="https://cdn.plyr.io/3.7.8/plyr.js"></script>
<script>
 const player = new Plyr('#player', {
 controls: ['play', 'progress', 'current-time', 'mute', 'volume', 'airplay', 'fullscreen']
 });
</script>

Boom. Load this on an iPad, tap the AirPlay button, and select your receiver. It supports seeking, playback controls, and even multi-room audio if your setup allows. But what if you’re on desktop Safari? Still works for AirPlay to nearby devices.

Pro tip: Set pip: true alongside for picture-in-picture fallback. Users love options.


Chromecast Integration with Plyr

Plyr Chromecast isn’t quite as “set it and forget it” as AirPlay, but it’s solidly built-in thanks to community efforts. Back in 2015, folks requested Google Cast support in issue #112, and it finally landed with PR #706 merging into master around 2020.

The plugin lives at plugins/google-cast.js. It adds a 'googlecast' control that shows up only on Chrome (desktop, Android, iOS)—smart, since Cast shines there. No bloat for other browsers. You’ll need the Google Cast SDK, but Plyr wraps it neatly.

Does it replace third-party libs like Shaka Player? For basic MP4/WebM casting from Plyr, yes. Forget wrestling with raw Cast APIs.


Adding the Google Cast Plugin

To enable Chromecast in Plyr, first build Plyr from source or use a custom dist. Clone the repo: git clone https://github.com/sampotts/plyr.git, then npm install && gulp.

Include the plugin in your controls—but check for Chrome:

javascript
const player = new Plyr('#player', {
 controls: [
 'play', 'progress', 'current-time', 'mute', 'volume',
 ...(window.chrome ? ['googlecast'] : []),
 'fullscreen'
 ]
});

Get your Google Cast app ID from the Cast Developer Console. Pass it via googlecast: { appId: 'YOUR_APP_ID' } in options. Initialize, and the Cast button appears. Tap it, select your Chromecast device, and stream away.

On Android TV or Nest Hub? Handles it. But HLS/DASH or YouTube providers? Those need extra work—stick to progressive downloads for now.


Code Examples for AirPlay and Chromecast

Want a full demo? Check this working Plyr AirPlay example on CodePen. It mirrors the official config, with AirPlay lighting up on iOS.

For Chromecast, here’s a beefed-up snippet:

html
<!DOCTYPE html>
<html>
<head>
 <link rel="stylesheet" href="https://cdn.plyr.io/3.7.8/plyr.css" />
</head>
<body>
 <video id="player" controls crossorigin playsinline>
 <source src="big-buck-bunny.mp4" type="video/mp4" />
 </video>
 
 <script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
 <script src="https://cdn.plyr.io/3.7.8/plyr.js"></script>
 <script>
 const player = new Plyr('#player', {
 controls: ['play-large', 'progress', 'volume', 'settings',
 ...(Plyr.supports('chrome') ? ['googlecast'] : []),
 'airplay', 'fullscreen'
 ],
 googlecast: { appId: 'YOUR_APP_ID_HERE' }
 });
 </script>
</body>
</html>

Test on Chrome with a Chromecast nearby. AirPlay? Fire up Safari. Both buttons coexist peacefully.


Limitations and Browser Compatibility

Not everything’s perfect. AirPlay shines on Apple ecosystems—expect quirks on Windows via emulators. One ongoing issue notes seekbar glitches post-connection (duration shows 00:00). Workaround: Ensure your video has proper duration metadata.

Chromecast? Chrome-only party. Firefox/Edge users get nada from 'googlecast'. Supports HTML5 basics only—no live streams or adaptive bitrate yet. And always load the Cast SDK first to avoid console errors.

Mobile? Android Chrome casts fine, but iOS Chrome falls back gracefully. Build custom for edge cases.


Troubleshooting Common Issues

AirPlay not showing? Verify HTTPS—AirPlay hates plain HTTP. Or toggle enabled: true in fullscreen options for iOS native hints.

Chromecast silent? Double-check your app ID and Cast SDK load order. Console logging via player.on('googlecast-*', e => console.log(e)) helps debug sessions.

Player unresponsive after cast? Destroy/recreate on disconnect: player.destroy(); new Plyr(...). Common gotcha.

Stuck? Dive into Plyr options docs or the repo issues.


Sources

  1. Plyr GitHub Repository — Core documentation on AirPlay controls and player options: https://github.com/sampotts/plyr
  2. Plyr Options Documentation — Details controls array including airplay and custom plugins: https://github.com/sampotts/plyr#options
  3. Google Cast Support PR #706 — Merged pull request adding googlecast plugin implementation: https://github.com/sampotts/plyr/pull/706
  4. Google Cast Feature Request #112 — Original issue discussing Chromecast integration needs: https://github.com/sampotts/plyr/issues/112
  5. Plyr AirPlay CodePen Demo — Working example configuration for AirPlay button: https://codepen.io/xavianaxw/pen/QVNyrQ

Conclusion

Plyr makes AirPlay dead simple with zero extras, while Chromecast requires a quick plugin tweak and Chrome check—both baked into the official codebase. Skip third-party headaches; a custom build or smart controls array gets you casting videos effortlessly. Grab the repo, test on real devices, and your players will handle modern streaming like pros. Questions? The GitHub community has your back.

Authors
Verified by moderation
NeuroAnswers
Moderation
How to Add AirPlay & Chromecast to Plyr Player