Skip to content

playlist autoplay but has not sound

I have a playlist in javascript, when it is muted the video plays automatically, otherwise it doesn’t play automatically.

How can I make autoplay and muted false?

My code HTML is:

<video  id="vid" src="main/" style="width:1360px; height:750px; visibility:visibility;"  controls playsinline     >

var separador = ";";
var video = document.currentScript.parentElement;
var sec = document.getElementById("valor").textContent;
var playlist = sec.split(separador);
video.volume = 0.1;

var lastSong = null;
var selection = null;
var video = document.getElementById("vid");

video.autoplay = true;
video.muted = true;

video.addEventListener("ended", selectRandom);
function selectRandom() {
  while (selection == lastSong) {

    selection = Math.floor(Math.random() * playlist.length);


  lastSong = selection;
  video.src = playlist[selection];





You can’t play a video automatically with sound. There’s a thing called “Autoplay Policy”, at least for Chrome, but all other browsers are trying to block it.

See more information here.

User contributions licensed under: CC BY-SA
7 People found this is helpful