Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement audio speed control #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions adventures.html
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,19 @@ <h3 class="text-lg mt-2">
>
<i class="bi bi-volume-up-fill"></i>
</div>
<!-- Speed Control Buttons -->
<div class="ctrl-button ctrl-button-small" id="speed-0.5x">
<span>0.5x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-1x">
<span>1x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-1.5x">
<span>1.5x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-2x">
<span>2x</span>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@ document.addEventListener("DOMContentLoaded", function () {

// Event listener for "Previous" button
if (prevBtn) prevBtn.addEventListener("click", prevPage);

// Speed control buttons functionality
const speedButtons = document.querySelectorAll("[id^='speed-']");
speedButtons.forEach((button) => {
button.addEventListener("click", function () {
const speed = parseFloat(this.id.split("-")[1]);
audioPlayer.playbackRate = speed;
});
});
});
13 changes: 13 additions & 0 deletions fs.html
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,19 @@ <h3 class="text-lg mt-2">By Mary Shelby</h3>
>
<i class="bi bi-volume-up-fill"></i>
</div>
<!-- Speed Control Buttons -->
<div class="ctrl-button ctrl-button-small" id="speed-0.5x">
<span>0.5x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-1x">
<span>1x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-1.5x">
<span>1.5x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-2x">
<span>2x</span>
</div>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions rdpd.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@ <h3 class="text-lg mt-2">By Yuval Noah Harari</h3>
>
<i class="bi bi-volume-up-fill"></i>
</div>
<!-- Speed Control Buttons -->
<div class="ctrl-button ctrl-button-small" id="speed-0.5x">
<span>0.5x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-1x">
<span>1x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-1.5x">
<span>1.5x</span>
</div>
<div class="ctrl-button ctrl-button-small" id="speed-2x">
<span>2x</span>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@ document.addEventListener("DOMContentLoaded", function () {
}
});
});

// Speed control buttons functionality
const speedButtons = document.querySelectorAll("[id^='speed-']");
speedButtons.forEach((button) => {
button.addEventListener("click", function () {
const speed = parseFloat(this.id.split("-")[1]);
audioPlayer.playbackRate = speed;
});
});
});
// Function to load an HTML file into an element
function loadHTML(file, elementId) {
Expand Down