1. Home
  2. Knowledge Base
  3. How to Auto-Play and Loop Audio and Video files in Android?

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

The Auto-play and Loop functions in Android are disabled to minimize the user bandwidth however this post may offer you some help if trying to find a quick fix for this problem.

All you have to do is to follow the below steps.

1. Use the following script for your HTML file –

unction onPageLoad()

function loadVideo()
document.getElementById(“sampleVideo”).src = “./surefox.mp4”;

function loadAudio()
document.getElementById(“sampleAudio”).src = “./surefox.mp3”;

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 – Change the name of the audio and video file accordingly and make necessary changes if using only video or only audio files.

2. For the body of the HTML file, use the following –

<body onload=”onPageLoad()”>
<div style=”width:10px;height:310px;padding:5px;”>
<video id=”sampleVideo” style=”width:300px;height:300px;” controls=”controls” onended=”startPlayingvideo()” ></video>
<audio id=”sampleAudio” style=”width:300px;height:300px;” controls=”controls” onended=”startPlayingaudio()” ></audio>

For a quick check, download a sample file by clicking click here.
For more details on our products, click here 
If you need further assistance, please submit a ticket here

Was this helpful?
Updated on June 2021