How can I remove each link that points to a video after the end of the video?

1

I have this div down, namely with id and having within it elements p followed a (anchor):

var vid = document.getElementById('player');

var link = document.getElementById('lista').getElementsByTagName('a');

var el = document.getElementById('lista').getElementsByTagName('p');

var src0 = vid.src;

var href0 = link.href;

var fonte = [
	"https://sites.google.com/site/mplayerplugin/repositorio/animais_cantando.webm",
	"https://sites.google.com/site/mplayerplugin/repositorio/equipment_these_days.webm",
	"https://sites.google.com/site/mplayerplugin/repositorio/peck_pocketed.webm"
],
    clone = [
	"https://sites.google.com/site/mplayerplugin/repositorio/animais_cantando.webm",
	"https://sites.google.com/site/mplayerplugin/repositorio/equipment_these_days.webm",
	"https://sites.google.com/site/mplayerplugin/repositorio/peck_pocketed.webm"
];

    function proximo() {
    	if (fonte.length === 0) {
        	fonte = clone.slice(0);
    	}
    	var indice = fonte.splice(0, 1);
    	vid.src = indice;
    	vid.autoplay = indice;
	}
window.setInterval(function() {
    	var seg = vid.duration - vid.currentTime;

    	if ((seg - 1) < 0)

	for (var i = 0; i < el.length; i++) {

	if(src0 == href0) // comparar se o atributo src no elemento video e igual a do atributo href

	el[i].outerHTML = '';

	delete el[i].item(0);

		proximo();

	break;
		}
	}, 1000);

proximo();
<video id="player" preload controls></video>

<hr>

<div id='lista'>
	    <p><a href="https://sites.google.com/site/mplayerplugin/repositorio/animais_cantando.webm">Animais cantando</a></p>
	    <p><a href="https://sites.google.com/site/mplayerplugin/repositorio/equipment_these_days.webm">Equipment these days</a></p>
	    <p><a href="https://sites.google.com/site/mplayerplugin/repositorio/peck_pocketed.webm">Peck Pocketed</a></p>
</div>

Well, look closely at my source code and note that I'm doing this automatically, without clicking directly on the link.

    
asked by anonymous 02.04.2017 / 20:52

1 answer

1

Uses el[i].parentNode.removeChild(el[i]); instead of delete el[i].item(0);

var vid = document.getElementById('player');
var link = document.getElementById('lista').getElementsByTagName('a');
var el = document.getElementById('lista').getElementsByTagName('p');

var src0 = vid.src;
var href0 = link.href;
var fonte = [
  "https://sites.google.com/site/mplayerplugin/repositorio/animais_cantando.webm",
  "https://sites.google.com/site/mplayerplugin/repositorio/equipment_these_days.webm",
  "https://sites.google.com/site/mplayerplugin/repositorio/peck_pocketed.webm"
];
var clone = fonte.slice();

function proximo() {
  if (fonte.length === 0) {
    fonte = clone.slice(0);
  }
  var indice = fonte.splice(0, 1);
  vid.src = indice;
  vid.autoplay = indice;
}
window.setInterval(function() {
  var seg = vid.duration - vid.currentTime;
  if ((seg - 1) < 0)
    for (var i = 0; i < el.length; i++) {
      if (src0 == href0) // comparar se o atributo src no elemento video e igual a do atributo href
        el[i].outerHTML = '';
      el[i].parentNode.removeChild(el[i]);
      proximo();
      break;
    }
}, 1000);

proximo();
<video id="player" preload controls></video>
<hr>
<div id='lista'>
  <p><a href="https://sites.google.com/site/mplayerplugin/repositorio/animais_cantando.webm">Animais cantando</a></p>
  <p><a href="https://sites.google.com/site/mplayerplugin/repositorio/equipment_these_days.webm">Equipment these days</a></p>
  <p><a href="https://sites.google.com/site/mplayerplugin/repositorio/peck_pocketed.webm">Peck Pocketed</a></p>
</div>
    
02.04.2017 / 20:55