SplitmediaLabsLimited / xjs

XSplit JS Framework. Make plugins for XSplit Broadcaster, quickly and easily.
Other
39 stars 11 forks source link

Allow hidden plugins to make noise #131

Closed paul-lrr closed 7 years ago

paul-lrr commented 7 years ago

So back in the early days of xsplit plugins, source plugins that play sound would continue making noise even when hidden or on a non-active scene (if they were kept in memory). In order to get a plugin to obey xsplit's volume commands and mute when hidden you would have to add a handler for the SetVolume() function to manually tell your player to change volume. At some point it seems that you changed things so that xsplit has overriding control of source plugin volume and automatically mutes it when hidden or on a non-active scene without the need for setVolume().

This is probably an overall improvement, but I find myself in the need of the old functionality. As in I would like to make a source plugin that continues to make noise even when hidden or on another scene and then use setVolume() to manually control how it reacts to changes in the volume control. Is there anything I can do in the plugin script or maybe a directive in plugin config file to tell it to ignore the normal xsplit volume commands?

On a related note, is there any documentation on how to tie into the play/pause/stop etc buttons beside the volume control in HTML source plugins? I didn't see anything on the API website about how to get these to work and putting a <CanPlay>true<\CanPlay> directive in the config file didn't seem to do anything.

SML-MeSo commented 7 years ago

Currently SetVolume(volume) is never called whenever native sound control for CEF sources is enabled (Tools > Settings > Advanced > Enable native Flash and browser audio control). The only workaround for your case is to disable native sound control. The SetVolume callback will come back, automatic muting of all HTML sources is disabled but it also disables the ability to render audio of HTML sources to 'Stream Only' (audio will always be heard as long as source is loaded, unless manually muted/volume changed to 0).

As for the question regarding the playback buttons, maybe this screenshot will help: https://321.show/L0J0Af7NTgd

Sorry, but the screenshot is part of the documentation for our initial iteration of making HTML source plugins which never make it out to public release which is why this uses the native API.

As a summary:

in the source properties dialog, upon clicking the playback buttons:

paul-lrr commented 7 years ago

With native Flash and browser audio control disabled, setVolume(volume) is called, but no matter what I do in that function, the source's volume is controlled by xsplit anyway.

Example:

var audio = new Audio('song.mp3');
audio.volume = 1;
audio.play();

function SetVolume (vol) {
    console.log('xsplit:'+vol,"audio.volume:"+audio.volume);
}
Console.log output:
INITIAL
xsplit:100 audio.volume:1 //song plays at normal volume

CLICK MUTE IN SOURCE PROPERTIES
xsplit:0 audio.volume:1 //song is muted even though the audio.volume hasn't changed

UNMUTE IN SOURCE PROPERTIES
xsplit:100 audio.volume:1 //song audio returns

SET VOLUME SLIDER IN SOURCE PROPERTIES TO 50%
xsplit:50 audio.volume:1 //song audio changes to 50% volume

As you can see, the volume of the audio in the source seems to be overridden by xsplit regardless of what the volume property of my audio object is set to. The same thing happens when a source is hidden or on a non-active scene.

Thanks for the info about the playback controls . Are there any plans to make those part of the current xjs api?

mikeybanez commented 7 years ago

Regarding playback controls:

If I remember correctly, the reason for not including this in the API is the same reason for why the "HTML" tab in source properties is not reusable by non-native plugins: it's the idea that not all HTML pages will be "playable"/"next-able", and it probably makes more sense to delegate handling of this to the developer. Compare this to the other reusable tabs (Color, Layout, Effects) which can configure properties that apply to any and all HTML sources.

Basically, there are no plans at the moment to make them part of the API, but we might reconsider this in the future.

paul-lrr commented 7 years ago

Any more info on how to prevent xsplit from overriding the SetVolume() function? As I showed above, with Native browser audio control disabled , SetVolume() is called but xsplit overrides the volume anyway. Alternatively, is there any other way to allow an HTML source to continue making noise when it isn't on the active scene?

SML-MeSo commented 7 years ago

Re-checked and verified it as a bug as XBC should have no control on audio once native browser audio control is disabled. Apparently, this has been a bug since the second update of XBC v2.9 (2.9.1701.1615). This is already filed and will keep you updated as to when this is resolved.

mikeybanez commented 7 years ago

With respect to @paul-lrr 's question about a workaround...

The only workaround we can think of is a very convoluted one. The basic idea is to copy and paste your source across all scenes (and make sure you paste as linked) so that sound still plays, and you somehow inject visibility: hidden and background: transparent as CSS into your page for scenes where you shouldn't see the source.

However, since sources are not able to get the scene index of any scene that's loading, you'll have to listen to the scene-load event through an extension, which you'll want to configure to set the target source's configuration to toggle the transparency CSS.

It's really a lot of work, but it could be worth a shot if you need this behavior before we get a fix in the app.

@SML-MeSo can you please indicate the internal issue number you filed earlier? (for easy tracking later)

SML-MeSo commented 7 years ago

@Matrim-Cauthon It's CPPCORE-1243

paul-lrr commented 7 years ago

Thanks for the info. It is good to know that I wasn't just doing something wrong. FWIW if a change is being made to XBC anyway, it would be nice if who has control of the source's volume could be specified on a per-plugin basis with a directive in the xml file instead of having to be set app-wide.

i.e. Xsplit having control makes sense for a default but maybe that could be bypassed by putting <NativeAudio>false</NativeAudio> in the config xml file.

mikeybanez commented 7 years ago

Internal item CPPCORE-1244 is now closed. A new property for keeping audio is exposed so we can probably wrap this property in our API now.

Minimum version would be the next XBC version (the one currently in the PTR). @SML-MeSo this looks to be a simple property getter/setter, so I suspect we can include this in the next xjs version. Please verify if there are further complications.