Skip to content

Commit

Permalink
More books added with change in design and addtion of button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ctoic committed Jan 11, 2024
1 parent 800e45f commit b778803
Show file tree
Hide file tree
Showing 35 changed files with 318 additions and 20 deletions.
Empty file added ,.
Empty file.
Binary file added Images/cs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 31 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
document.addEventListener("DOMContentLoaded", function () {
const audioPlayer = document.getElementById("audio-player");
const playlistItems = document.querySelectorAll("#playlist li");
const prevBtn = document.getElementById("prev-btn");
const nextBtn = document.getElementById("next-btn");
let currentIndex = 0;

playlistItems.forEach((item) => {
// Function to play the current track
function playTrack(index) {
const audioSource = playlistItems[index].getAttribute("data-src");
audioPlayer.src = audioSource;
audioPlayer.play();
}

// Initial play
playTrack(currentIndex);

// Event listener for "Next" button
nextBtn.addEventListener("click", function () {
currentIndex = (currentIndex + 1) % playlistItems.length;
playTrack(currentIndex);
});

// Event listener for "Previous" button
prevBtn.addEventListener("click", function () {
currentIndex = (currentIndex - 1 + playlistItems.length) % playlistItems.length;
playTrack(currentIndex);
});

// Event listener for playlist items
playlistItems.forEach((item, index) => {
item.addEventListener("click", function () {
const audioSource = this.getAttribute("data-src");
audioPlayer.src = audioSource;
audioPlayer.play();
currentIndex = index;
playTrack(currentIndex);
});
});

// Event listener for form submission (comments)
const commentForm = document.getElementById("comment-form");
const commentsList = document.getElementById("comments-list");

Expand Down
Loading

0 comments on commit b778803

Please sign in to comment.