I have two video sources that are outputted to my page via ajax (the second is hidden). I play the first one and bind an event onto it so that when it has ended the next video is played and shown whilst the first is then paused, rewinded back to 0, and the process continues.
here is my code.
function queueVideos(num, amount) {
if (num < amount) {
document.getElementById('video-element-'+num).addEventListener('ended', playNextClip, false);
function playNextClip() {
var nextVid = num + 1;
$( '#video-element-' + nextVid ).show().get(0).play();
$( '#video-element-' + num ).hide();
document.getElementById( 'video-element-' + num ).pause();
document.getElementById( 'video-element-' + num ).currentTime = 0;
queueVideos(nextVid, amount)
}
}
if (num == amount) {
document.getElementById('video-element-'+num).addEventListener('ended', playFirst, false);
function playFirst() {
$( '#video-element-1' ).show().get(0).play();
$( '#video-element-' + num ).hide();
document.getElementById( 'video-element-' + num ).pause();
document.getElementById( 'video-element-' + num ).currentTime = 0;
queueVideos(1, amount);
}
}
}
The code is called within an ajax function that feeds it the num and amount from data i get elsewhere, for arguments sake let's say i'm running it like so:
queueVideos(1, 2);
My problem is that after around 1 minute the transitions between the clips get laggy, the clips pause unexpectedly, and ultimately the browser (chrome) performs slowly.
How can I fix this?
Thanks!
I have an array with this loop: var arr = [5, 4, 9, 6, 4]; var sum = 0; arr.forEach(function(item) { sum += parseInt(item); console.log(sum) }); At the moment, I get ...
I have an array with this loop: var arr = [5, 4, 9, 6, 4]; var sum = 0; arr.forEach(function(item) { sum += parseInt(item); console.log(sum) }); At the moment, I get ...
I've built a page with 3 elements, each of which looks like this: <div class="col-md-4 event-type"> <a href="{{ pathFor 'step2' }}" id="eventchoice" name="eventchoice" value="corporate"> &...
I've built a page with 3 elements, each of which looks like this: <div class="col-md-4 event-type"> <a href="{{ pathFor 'step2' }}" id="eventchoice" name="eventchoice" value="corporate"> &...
is there an elegant way to determine, whether an array like this: [ {id: 1, value: false}, {id: 2, value: true}, {id: 3, value: false}, {id: 4, value: true}, {id: 5, value: true} ] ...
is there an elegant way to determine, whether an array like this: [ {id: 1, value: false}, {id: 2, value: true}, {id: 3, value: false}, {id: 4, value: true}, {id: 5, value: true} ] ...
I am having a problem where i'm trying to render pass an array's data to a card component but it doesn't appear on the page, the card component renders normally on its own: import React, { Component }...
I am having a problem where i'm trying to render pass an array's data to a card component but it doesn't appear on the page, the card component renders normally on its own: import React, { Component }...