\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":3,"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/highcharts-stacked-bar-tiny-stacks-visible-clickable","name":"Highcharts Stacked Bar: Make Tiny Stacks Visible & Clickable","position":1,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/highcharts-stacked-bar-tiny-stacks-visible-clickable","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/highcharts-stacked-bar-tiny-stacks-visible-clickable"},"inLanguage":"en","dateCreated":"2026-01-14T16:22:38.477Z","datePublished":"2026-01-14T16:22:38.477Z","dateModified":"2026-01-14T16:22:38.477Z","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":"Highcharts Stacked Bar: Make Tiny Stacks Visible & Clickable","description":"Fix Highcharts horizontal stacked bar charts where small stacks (1-10) are hidden by large ones (25k). Use minPointLength, logarithmic xAxis, clip false, and overlays for visibility and clickability with code examples.","keywords":["highcharts","stacked bar chart","minPointLength","highcharts stacked bar","logarithmic axis","highcharts bar","tiny stacks","small stacks visible","highcharts series","highcharts chart"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/fix-express-res-json-array-response-issue","name":"Fix Express.js res.json() Array Response Issue - Last Element Only","position":2,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/fix-express-res-json-array-response-issue","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/fix-express-res-json-array-response-issue"},"inLanguage":"en","dateCreated":"2025-12-28T15:27:43.001Z","datePublished":"2025-12-28T15:27:43.001Z","dateModified":"2025-12-28T15:27:43.001Z","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 Express.js res.json() Array Response Issue - Last Element Only","description":"Learn how to fix Express.js res.json() returning only the last element of an array instead of the full array. Solutions for proper array handling in Express APIs.","keywords":["express json","express array","res.json array","json response","array handling","express api","node.js","javascript arrays","forEach loop","array push","json stringify","express middleware","api response","array methods","json parsing"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/javascript-button-not-displaying-fix","name":"JavaScript Button Not Displaying: Fix Document Body Null Issue","position":3,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/javascript-button-not-displaying-fix","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/javascript-button-not-displaying-fix"},"inLanguage":"en","dateCreated":"2026-04-15T12:14:19.336Z","datePublished":"2026-04-15T12:14:19.336Z","dateModified":"2026-04-15T13:18:53.349Z","author":[{"@type":"Person","@id":"https://neuroanswers.net/@mdn-contributors","name":"@mdn-contributors","url":"https://neuroanswers.net/@mdn-contributors","jobTitle":"Community Contributor","description":"MDN contributors are a community of developers who write and maintain documentation for web standards"},{"@type":"Organization","@id":"https://neuroanswers.net/@developer.mozilla-org","name":"@developer.mozilla-org","url":"https://neuroanswers.net/@developer.mozilla-org"},{"@type":"Organization","@id":"https://neuroanswers.net/@javascript-info","name":"JavaScript.info","description":"Modern JavaScript Tutorial: simple, but detailed explanations with examples and tasks, including: closures, document and events, object oriented programming and more","url":"https://neuroanswers.net/@javascript-info","logo":{"@type":"ImageObject","url":"https://neuroanswers.net/api/v1/source/javascript-info/logo.png","width":"72","height":"72"}}],"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":"JavaScript Button Not Displaying: Fix Document Body Null Issue","description":"Learn why your JavaScript button isn't showing on your HTML page and how to fix document body null issues with proper script execution timing.","keywords":["javascript button","javascript button click","document body null","domcontentloaded","javascript append","html button","javascript dom manipulation"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/fix-bootstrap-collapse-stuck-collapsing","name":"Fix Bootstrap Collapse Stuck in Collapsing State","position":4,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/fix-bootstrap-collapse-stuck-collapsing","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/fix-bootstrap-collapse-stuck-collapsing"},"inLanguage":"en","dateCreated":"2026-01-02T10:36:54.741Z","datePublished":"2026-01-02T10:36:54.741Z","dateModified":"2026-01-02T10:36:54.741Z","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 Bootstrap Collapse Stuck in Collapsing State","description":"Troubleshoot and fix Bootstrap collapse stuck in 'collapsing' state, failing to hide. Covers duplicate JS, position absolute, floats, event handlers, and initialization issues for reliable Bootstrap navbar collapse and Bootstrap 3 collapse fixes.","keywords":["bootstrap collapse","bootstrap navbar collapse","bootstrap 3 collapse","bootstrap collapse stuck","collapsing state","bootstrap collapse not working","bootstrap collapse hide"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/focus-jquery-timepicker-validation-fail","name":"Focus jQuery Timepicker on Validation Failure","position":5,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/focus-jquery-timepicker-validation-fail","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/focus-jquery-timepicker-validation-fail"},"inLanguage":"en","dateCreated":"2026-01-01T10:09:09.953Z","datePublished":"2026-01-01T10:09:09.953Z","dateModified":"2026-01-01T10:09:09.953Z","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":"Focus jQuery Timepicker on Validation Failure","description":"Learn how to reliably focus a jQuery Timepicker input field like #Period1TimeFrom when jQuery validation fails. Use setTimeout, event hooks, and custom methods to fix focus issues after form errors.","keywords":["jquery validation","jquery timepicker","focus input field","timepicker focus","form validation fail","settimeout focus","jquery validate timepicker","timepicker validation"],"image":[],"articleBody":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/get-unix-timestamp-javascript","name":"How to Get Unix Timestamp in JavaScript (Date.now())","position":6,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/get-unix-timestamp-javascript","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/get-unix-timestamp-javascript"},"inLanguage":"en","dateCreated":"2025-10-20T07:14:26.205Z","datePublished":"2025-10-20T07:14:26.205Z","dateModified":"2026-01-04T08:35:08.800Z","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 Get Unix Timestamp in JavaScript (Date.now())","description":"Learn how to get a Unix timestamp in JavaScript using Date.now() for milliseconds or Math.floor(Date.now() / 1000) for seconds. Covers js get timestamp, conversions, Node.js examples, pitfalls, and helper functions for accurate date and time representation.","keywords":["unix timestamp","javascript timestamp","js get timestamp","get unix timestamp","date.now","unix timestamp javascript","current unix timestamp","unix timestamp milliseconds","javascript date timestamp","js unix timestamp"],"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":7,"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/format-javascript-date-10-aug-2010-string","name":"How to Format JavaScript Date to '10-Aug-2010' String","position":8,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/format-javascript-date-10-aug-2010-string","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/format-javascript-date-10-aug-2010-string"},"inLanguage":"en","dateCreated":"2025-10-21T20:59:58.879Z","datePublished":"2025-10-21T20:59:58.879Z","dateModified":"2026-01-05T15:48:27.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":"How to Format JavaScript Date to '10-Aug-2010' String","description":"Learn javascript date format for '10-Aug-2010' using manual mapping, Intl.DateTimeFormat, or date-fns. Covers js date to string format functions, js string to date parsing, date string javascript examples, and locale-aware options.","keywords":["javascript date format","js date to string format","js string to date","date string javascript","js date to iso string","format date javascript","javascript date to string","intl datetimeformat","date-fns format"],"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":9,"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":""}},{"@type":"ListItem","@id":"https://neuroanswers.net/c/web/q/css-sticky-toggle-button-sliding-animation-scroll","name":"CSS Sticky Toggle Button: Sliding Animation on Scroll","position":10,"item":{"@type":"Article","@id":"https://neuroanswers.net/c/web/q/css-sticky-toggle-button-sliding-animation-scroll","mainEntityOfPage":{"@type":"WebPage","@id":"https://neuroanswers.net/c/web/q/css-sticky-toggle-button-sliding-animation-scroll"},"inLanguage":"en","dateCreated":"2026-02-06T16:49:41.920Z","datePublished":"2026-02-06T16:49:41.920Z","dateModified":"2026-02-06T16:49:41.920Z","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":"CSS Sticky Toggle Button: Sliding Animation on Scroll","description":"Create smooth sliding animation for CSS sticky toggle button that fills space when hiding content on scroll (>50px). Flexbox, grid, JS solutions with code for position sticky scroll animation CSS and toggle button CSS.","keywords":["css sticky","scroll animation css","toggle button css","sliding animation toggle button scroll","position sticky","sticky button animation","flexbox height transition","grid template rows animation","animate height auto css","hide content on scroll css","css sticky toggle button"],"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 3 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