Skip to content

Commit

Permalink
Merge branch 'develop' into feature/fix_send_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
902seanryan committed Jan 31, 2024
2 parents 86aaa36 + 3bff5ba commit 9672124
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Prevent CaptionsTogglePlugin from sending mute state before Application is loaded.
- updated .nvmrc to 18

## [2.4.6] - 2023-10-16
### Added

- Added a check to make sure plugin preloads are finished before opening up the application to avoid race conditions.

https://github.com/SpringRoll/SpringRollContainer/pull/169


### Fixed

Expand Down
2 changes: 1 addition & 1 deletion dist/SpringRoll-Container-umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/SpringRoll-Container-umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Container extends PluginManager {
super({ plugins });

this.iframe = iframeOrSelector instanceof HTMLIFrameElement ? iframeOrSelector : document.querySelector(iframeOrSelector);
this.iframe.style.backgroundColor = 'black';

if (null === this.iframe) {
throw new Error('No iframe was found with the provided selector');
Expand Down Expand Up @@ -141,6 +142,15 @@ export class Container extends PluginManager {
* @memberof Container
*/
_internalOpen(userPath, { singlePlay = false, playOptions = null } = {}) {
// If plugin preloads are still going wait for them to finish before opening the Application
if (this.preloading) {
this.client.on('preloadsFinished', () => {
this._internalOpen(userPath, { singlePlay, playOptions });
});

return;
}

const options = { singlePlay, playOptions };
this.reset();

Expand Down
4 changes: 4 additions & 0 deletions src/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class PluginManager {
*/
constructor({ plugins = [] }) {
this.client = new Bellhop();
this.preloading = true;
// @ts-ignore
this.client.hidden = this.client.receive.bind(this.client);
// @ts-ignore
Expand Down Expand Up @@ -57,6 +58,9 @@ export default class PluginManager {
plugin => plugin.preloadFailed !== true
);

this.preloading = false;
this.client.trigger('preloadsFinished');

//init
this.plugins.forEach(plugin => {
if (!plugin.init) {
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/SoundPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export class SoundPlugin extends ButtonPlugin {
this._sfxMutedByUser = false;
this._voMutedByUser = false;

this.soundMuteEnabled = false;
this.musicMuteEnabled = false;
this.sfxMuteEnabled = false;
this.voMuteEnabled = false;
this.soundMutedEnabled = false;
this.musicMutedEnabled = false;
this.sfxMutedEnabled = false;
this.voMutedEnabled = false;

this.soundVolume = 1;
this.musicVolume = 1;
Expand Down Expand Up @@ -504,16 +504,16 @@ export class SoundPlugin extends ButtonPlugin {

// to avoid the mute property overwriting the volume on startup, mutes should only send if they're true
// or the volume channel isn't enabled
if ( (this.soundButtonsLength > 0 && this.soundMuteEnabled) && (this.soundMuted || !this.soundVolumeEnabled )) {
if ( (this.soundButtonsLength > 0 && this.soundMutedEnabled) && (this.soundMuted || !this.soundVolumeEnabled )) {
this.sendProperty(SoundPlugin.soundMutedKey, this.soundMuted);
}
if ( (this.musicButtonsLength > 0 && this.musicMuteEnabled) && (this.musicMuted || !this.musicVolumeEnabled )) {
if ( (this.musicButtonsLength > 0 && this.musicMutedEnabled) && (this.musicMuted || !this.musicVolumeEnabled )) {
this.sendProperty(SoundPlugin.musicMutedKey, this.musicMuted);
}
if ( (this.voButtonsLength > 0 && this.voMuteEnabled) && ( this.voMuted || !this.voVolumeEnabled )) {
if ( (this.voButtonsLength > 0 && this.voMutedEnabled) && ( this.voMuted || !this.voVolumeEnabled )) {
this.sendProperty(SoundPlugin.voMutedKey, this.voMuted);
}
if ( (this.sfxButtonsLength > 0 && this.sfxMuteEnabled) && (this.sfxMuted || !this.sfxVolumeEnabled )) {
if ( (this.sfxButtonsLength > 0 && this.sfxMutedEnabled) && (this.sfxMuted || !this.sfxVolumeEnabled )) {
this.sendProperty(SoundPlugin.sfxMutedKey, this.sfxMuted);
}
}
Expand Down

0 comments on commit 9672124

Please sign in to comment.