A
A
Arseniy Sokolovsky2021-02-16 21:51:59
JavaScript
Arseniy Sokolovsky, 2021-02-16 21:51:59

How to take timestamps from a file, but to make them work in a script?

I have a script

let videoSetStupidLove = 2800;
let speedStupidLove = 1005;
let iStupidLove = 1;
let iStupidLove_2;
let canplaygold = true;
function stupidLovePictGo(){
  
  let ins = document.getElementById('in');

          let his = document.createElement('his');
          his.className = "his";
          ins.prepend(his);
  setTimeout(nexte, videoSetStupidLove);
  function nexte(){
               var audio = new Audio();
    audio.src = "***";
    audio.play();
    audio.volume = 0.0;
    codename = 'StupidLove';
    $.getJSON( '/maps/2021/' + codename + '/' + codename + '.json', function(map) { 
           
       });
    var lirycs = [
        
    ];
    var next_name = lirycs.shift();
    var checker = setInterval(function(){
      if(end==0){

        if(next_name.time==80347&&canplaygold == true||next_name.time==196244&&canplaygold == true){
            canplaygold = false; 
           goldMoveGoing();
        }
        
        if(next_name.time==71194){
          speedStupidLove = 1002;
        }

        if(next_name.time<audio.currentTime*speedStupidLove){
         
          
  
            let dvi = document.createElement('div');
     dvi.className = "dvi";
     his.prepend(dvi);
    
            let dv = document.createElement('div');
     dv.className = "dv";
     dvi.prepend(dv);
    
            let imgss = document.createElement('img');
     imgss.className = "picto-go";
     imgss.id = "hi" + iStupidLove;
     imgss.style.zIndex = iStupidLove;
     imgss.style.width = 235 + 'px';
     imgss.style.height = 235 + 'px';
    imgss.src = '/maps/2021/StupidLove/pictograms/' + next_name.name + '.png';
    dv.prepend(imgss);
    document.getElementById('hi' + iStupidLove).animate({
    top: ['567px', '567px', '567px'],
    left: [ '1540px', '956px', '956px'],
    opacity: [ 1, 1, 0 ],
    transform: [ 'scale(1)', 'scale(1)', 'scale(1.2)' ],
    offset: [ 0, 0.9275, 1 ]
  }, {
    duration: 2500,
    fill: "forwards",
  });
    iStupidLove++;
    console.log(next_name.time + ' ' + next_name.name);
            next_name = lirycs.shift();
            
        }
      }
        if(audio.ended)clearInterval(checker);
    });
    
  }
         };

      function goldMoveGoing(){
        canplaygold = false;   
               var foldaudio = new Audio(); // Создаём новый элемент Audio
               foldaudio.src = '/audio/fullgoldmove.mp3'; // Указываем путь к звуку "клика"
               foldaudio.autoplay = true; // Автоматически запускаем
               foldaudio.volume = .5;
               setTimeout(playgold,6070)
               function playgold(){
                goldmove();
               }
setTimeout(can,4000)
               function can(){
                canplaygold = true;   
               }
             
      }

and there is a lyrics variable, it is necessary that its value is taken from json , like this
$.getJSON( '/maps/2021/' + codename + '/' + codename + '.json', function(map) { 
           
       });

json looks like this:
{
    "Mapname": "StupidLove",
    "Title": "Stupid Love",
    "Artist":"Lady Gaga",
    "Difficulty": "Normal",
    "JDVersion": "JDOnline",
    "NumCoach": "Solo",
    "OriginalJDVersion": 2021,
    "assets":{
        "Cover_Generic":"***",
        "Cover_AlbumCoach":"***",
        "Coach_1":"***",
        "Map_Bkg":"***",
        "videoPreview":"***",
        "videoCoach":"***"
    },
    "pictos":[
        {
            "duration": "339",
            "name": "starting_sh",
            "time": "2032"
        },
        {
            "duration": "339",
            "name": "fist_sh",
            "time": "2541"
        }
    ]
}

pictos has duration, name and time, so you need this part
{
            "duration": "339",
            "name": "starting_sh",
            "time": "2032"
        },
        {
            "duration": "339",
            "name": "fist_sh",
            "time": "2541"
        }


put in lirycs and have it work and read the array.

I explained very poorly and most likely it is not clear ..
If you can somehow, please help and tell me how to combine getting a dson and using it in a script, otherwise I'm in this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-02-16
@SokolarGm

fetch('/maps/2021/' + codename + '/' + codename + '.json')
  .then(r => r.json())
  .then(data => {
    data.pictos // делаем что-то
  })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question