\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":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"}}],"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/sync-trumbowyg-editors-alpine-js","name":"Alpine.js: Sync Trumbowyg Vertical Scrolling with Code","position":3,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/sync-trumbowyg-editors-alpine-js","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/sync-trumbowyg-editors-alpine-js"},"inLanguage":"en","dateCreated":"2026-01-05T16:35:48.554Z","datePublished":"2026-01-05T16:35:48.554Z","dateModified":"2026-01-05T16:35:48.554Z","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":"Alpine.js: Sync Trumbowyg Vertical Scrolling with Code","description":"Sync vertical scrolling between two Trumbowyg editors using Alpine.js or vanilla JS. Keeps toolbars visible and avoids page scrolling. Includes runnable code.","keywords":["trumbowyg","alpine js","sync scroll","vanilla js","trumbowyg-editor","fixedBtnPane","syncscroll","scrollTop","editor sync","contenteditable","toolbar visibility","requestAnimationFrame"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/prevent-qz-tray-security-popups","name":"Prevent QZ Tray security popups for repeated prints","position":4,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/prevent-qz-tray-security-popups","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/prevent-qz-tray-security-popups"},"inLanguage":"en","dateCreated":"2026-01-07T10:42:53.036Z","datePublished":"2026-01-07T10:42:53.036Z","dateModified":"2026-01-07T10:42:53.036Z","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":"Prevent QZ Tray security popups for repeated prints","description":"Stop QZ Tray security popups: initialize certificate and signature once, keep the WebSocket open, and use server-side signing to avoid prompts for QZ Tray.","keywords":["qz tray","qz tray popups","qz tray certificate","qz tray javascript","qz tray signature","silent printing","server-side signing","websocket connection","print security","prevent popups"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/efficient-js-clone-object-deep-clone","name":"Most Efficient JS Clone Object: Deep Clone Guide","position":5,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/efficient-js-clone-object-deep-clone","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/efficient-js-clone-object-deep-clone"},"inLanguage":"en","dateCreated":"2025-10-20T09:20:17.294Z","datePublished":"2025-10-20T09:20:17.294Z","dateModified":"2026-01-10T07:50:57.506Z","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":"Most Efficient JS Clone Object: Deep Clone Guide","description":"Learn the most efficient way to deep clone objects in JavaScript with structuredClone(). Beats JSON.parse(JSON.stringify()) on speed, handles circular refs. Compare Lodash cloneDeep, performance benchmarks, and best practices for js clone object.","keywords":["js clone object","javascript clone","javascript clone object","deep clone javascript","structuredclone","lodash clonedeep","object cloning javascript"],"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":6,"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/form-reloads-despite-preventdefault-fix","name":"Why Form Reloads Despite event.preventDefault() Fix","position":7,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/form-reloads-despite-preventdefault-fix","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/form-reloads-despite-preventdefault-fix"},"inLanguage":"en","dateCreated":"2026-01-09T10:28:35.643Z","datePublished":"2026-01-09T10:28:35.643Z","dateModified":"2026-01-09T10:28:35.643Z","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":"Why Form Reloads Despite event.preventDefault() Fix","description":"Fix page reload on form submit even with event.preventDefault() on button click. Learn to use form submit event listener, handle Enter key, programmatic submit, and debugging steps for reliable prevention.","keywords":["preventdefault","event preventdefault","preventdefault javascript","addeventlistener preventdefault","form submit preventdefault","javascript form submit","prevent form submission","e preventdefault","click preventdefault"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/php-popup-form-row-data-fix-first-row-issue","name":"PHP Popup Form Row Data: Fix First Row Issue","position":8,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/php-popup-form-row-data-fix-first-row-issue","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/php-popup-form-row-data-fix-first-row-issue"},"inLanguage":"en","dateCreated":"2025-12-22T16:06:38.328Z","datePublished":"2025-12-22T16:06:38.328Z","dateModified":"2025-12-22T16:06:38.328Z","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":"PHP Popup Form Row Data: Fix First Row Issue","description":"Fix PHP popup form always getting first row data. Learn how to pass correct row reference numbers to popup forms using JavaScript, hidden inputs, and proper form handling.","keywords":["php form","php data","php table","php javascript","ajax php","popup form","row data","reference number","hidden input","form submission"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/iterate-arrays-javascript-for-loops-java-equivalent","name":"Iterate JS Arrays: for, for...of vs Java Enhanced For","position":9,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/iterate-arrays-javascript-for-loops-java-equivalent","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/iterate-arrays-javascript-for-loops-java-equivalent"},"inLanguage":"en","dateCreated":"2025-10-21T16:24:21.236Z","datePublished":"2025-10-21T16:24:21.236Z","dateModified":"2026-01-08T19:40:53.346Z","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":"Iterate JS Arrays: for, for...of vs Java Enhanced For","description":"Learn to loop through arrays in JavaScript with for loops, for...of (Java enhanced for equivalent), and forEach. Examples, comparisons, sparse arrays handling, and best practices for iteration.","keywords":["iterate arrays javascript","javascript for loop","for of javascript","javascript foreach","loop through arrays javascript","java enhanced for loop","array iteration javascript","javascript array loops","for of vs foreach","javascript cycle array"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/fix-cors-missing-access-control-allow-origin-xmlhttprequest","name":"Fix CORS Missing Access-Control-Allow-Origin in XMLHttpRequest","position":10,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/fix-cors-missing-access-control-allow-origin-xmlhttprequest","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/fix-cors-missing-access-control-allow-origin-xmlhttprequest"},"inLanguage":"en","dateCreated":"2026-01-18T11:28:56.709Z","datePublished":"2026-01-18T11:28:56.709Z","dateModified":"2026-01-18T11:28:56.709Z","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 CORS Missing Access-Control-Allow-Origin in XMLHttpRequest","description":"Resolve 'Missing CORS header Access-Control-Allow-Origin' error in VM Essentials plugin's status-update.js. Server-side PHP fixes for Joomla, handle preflights, add headers, and test XMLHttpRequest requests effectively.","keywords":["cors error","access-control-allow-origin","xmlhttprequest","cors header","fix cors","php cors","joomla cors","cors policy","allow cors","cors blocked"],"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 1 view

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