Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!