Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How to give audio files path in javascript's dictionary in VS Code

everyone I am getting an issue in audio files that I have been trying to give them the path in javascript's dictionary for creating a music player. I already used 'src' and 'URL' before the file path but every time function did not work. I just want to know how I can give them the path that function can access and play songs that are inside the dictionary. Any help would be appreciated. I am a fresher and learning programming by myself. Thanks

Here is the complete code.......

enter code here
 <script>
        let pause_btn = document.querySelector('.playPause');
        let backward_btn = document.querySelector('.playBack');
        let next_btn = document.querySelector('.playNext');

        let track_index = 0;
        let curr_track = document.createElement('audio');
        isPlaying = false;
        let updateTimer;
        let track_list =[{
            path: url(../music/song.mp3)}///////HERE I AM GETTING AN ISSUE
        ]

        function loadTrack(track_index){
            clearInterval(updateTimer);
            // resetValues();
            //load a new track
            curr_track.src = track_list[track_index].path;
            curr_track.load();
            //update time interval
            updateTimer = setInterval(seekUpdate,1000);
            //move to the next track if the current finishes playing using the 'ended' event
            curr_track.addEventListener('ended',next_song)
        }
        function playTrack(){
            curr_track.play();
            isPlaying = true;
            pause_btn.innerHTML = "<i class= 'fa fa-pause-circle fa-5x'></i>";
        }
        function pauseTrack(){
            curr_track.pause();
            isPlaying =false;
            pause_btn.innerHTML = "<i class= 'fa fa-play-circle fa-5x'></i>";

        }
        function play_pause_track(){
            if(!isPlaying)playTrack();
            else pauseTrack();
        }
        
        function previous_song(){
            if(track_index>0){
                track_index -=1;
            }else{
                track_index = track_list.length-1;
            }
            curr_track.load();
            playTrack();
        }
        function next_song(){
            if(track_index<track_list.length-1){
                track_index+=1;
            }else{
                track_index =0;
            }
            curr_track.load();
            playTrack();
        }
    </script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First sure that your URL is correct and then try:

let track_list =[{
        path: "../music/song.mp3"}
    ]
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda