Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New extension: Pause specific audio channels when game is out of focus #1444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

github-actions[bot]
Copy link
Contributor

Description

This extension gives you the ability to pause specific sound channels when the game is out of focus, either because you switch windows, open another tab in the browser, or for any other reason.

When focus is regained, the specified sound channel(s) will resume playback.

How to use the extension

Simply add a "Pause a sound channel if game isn't focused" action on an event sheet, and then specify which sound channel to pause.

Checklist

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.

What tier of review do you aim for your extension?

Community (Unreviewed)

Example file

PauseASoundChannelExample.zip

Extension file

PauseSoundNotFocus.zip

@github-actions github-actions bot added the ✨ New extension A new extension label Nov 19, 2024
@github-actions github-actions bot requested a review from a team as a code owner November 19, 2024 21:40
@D8H
Copy link
Contributor

D8H commented Nov 19, 2024

Thank you for submitting an extension.

Why did you use Javascript?
It seems that the following events do something similar.

image

@luthfialdi99
Copy link

luthfialdi99 commented Nov 19, 2024

Hi, @D8H

In exported HTML5 build, the built-in "The window is focused" conditions in GDevelop 5 currently doesn't properly detect the browser's current tab or something. I'm assuming that particular condition only works on Windows, Linux, etc. But unfortunately not on Internet browsers. Hence why I'm using JavaScript.

I'm developing a HTML5 game which I plan to publish on gd.games and one of the game's musical minigames requires hitting precise notes according to a specified offset of a song. So, I had to write it in simple JavaScript. Without this extension, the musical minigame became unplayable because when I switched to another tab, the game just pauses/stops (doesn't render?) but not the sound. As a result, upon returning to the game's tab, the game was very much late to the party and the song is already over.

I thought since currently there isn't any function within GDevelop that can pause a sound channel when a player is on a different focus on a web browser, I decided to share one.

Edit: wording

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ New extension A new extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants