---
title: "How to use Media Source Extensions with AirPlay"
description: "Media Source Extensions and Apple's Managed Media Source can't be used with AirPlay because they feed binary blobs into a SourceBuffer, and AirPlay needs a real playback URL."
url: "https://swe.quest/articles/how-to-use-media-source-extensions-with-airplay-06e280154b4295b0"
canonical: "https://webkit.org/blog/15036/how-to-use-media-source-extensions-with-airplay/"
source: "WebKit"
published: "2024-02-16"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["video-media","browsers","javascript","frontend"]
---

# How to use Media Source Extensions with AirPlay

A post on [WebKit](https://swe.quest/sources/webkit.md), published 2024-02-16, 4 min read, How-to. Original: [https://webkit.org/blog/15036/how-to-use-media-source-extensions-with-airplay/](https://webkit.org/blog/15036/how-to-use-media-source-extensions-with-airplay/)

## Summary

Media Source Extensions and Apple's Managed Media Source can't be used with AirPlay because they feed binary blobs into a SourceBuffer, and AirPlay needs a real playback URL. The workaround is to give the video element multiple \<source\> children. Put the object URL created from the MediaSource first and an AirPlay-compatible HLS URL second. Safari then shows the AirPlay button and switches to the HLS source when the user casts. The example code feature-detects ManagedMediaSource with a fallback to MediaSource, and it uses the startstreaming event to load segments when that event is available.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Video & media](https://swe.quest/tags/video-media.md) (Domains)
- [Browsers](https://swe.quest/tags/browsers.md) (Web & mobile)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)

## Prerequisites

- HTML video element ([easy posts on Video & media](https://swe.quest/tags/video-media.md?difficulty=easy))
- JavaScript async/await ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- Media Source Extensions basics ([easy posts on Video & media](https://swe.quest/tags/video-media.md?difficulty=easy))

## Keywords

Media Source Extensions, Managed Media Source, AirPlay, HTTP Live Streaming, Safari, WebKit

## Related posts

- [WebKit Features in Safari 17.1](https://swe.quest/articles/webkit-features-in-safari-17-1-a08f621f175b022b.md): WebKit · 2023-10-25 · Easy · 5 min read · Browsers, Video & media, Frontend
  Safari 17.1 brings the Managed Media Source API to iPhone, a power-efficient alternative to Media Source Extensions for adaptive bitrate streaming.
- [What the iPhone Duo means for web development](https://swe.quest/articles/what-the-iphone-duo-means-for-web-development-ae876b58f98678e3.md): Mux · 2026-10-23 · Medium · 8 min read · Frontend, CSS, Browsers, Video & media, Mobile
  Safari on the foldable iPhone Duo exposes the Device Posture API and Viewport Segments API behind WebKit feature flags.
- [Meet Web Push](https://swe.quest/articles/meet-web-push-bf0c9724c735ad8d.md): WebKit · 2022-06-07 · Easy · 4 min read · Browsers, Communications, Frontend
  Safari 16 on macOS Ventura supports Web Push through the W3C Push API, Notifications API and Service Workers, with iOS and iPadOS support planned for 2023.
- [Safari on Apple HomeView](https://swe.quest/articles/safari-on-apple-homeview-214c9d942913d69c.md): WebKit · 2026-11-13 · Medium · 3 min read · Browsers, Frontend, Accessibility, CSS
  Safari now runs on Apple HomeView, a square 7-inch display driven by voice and touch, and most well-built sites need no changes to work there.
- [Building an AI WebTV](https://swe.quest/articles/building-an-ai-webtv-7dad8a539728d692.md): Hugging Face · 2023-07-17 · Medium · 9 min read · Video & media, Inference & serving, TypeScript, Machine learning
  The AI WebTV is an experimental 24/7 stream of short clips generated by open-source text-to-video and music models.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
