Skip to content

Instantly share code, notes, and snippets.

@macariojames
Forked from danro/remove-video.js
Created November 2, 2016 18:26
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 macariojames/01a4dd4a6f790b10ffc301aa5d498200 to your computer and use it in GitHub Desktop.
Save macariojames/01a4dd4a6f790b10ffc301aa5d498200 to your computer and use it in GitHub Desktop.
Remove HTML5 video and clear src attribute to prevent leaks.
// remove audio + video + stop all the downloadin’
// assumes $video and $audio are jQuery selectors for <video> and <audio> tags.
var removeMedia = function () {
_.each([$video, $audio], function ($media) {
if (!$media.length) return;
$media[0].pause();
$media[0].src = '';
$media.children('source').prop('src', '');
$media.remove().length = 0;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment