Skip to content

Instantly share code, notes, and snippets.

@beaufortfrancois
Last active April 9, 2018 11:47
Show Gist options
  • Save beaufortfrancois/307e3ffbf8c8435b1fab80831e5dd404 to your computer and use it in GitHub Desktop.
Save beaufortfrancois/307e3ffbf8c8435b1fab80831e5dd404 to your computer and use it in GitHub Desktop.
MSE promisified
// In an ideal world, MSE would be that simple...
const mediaSource = new MediaSource()
video.srcObject = mediaSource
await mediaSource.ready
const sourceBuffer = mediaSource.addSourceBuffer('video/mp4')
const response = await fetch('https://example.com/init.mp4')
const data = await response.arrayBuffer()
await sourceBuffer.appendBuffer(data)
@beaufortfrancois
Copy link
Author

beaufortfrancois commented Apr 9, 2018

@mounirlamouri Here it is:

interface MediaSource : EventTarget {
    readonly attribute Promise<void> ready;
}
interface SourceBuffer : EventTarget {
    Promise<void> appendBuffer(BufferSource data);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment