Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var supports_autoplay = function(cb) {
- var r = [];
- // try to play video
- var v = document.createElement("video");
- v.paused = true;
- var vp = "play" in v && v.play();
- r.video = !v.paused || "Promise" in window && vp instanceof Promise;
- // try to play audio
- var a = document.createElement("audio");
- a.paused = true;
- "play" in a && a.play();
- r.audio = !a.paused;
- cb(r);
- };
Add Comment
Please, Sign In to add comment