GithubHelp home page GithubHelp logo

Comments (2)

stamat avatar stamat commented on July 28, 2024 1

Hey hey @another-blank-page, so I've added a global variable VIDEO_BACKGROUNDS, now when jQuery is being used, and also an uniform function for setting the volume regardless of the type of the video. So you can still use jQuery and have this global variable out of the box.

for (let uid in VIDEO_BACKGROUNDS.index) {
  VIDEO_BACKGROUNDS.index[uid].setVolume(0.15);
}

You can also set the initial volume via an attribute data-vbg-volume="0.15.

Just remember that on mobile the mobile phone volume is picked up and this setting won't have an effect!

This update is in the latest release v1.0.18

Cheers! πŸ₯‚

from youtube-background.

stamat avatar stamat commented on July 28, 2024

Hey there @another-blank-page! ✨ So, first of all this was intended to be just the background, without the capability of sound, I seriously cannot remember why I added the mute/unmute option. Anyway, I will add an attribute setting for the volume just for you, so stay tuned. The issue is that you are using jQuery which looses the reference for the index (facrory) object. VideoBackgrounds object holds the index of all of the players.

Instead of using jQuery you can do this:

// Initialize the VideoBackgrounds object using vanilla JS
const videoBackgrounds = new VideoBackgrounds('[data-vbg]', { your_properties: here });
// Loop through all of the initialized backgrounds, each background contains the player variable 
// and depending on the Video, Vimeo, Youtube players you can set the volume. 
// Just remember that the youtube videos wait for `window.onYouTubeIframeAPIReady` to be triggered.
for (let uid in videoBackgrounds.index) {
  if (videoBackgrounds.index[uid] instanceof YoutubeBackground) {
    videoBackgrounds.index[uid].player.setVolume(15); // this should set the volume for all your youtube backgrounds, setting ranges from 0-100
  }
}

That's bout it! ☺️ One quick update with volume is comming right up!

from youtube-background.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.