Android audio

Monkey Targets Forums/Android/Android audio

marksibly(Posted 2011) [#1]
Hi,

Is android audio puasing correctly when user suspends up by clicking home button? This is with latest V31.

It works fine here with the 'audiotest' demo in samples, but someone said it didn't...?


therevills(Posted 2011) [#2]
Hi Mark,

I built my newest Monkey game Invaders using v31 and it does continue to play after pressing the home button.

You can download the apk here to test:
http://www.therevillsgames.com/monkey/invaders/

[Edit: Just had a thought... do we actually have to code the stuff to stop within the OnSuspend events or does Monkey automatically does this for us? ]


Canardian(Posted 2011) [#3]
I think the app should only know it's in OnSuspend mode, but do nothing else. If I make some background music player, it should be able to play sounds and draw on a transparent canvas when the user hits the Home button.


marksibly(Posted 2011) [#4]
Hi,

> I built my newest Monkey game Invaders using v31 and it does continue to play after pressing the home button.

Would you mind emailing me the source/media?

And this is on a Samsung Galaxy S?


Virtech(Posted 2011) [#5]
@therevills
I downloaded your apk, but my Galaxy S refuses to install it. Weird, I havent had problem installing any of my own apk before.

@Mark
I compiled your audiotest from the monkey samples and installed on my phone. All modes from menu (key 1-7) play. Using key 7 (loopsound) the sound stop when I hit the home key.

However I cant play my own ogg files. Do you use some custom config for your ogg files?
Is there any reason (relatetd to audio) you are setting "SetUpdateRate" low as 15?


therevills(Posted 2011) [#6]
Sent to your gmail account Mark.

Nope my Android phone is the LG Optimus One P500. Also tested on the Nexus One which also continues the sounds/game when the Home key is pressed.

@Virtech - What error did you get?


Virtech(Posted 2011) [#7]
> What error did you get?

Simply a screen telling the apk was not installed. I tryed several times.


therevills(Posted 2011) [#8]
Have you got Unknown sources ticked in Settings > Applications ?


Virtech(Posted 2011) [#9]
Yes I have 'usb-debug-mode' & 'unknown-sources' ticked.

I noted your apk dont have -debug appended to the filename. When I compile for Android (from Jungle IDE) I always get -debug in the filename. Regardless if I set release or debug. Did you just rename your apk?


therevills(Posted 2011) [#10]
Yep I renamed it. How are you installing tha apk?

When Samah installed it he used the adb.exe:

Go to here in CMD:

C:\Program Files (x86)\Android\android-sdk\platform-tools

Type:

adb install MonkeyGame.apk

(You might have to copy MonkeyGame.apk to the same folder)


Virtech(Posted 2011) [#11]
Its a very straighforward procedure.

- usb cable
- transfer the apk to a folder on the sdcard
- disconnect usb link
- on the phone: browse to the apk file
- touch the apk file to start install
- open (start) the installed apk


therevills(Posted 2011) [#12]
Can you try using the adb.exe?

Also do you have another MonkeyGame.apk installed on your phone? (If so, can you uninstall it and try again).


Virtech(Posted 2011) [#13]
I tryed using the adb method. Thanks for the tip! That was an even easyer way of installing the apk :)

And now your game works on my phone. But its strange it didnt the way I usually do it.

Do you know if the adb method also works over wifi?

About the sound. Yes I can still hear explosion sounds after I hit the HOME key. So there is definitely a difference in behaviour relative to how you install the apk on the phone.


Perturbatio(Posted 2011) [#14]
The audiotest sound stops when suspended on my HTC Desire.


Canardian(Posted 2011) [#15]
I don't see any code which stops the sounds in audiotest. It should not stop playing sounds if it's not explicitely wanted by the programmer.

Somekind of a IsSuspended() function would be enough, then the programmer can choose if he wants to stop the sounds, which is usually the case for games, or if he wants to keep the sounds playing when the user presses the home button, which is good for music players.

The Android home button is exactly the same as the Show Desktop button in Windows, it should only defocus (=IsSuspended()=true) the apps, but not do anything else.

On my Android emulator it stops the sound when I press the home button, which is bad.