dimanche 15 mai 2022

Random videos followed by selected videos from array

I've been making a site that plays 60 random videos (without duplicates) one after the other. However, I'd like it to play certain videos after a certain amount of videos have been played. Once the selected video has been played, it then returns back to stepping through the random shuffled of videos. For example, '1,40,32,21,45,(chosen video), 59, 11,18,27,(chosen video) etc etc. It's important that the selected video's are not then included in the 60 shuffled videos. Hope that makes sense...I'm very much a beginner so any help would be much appreciated!

Thanks a lot :)

var clip = document.querySelector("#OracleVidSRC");
var video = document.querySelector("#OracleVid");
var oracleVidArray = [
"mp4s/1-£2000.mp4",
"mp4s/2-1-2.mp4",
"mp4s/3-I_love_you.mp4",
"mp4s/4-Anger.mp4",
"mp4s/5-ASMR.mp4",
"mp4s/6-Implementation.mp4",
"mp4s/7-Bird_Aria.mp4",
"mp4s/8-Birth.mp4",
"mp4s/9-Participation.mp4",
"mp4s/10-The_cafe.mp4",
"mp4s/11-Contrabasso.mp4",
"mp4s/12-A_new_friend.mp4",
"mp4s/13-Dream.mp4",
"mp4s/14-Farewell_steven.mp4",
"mp4s/15-Feldman.mp4",
"mp4s/16-Unfortunate.mp4",
"mp4s/17-Game_show.mp4",
"mp4s/18-Perseverance.mp4",
"mp4s/19-We're_going_down_to_the_river.mp4",
"mp4s/20-Hallelujah.mp4",
"mp4s/21-Help.mp4",
"mp4s/22-How_am_I_gonna_walk away_from_this.mp4",
"mp4s/23-A_lovely_way_of_putting_it.mp4",
"mp4s/24-I_am_a_conductor.mp4",
"mp4s/25-I_am_alive_and_shall_go_on.mp4",
"mp4s/26-I_need_a_man.mp4",
"mp4s/27-Introduce_the_band.mp4",
"mp4s/28-Is_it_too_late.mp4",
"mp4s/29-Let's_rock.mp4",
"mp4s/30-Positive_influence.mp4",
"mp4s/31-Misplacement.mp4",
"mp4s/32-The_opening.mp4",
"mp4s/33-One_eye_the_other_the_other_of_a_doll.mp4",
"mp4s/34-Please_let's_have_a_chat_mister_boss.mp4",
"mp4s/35-Using_initiative.mp4",
"mp4s/36-Schubert.mp4",
"mp4s/37-Slow_dance.mp4",
"mp4s/38-Stockhausen.mp4",
"mp4s/39-Stop.mp4",
"mp4s/40-The_ball.mp4",
"mp4s/41-The_concert.mp4",
"mp4s/42-The_desert.mp4",
"mp4s/43-I'm_sorry.mp4",
"mp4s/44-The_mountain.mp4",
"mp4s/45-Try.mp4",
"mp4s/46-Upon_who's_silence_stands.mp4",
"mp4s/47-We_have_to_face_it.mp4",
"mp4s/48-Webern.mp4",
"mp4s/49-The_walk_that_turned_into_a_dance.mp4",
"mp4s/50-Decision.mp4",
"mp4s/50-Individual_responsibility.mp4",
"mp4s/51-What_is_modular_synthesis?.mp4",
"mp4s/52-William_s_burroughs.mp4",
"mp4s/53-Wolf_tune.mp4",
"mp4s/54-Worlds.mp4",
"mp4s/55-Seeking_knowledge.mp4",
"mp4s/56-Anticipation.mp4",
"mp4s/57-Puccini_giacomo.mp4",
"mp4s/59-Phil.mp4",
"mp4s/60-Motivation.mp4",
"mp4s/Angel_clip.mp4",
"mp4s/Chicken_clip.mp4"


 ];



 var count = 0;


function oracleClicked() {
  let sortedRandom = ranNums[count];
  console.log (ranNums);
clip.src = oracleVidArray[sortedRandom];
count += 1;
video.style = "display: block";
video.load();





}

function shuffle(array) {
    var i = array.length,
        j = 0,
        temp;

    while (i--) {

        j = Math.floor(Math.random() * (i+1));

        // swap randomly chosen element with current element
        temp = array[i];
        array[i] = array[j];
        array[j] = temp;


    }

    return array;
}

var ranNums = shuffle([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]);





video.addEventListener('ended', oracleClicked)



Aucun commentaire:

Enregistrer un commentaire