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

video_volume.js will keep all the players volume in sync #166

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ version: '3'
services:
web:
container_name: proxitok-web
image: ghcr.io/pablouser1/proxitok:master
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should let docker-compose use the pre-built image, maybe you were doing some testing and forgot to undo it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, how else could I test? It's just Github automatically picking up the docker-compose changes, this wasn't meant to make it in the PR

#image: ghcr.io/pablouser1/proxitok:latest
build:
context: ./
dockerfile: ./Dockerfile
ports:
- 8080:8080
environment:
Expand All @@ -22,8 +25,8 @@ services:
- proxitok
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
#cap_drop:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you commenting out this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was breaking the Apache container previously. Again, the docker-compose.yml wasn't meant to be included in the PR.

# - ALL
cap_add:
- CHOWN
- SETGID
Expand Down
40 changes: 40 additions & 0 deletions scripts/video_volume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// This will save the video volume and keep all the players on the page in sync
document.addEventListener("DOMContentLoaded", function() {
const videos = document.querySelectorAll("video");

// Function to save the volume to localStorage
function saveVolume(volume) {
localStorage.setItem("videoVolume", volume);
}

// Function to restore the volume from localStorage
function restoreVolume() {
const savedVolume = localStorage.getItem("videoVolume");
if (savedVolume !== null) {
videos.forEach(video => {
video.volume = parseFloat(savedVolume);
});
}
}

// Function to sync the volume across all video elements
function syncVolume(video) {
videos.forEach(otherVideo => {
if (otherVideo !== video) {
otherVideo.volume = video.volume;
}
});
saveVolume(video.volume);
}

// Loop through all video elements and attach event listeners
videos.forEach(video => {
// Save the volume when the volume changes
video.addEventListener("volumechange", function() {
syncVolume(video);
});
});

// Restore the volume on page load
restoreVolume();
});
1 change: 1 addition & 0 deletions templates/layouts/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
{block content}{/block}
</section>
{block extra}{/block}
<script src="{static('js', 'video_volume.js')}"></script>
</body>
</html>
1 change: 1 addition & 0 deletions templates/layouts/hero.latte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</div>
</section>
{block extra}{/block}
<script src="{static('js', 'video_volume.js')}"></script>
</body>

</html>