Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda