Skip to content

Commit 9672124

Browse files
committed
Merge branch 'develop' into feature/fix_send_properties
2 parents 86aaa36 + 3bff5ba commit 9672124

File tree

8 files changed

+32
-13
lines changed

8 files changed

+32
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Prevent CaptionsTogglePlugin from sending mute state before Application is loaded.
1414
- updated .nvmrc to 18
1515

16-
## [2.4.6] - 2023-10-16
16+
### Added
17+
18+
- Added a check to make sure plugin preloads are finished before opening up the application to avoid race conditions.
19+
20+
https://github.com/SpringRoll/SpringRollContainer/pull/169
21+
1722

1823
### Fixed
1924

dist/SpringRoll-Container-umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/SpringRoll-Container-umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Container.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class Container extends PluginManager {
2828
super({ plugins });
2929

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

3233
if (null === this.iframe) {
3334
throw new Error('No iframe was found with the provided selector');
@@ -141,6 +142,15 @@ export class Container extends PluginManager {
141142
* @memberof Container
142143
*/
143144
_internalOpen(userPath, { singlePlay = false, playOptions = null } = {}) {
145+
// If plugin preloads are still going wait for them to finish before opening the Application
146+
if (this.preloading) {
147+
this.client.on('preloadsFinished', () => {
148+
this._internalOpen(userPath, { singlePlay, playOptions });
149+
});
150+
151+
return;
152+
}
153+
144154
const options = { singlePlay, playOptions };
145155
this.reset();
146156

src/PluginManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class PluginManager {
1515
*/
1616
constructor({ plugins = [] }) {
1717
this.client = new Bellhop();
18+
this.preloading = true;
1819
// @ts-ignore
1920
this.client.hidden = this.client.receive.bind(this.client);
2021
// @ts-ignore
@@ -57,6 +58,9 @@ export default class PluginManager {
5758
plugin => plugin.preloadFailed !== true
5859
);
5960

61+
this.preloading = false;
62+
this.client.trigger('preloadsFinished');
63+
6064
//init
6165
this.plugins.forEach(plugin => {
6266
if (!plugin.init) {

src/plugins/SoundPlugin.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export class SoundPlugin extends ButtonPlugin {
4444
this._sfxMutedByUser = false;
4545
this._voMutedByUser = false;
4646

47-
this.soundMuteEnabled = false;
48-
this.musicMuteEnabled = false;
49-
this.sfxMuteEnabled = false;
50-
this.voMuteEnabled = false;
47+
this.soundMutedEnabled = false;
48+
this.musicMutedEnabled = false;
49+
this.sfxMutedEnabled = false;
50+
this.voMutedEnabled = false;
5151

5252
this.soundVolume = 1;
5353
this.musicVolume = 1;
@@ -504,16 +504,16 @@ export class SoundPlugin extends ButtonPlugin {
504504

505505
// to avoid the mute property overwriting the volume on startup, mutes should only send if they're true
506506
// or the volume channel isn't enabled
507-
if ( (this.soundButtonsLength > 0 && this.soundMuteEnabled) && (this.soundMuted || !this.soundVolumeEnabled )) {
507+
if ( (this.soundButtonsLength > 0 && this.soundMutedEnabled) && (this.soundMuted || !this.soundVolumeEnabled )) {
508508
this.sendProperty(SoundPlugin.soundMutedKey, this.soundMuted);
509509
}
510-
if ( (this.musicButtonsLength > 0 && this.musicMuteEnabled) && (this.musicMuted || !this.musicVolumeEnabled )) {
510+
if ( (this.musicButtonsLength > 0 && this.musicMutedEnabled) && (this.musicMuted || !this.musicVolumeEnabled )) {
511511
this.sendProperty(SoundPlugin.musicMutedKey, this.musicMuted);
512512
}
513-
if ( (this.voButtonsLength > 0 && this.voMuteEnabled) && ( this.voMuted || !this.voVolumeEnabled )) {
513+
if ( (this.voButtonsLength > 0 && this.voMutedEnabled) && ( this.voMuted || !this.voVolumeEnabled )) {
514514
this.sendProperty(SoundPlugin.voMutedKey, this.voMuted);
515515
}
516-
if ( (this.sfxButtonsLength > 0 && this.sfxMuteEnabled) && (this.sfxMuted || !this.sfxVolumeEnabled )) {
516+
if ( (this.sfxButtonsLength > 0 && this.sfxMutedEnabled) && (this.sfxMuted || !this.sfxVolumeEnabled )) {
517517
this.sendProperty(SoundPlugin.sfxMutedKey, this.sfxMuted);
518518
}
519519
}

0 commit comments

Comments
 (0)