llaske / sugarizer

Sugarizer is a web implementation of the Sugar platform to run on any device or browser
https://sugarizer.org
Apache License 2.0
197 stars 412 forks source link

Fix: defeat music stops correctly during navigation. #1556

Closed d1vyanshu-kumar closed 5 months ago

d1vyanshu-kumar commented 6 months ago

The defeat music in the Tank Operation activity persists even after returning to a previous screen. This PR resolves the issue by ensuring that the defeat music stops correctly during navigation. here is how I solve this issue: by using the if statement i.e if the game ends && the screen is also changed then the sound will pause Activity name: Tank-operation. Issue: #1553 @llaske please review this PR.

d1vyanshu-kumar commented 6 months ago

@llaske please review this PR.

d1vyanshu-kumar commented 5 months ago

@llaske please review it now i think it looks good now.

llaske commented 5 months ago

Why do you duplicate the same test condition?

image

d1vyanshu-kumar commented 5 months ago

@llaske if(this.endOfGame){ if(app.renderInto(document.getElementById("board"))){ sound.pause(); } } I use duplicate condition because here we have to stop the sound when the user navigates to the home screen so I inside the if-statment, we have to add only sound.pause(); If is it not a good approach then I try another way. but it works i test in my local device it successfully solved the issue. another way is to directly use sound.pause() inside the above statement but I think maybe it is not a good idea initially I think that for control sound I have to make a separate box so that it is more readable and further in future anyone can manipulate this if this is not a good approach then I use directly inside the previous if -statement if it is not appropriate.

Screenshot 2024-03-15 at 11 51 10 PM
llaske commented 5 months ago

Not sure to understand your explanation. Simpler is better: do not duplicate the if statement and add the pause call in the existing one.

d1vyanshu-kumar commented 5 months ago

@llaske kindly review this now i think it looks good now.

d1vyanshu-kumar commented 5 months ago

@llaske please review this pr.