Professional Documents
Culture Documents
ACP Assignment No (1) : Muhammad Ali Ali Haider
ACP Assignment No (1) : Muhammad Ali Ali Haider
Assignment No (1)
Submitted By
Muhammad Ali
Submitted To
Ali Haider
BS (IT)
6th Semester
Spring-2022
Here I style all divs in CSS and buttons and background color
Now adding next and previous functionality using javascript(onclick) functions to change music
when buttons is clicked
After next and previous we move to change music time functionality
To reset the values such on card add a specific funtion to perform this operation
Calling function and to control the time duration according to range input
Creating a function for time duration
Functions:
Now_playing
track_art
track_name
playpause_btn
next_btn
prev_btn
seek_slider
For Slider which shows the music running Status
let seek_slider = document.querySelector('.seek_slider');
volume_slider
For Volume increasing and decreasing
let volume_slider = document.querySelector('.volume_slider');
curr_time
For current time of the music
let curr_time = document.querySelector('.current-time');
total_duration
Total duration of the music
let total_duration = document.querySelector('.total-duration');
randomIcon
For Playing Random Music
let randomIcon = document.querySelector('.fa-random');
curr_track
Current track of the music
let curr_track = document.createElement('audio');
Functions
For tracking the index. function loadTrack(track_index) For background color.
I have use bg colors for background function random_bg_color()
For resetting the time:
function reset(){ curr_time.textContent = "00:00";
total_duration.textContent = "00:00";
seek_slider.value = 0;
}
isRandom ? pauseRandom() : playRandom();
}
For Playing random music
function playRandom(){ isRandom = true;
randomIcon.classList.add('randomActive');
}
For Pausing random music
function pauseRandom(){ isRandom = false;
randomIcon.classList.remove('randomActive');
}
For repeating the track
function repeatTrack(){
let current_index = track_index; loadTrack(current_index); playTrack();
}
For time Slider
function seekTo(){
let seekto = curr_track.duration * (seek_slider.value / 100); curr_track.currentTime = seekto;
}
For Volume Slider
function setVolume(){
curr_track.volume = volume_slider.value / 100; curr_track.currentvolume = setVolume;
}
For updating the position of slider:
function setUpdate()
Output: