Oncorporation / CastorLazyPack

Castor's Lazy Pack Development Repository
7 stars 5 forks source link

Volume setting not applied to videos #2

Open Genide opened 5 years ago

Genide commented 5 years ago

The volume slider in the script configuration does not change the volume of played movies. This includes $movie and $movyt. I assume that this issue also includes twitch clips as well. Regardless of what volume this slider is at, the played movies are always at full volume.

image

Oncorporation commented 5 years ago

The clips are being played in the browser source, you may be able to adjust volume at the browser source .

I also work on OBS and Streamlabs and will review this on that level.

If that is not reasonable, I will investigate sending a volume indicator to the browser source.

Genide commented 5 years ago

Is it possible to set the "volume" property on the video tag?

Genide commented 5 years ago

For the youtube video link, you have to use the youtube iframe APIs to load and manipulate the video and volume.

I manually edited the code and get this somewhat working. I added the following to the beginning of client.js

var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

function onYouTubeIframeAPIReady() {
  player = new YT.Player('divYT', {});
  var iframe;
  iframe=player.getIframe();
  addClass(iframe, 'hidden');
  addClass(iframe, 'video');
  iframe.width="";
  iframe.height="";
}

And replaced case 'framesrc' with the following

            case 'framesrc':
                 var vidObj = {
                  'videoId': MySet.link,
                  'startSeconds': MySet.start,
                  'endSeconds': (Number(MySet.start) + (MySet.duration / 1000))
                }
                player.loadVideoById(vidObj);
                player.setVolume(30);   // Set volume to whatever it should be here. 0 - 100

                removeClass(player.getIframe(), "hidden")
                await timeout(MySet.duration);
                addClass(player.getIframe(), 'hidden');
                await timeout(1000);

                callback();
                break;

I also added a div to index.html <div id="divYT"></div>