I’ve added a player component at Home screen, and left the screen open while browsing on other screens so that the music keeps playing.
Is there a way to close that Home screen to stop the music while on another ‘Settings’ screen?
And is there a better way to add music to app without letting the Home screen open, while also being able to pause/stop it?
You can use this block to do that:
In my apps I prefer to switch arrangements instead of screens. This way if I want to pause/stop sound I won’t find any trouble.
Could you please elaborate on the ‘Start Value’ approach? You mean navigating back to Home screen when mute button is pressed, with a variable?
Edit: I did a mistake on the code blocks so I edited the comment to change the picture.
You have to send the value to Settings Screen that the music is mute and when you go back to Home Screen you have to send the value back so you can check it.
You can use the tinyDB to store if the music is mute, so when you come back to Home Screen you get that value and do the if test.
OK, I did a lot of experimenting with the ‘start value’ idea, and the main problem I encounter is that when I open ‘Screen 2’ for a second time, instead of navigating to the old ‘Screen 2’ I left open, it creates a whole new ‘Screen 2’.
So any values I try to change only affect the second instance of ‘Screen 2’, which means the music keeps playing.
Does the tiny DB solve that problem?
It does but Check this out first!
I see many issues done by users because they switched screens not correct.
This below is now just one of many
If you dont open/close screens correct your app will get possible runtime errors.
Possible errors: (example)
Unable to add window -- token [email protected] is not valid; is your activity running?
Iam sure you don’t want that.
Then please do it in the future and switch screens correct.
General Tips and Tricks for App Inventor/Makeroid
In both cases you have to switch screens correctly to avoid runtime errors.
I’ve actually used this method with every other screen switch, except with the home screen, in order to keep the music playing.
Could you expand on the Tiny DB proposition?
How can I manipulate values from other screens by using it?
Thanks in advance.
Create a tag in tinyDB to be the variable to check the sound status (e.g.
soundOn), and write the value yes or no there before you switch to Settings Screen. Once the tag is set with a value, you can call it from every screen you need it.
OK, I made the tag at Home Screen:
And changed the value at settings screen:
But I need an event to trigger the If argument, since the ‘screen’ is already initialized.
Btw is this what you had in mind when mentioning this approach?
I would just set the Player1.start before the if test.
That’s why I prefer to work with arrangements, because this process of checking tag in tinyDB will work if you close every screen you switch even the Home one.
unfortunately my app is pretty code heavy thats why I decided to use multiple screens to make it run smoother.
So, try to close every screen you switch and to continue the audio that was playing in screen 1, store the audio position in tinyDB before you switch screens and use the block
seek to in the audio player in the new Screen (you will need one player component in each screen).
Edit: Close even Home Screen
Sorry if I can’t help you showing blocks right now, I won’t be able to use my computer until next Monday.
OK, thanks for your help,I guess I’ll give it a few more tries with the old approach, and if none succeeds I’ll go with that way.
Would having the ability to Play/Pause the music via a Notification be helpful?
If so check out my MediaStyleNotification Extension here:
MediaStyleNotification Extension v1 allows you to use Play and Pause actions from a Notification including from the Lock Screen is now available for purchase. This Extension was Developed By Ken Nichols with Help from Andres Cotes, Thank You...
Reading time: 4 mins 🕑
Likes: 52 ❤
Unfortunately it doesn’t suit my app UI, but thanks for suggesting.
PLEASE don’t tell me tht you have more than