Skip to first unread message

CheesyGonzales

unread,
Sep 23, 2016, 12:49:20 AM9/23/16
to MIT App Inventor Forum
Hi AI Community,

I'm working on an app in AI2 that has a bunch of sequential screens that you'll march through, similar to the way you interact with an ATM (but more fun). I'm trying to build an mp3 player into the app that's will be accessible from any of the screens with a button-press or swipe.

The way I'm currently doing it:
Each screen has a button called "Jukebox" which takes you to the mp3 player screen, on which you can select a song, play/pause, adjust the play volume, or press the "back" button. Since I want the music to play while you interact with the other screens, I have Player set to play in the background. All the functionality is great while on the mp3 player screen.

The problem:
When I navigate away from the mp3 player screen, by pressing the "back" button which returns me to the previous screen, the music continues to play in the background. (As desired, wooohooo!). However, say i want to choose a new song. Or pause this one. When I return to the mp3 player screen (with the music playing) and select a new song, it begins to play over the background music! I'm looking for a way to pass the information that a song is being played in a certain player between all of the screens and keep track of the current duration of the background track. Is there a way to make a player global through all screens?

Apologies if this question has already been answered, I struggled to find relevant info. If you'd like any clarifications, let me know.

Thanks!
CheesyGonzales

Italo

unread,
Sep 23, 2016, 1:13:37 AM9/23/16
to MIT App Inventor Forum
Have you tried to execute the block Player.Stop when another song is selected?

CheesyGonzales

unread,
Sep 23, 2016, 12:28:26 PM9/23/16
to MIT App Inventor Forum
Hey Italo,

Thanks for your response. I haven't and it may work, but it doesn't solve my fundamental issue.

To describe a bit more:
I have a single simple play/pause button the follows the following blocks:

When i stay on the mp3 player page, it works great. But here's the problem: I select and play a song (which is then stored in tinyDB), navigate away from the player screen, then back. The song plays in the background the whole time (excellent!). When I push [Play_Pause], it begins playing the same song again, on top of the 1st one. It plays rounds! This just means that in the conditional block posted here, the player (after navigating away and back again to the mp3 player) status gets confused (most likely reset).

Perhaps I'll try passing the isPlaying value as a return value between screens or through a tinyDB.

Any thoughts?

Auto Generated Inline Image 1

Italo

unread,
Sep 23, 2016, 1:25:10 PM9/23/16
to MIT App Inventor Forum
I think I'll have to create a sample project to see what is the behaviour of the player in the case you describe. I never had that problem before. Or if you are willing to upload your aia, we may be able to find a solution.
In the meantime, you may want to try Taifun's new extension Enhanced Audio Player Extension

CheesyGonzales

unread,
Sep 23, 2016, 1:43:09 PM9/23/16
to mitappinv...@googlegroups.com
Right on, thanks. I did try Taifun's extension yesterday before posting and it freaked out with a load of error messages. Would be game to try it again.

This whole app is silly, it's designed to be an embedded system controller (interfaced with arduino via bluetooth ) for operating a vending machine. Right now it's just a series of mostly unrelated screens for testing various functionalities. Attached are both the .aia and .apk. Although you won't be able to see the problem in the .apk because all the tracks are hard-coded to my SD card, you can navigate to the player page by clicking [NeXt PaGe!] then filling out the email field with a "valid" email and pressing [Done!]. (FYI, the email field just checks for an '@' and a '.']. I do understand that the layout of this test app makes me seem like a blitherling lunatic. Italo, I appreciate your support =)


Test0.aia

CheesyGonzales

unread,
Sep 25, 2016, 11:11:45 AM9/25/16
to MIT App Inventor Forum
Hey Italo,

Just tried adding the Stop button as you suggested - it shows the same behavior as all the other buttons: works perfectly when you stay on the jukebox screen, but as soon as you navigate away and return, it loses all previous info about the player that's playing in the background. (i suspect the player is reinitialized, but am not sure how to figure it out - is there a way to view source code (or even a functional specification) for any of the AI elements or blocks?

Thanks again!
CheesyG

Palm Tree(TimeOfSands)

unread,
Sep 25, 2016, 12:44:03 PM9/25/16
to MIT App Inventor Forum
Try putting a stop button on all screen!

_________
Published app in gallery and want testing, reviews and suggestions? Drop in at :
https://groups.google.com/forum/?nomobile=true#!forum/mitaiforumfinishedapps

Taifun

unread,
Oct 15, 2016, 4:44:51 PM10/15/16
to MIT App Inventor Forum
 I did try Taifun's extension yesterday before posting and it freaked out with a load of error messages.

after importing an extension, you have to restart the companion app
Taifun

CheesyGonzales

unread,
Oct 21, 2016, 12:48:06 AM10/21/16
to MIT App Inventor Forum
Hey Taifun,

Thanks for your response, I apologize for writing off your extension as a bad job =)
I'll get around to testing it out in the next week or two. Does it allow player to be controlled from multiple screens?

Thanks for all of your work making AI accessible to the world - you guys are making an amazing, accessible learning and development tool. Good work and thank you. Much appreciated.

CGonz

CheesyGonzales

unread,
Oct 21, 2016, 5:23:23 AM10/21/16
to MIT App Inventor Forum
Hi Taifun,

Appologies, this is a silly question, but figured i'd post on the off-chance you've had this issue before.
I'm passing your player extension the same SDcard link as I'm passing to the player, which can access them. But when I try to start your player, it reports an "undefined" error. It is receiving the correct file location in the format: file:///mnt/extSdCard/MUSIC/01-09-%20Leftovers.mp3, for example.

Any thoughts?

Thanks!

Taifun

unread,
Oct 21, 2016, 8:45:51 AM10/21/16
to mitappinv...@googlegroups.com
But when I try to start your player, it reports an "undefined" error. It is receiving the correct file location in the format: file:///mnt/extSdCard/MUSIC/01-09-%20Leftovers.mp3, for example.
unfortunately I can't test this, because my devices do not have external sdcards
I will add a note on my webpage, that the player extension can't access external sdcards

Taifun

CheesyGonzales

unread,
Oct 21, 2016, 11:13:32 AM10/21/16
to MIT App Inventor Forum
That's a shame, because its quite possible that my incompetence is the only culprit.
Will let you know if i figure out the problem.

In the meantime, will work on hosting my content online.

Cheers,
CG

CheesyGonzales

unread,
Oct 25, 2016, 1:56:29 AM10/25/16
to MIT App Inventor Forum
Hey Taifun,

A positive and a negative:

The good thing: I tried my app with some music hosted online and it worked fine. So I think there's a real bug in your player accessing the SD card. (perhaps that's not a good thing...)

The less good thing: Your extension has the same issue as the AI player: when you play a song in the background, navigate away from the page, then return, the app has forgotten that it's playing a song. It seems like it's impossible, then, to have a jukebox screen that can be reached from any other screen that can update the music status (playing/paused/stopped/volume/change song, etc.). Any thoughts on how to do this?

Thanks again!
CG

CheesyGonzales

unread,
Oct 25, 2016, 2:03:59 AM10/25/16
to MIT App Inventor Forum
Basically I want a global player. Is something like that possible, or is it possible to pass meta data about the background-playing player effectively so I can re-access it once I return to the jukebox screen?

Taifun

unread,
Oct 25, 2016, 10:10:10 AM10/25/16
to MIT App Inventor Forum
 It seems like it's impossible, then, to have a jukebox screen that can be reached from any other screen that can update the music status (playing/paused/stopped/volume/change song, etc.). Any thoughts on how to do this?
use only 1 screen and some vertical screen arrangements to simulate different screens, just set the arrangements to visible = true/false as needed
Taifun
Reply all
Reply to author
Forward
0 new messages