Skip to content

Instantly share code, notes, and snippets.

@MeoMix
Created July 21, 2015 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MeoMix/be5485584baf2a5c016d to your computer and use it in GitHub Desktop.
Save MeoMix/be5485584baf2a5c016d to your computer and use it in GitHub Desktop.
} else if (responseType === 'arraybuffer') {
// The itag is a unique identifier which provides a 1:1 between videoInfo and a video data response.
var itag = (responseURL.split('itag=')[1] || '').split('&')[0];
// There's no guarantee that the current request is a video data response.
if (itag !== '') {
var videoInfo = videoInfoList.filter(function(object) {
return object.itag === itag;
})[0];
if (videoInfo) {
// Notify background of video information data necessary to render the video on another page.
// The type of video (including codec) as well as the ArrayBuffer of video data.
var message = {
buffer: this.response.slice(0),
bufferType: videoInfo.type
};
// Be sure to mark the buffer as transferable as it can be a large amount of data.
window.top.postMessage(message, origin, [message.buffer]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment