Loadingscreen music stopping after 2 sec or not playing

Hello,

I have a problem playing music in the FiveM loadingscreenie. Namely, I wrote a page and a JS script for it to switch music and change volume. Everything works as it should, in the browser, the music can be switched and wgl. The stairs started at FiveM, where CSS to remake and SOME! (so far 2 audio files) work, I don’t know what it depends on. They are in .ogg format, they are in the file “__resurce.lua”, but they do not play. Tried changing files to other ones, renaming, extensions and nothing. Anyone had a similar situation?

Thank you in advance for your help

Sorry for my english :stuck_out_tongue:

GitHub: GitHub - R3IC0P/loadscreen: Loading screen for FiveM

Hey, can you share you code I’ll help you.

window.onload = function () {
   document.body.addEventListener("mousemove", function (event) {
      let cursor = document.getElementById("cursor");

      let x = event.pageX - cursor.width + 23;
      let y = event.pageY - 1;

      cursor.style.left = x;
      cursor.style.top = y;
   });
}

let audio = document.getElementById('music1');
let prev_btn = document.querySelector('.prev-btn');
let next_btn = document.querySelector('.next-btn');

let currTrack = null;

let songs = {
   first: document.getElementById('music1'),
   second: document.getElementById('music2'),
   third: document.getElementById('music3')
};

let volume = document.querySelector('#volume-control');
volume.addEventListener('change', function(e) {
   songs.first.volume = e.currentTarget.value / 100;
   songs.second.volume = e.currentTarget.value / 100;
   songs.third.volume = e.currentTarget.value / 100;
})

function playMusic() {
   if (audio.paused) {
      audio.volume = 0.3;
      audio.play();
      currTrack++;
      console.log(currTrack);
   }
};

playMusic();

function puaseSongs() {
   songs.first.pause();
   songs.second.pause();
   songs.third.pause();
}

function next() {
   if (currTrack === 1) {
      puaseSongs();
      songs.second.play();
      currTrack++;
      console.log(currTrack);
   } else if (currTrack === 2) {
      puaseSongs();
      songs.third.play();
      currTrack++;
      console.log(currTrack);
   }  else {}
};

function prev() {
   if (currTrack === 3) {
      puaseSongs();
      songs.second.play();
      currTrack--;
      console.log(currTrack);
   } else if (currTrack === 2) {
      puaseSongs();
      songs.first.play();
      currTrack--;
      console.log(currTrack);
   } else {}
};

there are probably a lot of bugs here. But i’m learning: D