Onload function is not working.I cannot play the song automatically when the song is loaded.Here is my view.
<div class="main" onload="enableAutoplay()">
<div class="audio-name">
<h1><?php echo str_replace('_',' ',$name);?></h1>
</div>
<center>
<audio id="audio" controls="controls" >
<source src="<?php echo base_url();?>musics/<?php echo $name;?>" type="audio/mp3" >
</audio>
</center>
<center><a href="<?php echo base_url();?>admin/audio/showaudio" class='back'>Back to All song list</a></center>
</div>
<script>
var vid = document.getElementById("audio");
function enableAutoplay() {
vid.autoplay = true;
vid.load();
}
function disableAutoplay() {
vid.autoplay = false;
vid.load();
}
function checkAutoplay() {
alert(vid.autoplay);
}
</script>
i like to play the song when user click the song name.but here user have to click the "play" button to play the song.