How to Auto-Play and Loop Audio and Video files in Android?

By 42Gears Team
Applies to:
Product General
Platform Android
function onPageLoad() { loadVideo(); loadAudio(); }
function loadVideo() { document.getElementById("sampleVideo").src = "./surefox.mp4"; document.getElementById("sampleVideo").load(); startPlayingvideo(); }
function loadAudio() { document.getElementById("sampleAudio").src = "./surefox.mp3"; document.getElementById("sampleAudio").load(); startPlayingaudio(); }
function startPlayingaudio() { //Keep looping the same audio setTimeout(function() { document.getElementById("sampleAudio").play(); },100); } function startPlayingvideo() { //Keep looping the same Video setTimeout(function() { document.getElementById("sampleVideo").play(); },100); }
Note

“Written with expertise and passion to help you understand the topic better.”

4
42Gears Team – Content Author
Published on: October 21, 2013

Subscribe to our newsletter

Stay updated with the latest news, articles, and resources on enterprise mobility.

Weekly articles
Actionable insights delivered once a week. No noise.
No spam
Your privacy matters. Unsubscribe anytime.