Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
aryono_mcm
Posts: 18
Registered: ‎05-06-2013
My Device: BB Z10
Accepted Solution

play audio while backgrounded

Hello,

 

I'm developing a streaming music player app for blackberry z10,

but it becomes mute whenever user minimize the app or lock his/her phone.

How do I make the sound still plays while the app is inactive?

 

I already searched the forum and try several things with no result:

- adding NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE in my main mxml file

- adding permissions in the bar-descriptor.xml file

<permission>run_when_backgrounded</permission>
<permission>play_audio</permission>

<inactivePowerMode>throttled</inactivePowerMode>

 

sorry for my english and thanks in advance

Developer
Developer
mdd
Posts: 225
Registered: ‎01-17-2012
My Device: PB

Re: play audio while backgrounded

Normally, networking also halts when in STANDBY, so you need to request it to continue operating.

 

 I execute the following when I get deactivated:

 

QNXSystem.system.requestResource( QNXSystemResource.NETWORKING );							
QNXSystem.system.runFrameCycle();

 

Regards,

Developer
aryono_mcm
Posts: 18
Registered: ‎05-06-2013
My Device: BB Z10

Re: play audio while backgrounded

[ Edited ]

Hi mdd, thanks for your reply

 

added to my code:

 

var win:IowWindow = IowWindow.getAirWindow();
win.addEventListener(IowWindowEvent.WINDOW_STATE_CHANGED, stateChangedHandler );

function stateChangedHandler(e:*):void 
{
	switch( e.currentTarget.state ) 
	{
		case IowWindowState.NORMAL:
			trace( "app is full screen" );
			break;
		case IowWindowState.THUMBNAIL:
			QNXSystem.system.requestResource( QNXSystemResource.NETWORKING );							
			QNXSystem.system.runFrameCycle();
			trace( "app is minimized" );
			break;
		case IowWindowState.HIDDEN:
			QNXSystem.system.requestResource( QNXSystemResource.NETWORKING );							
			QNXSystem.system.runFrameCycle();
			trace( "app is hidden" );
			break;
	}
}

 

 but it gives me VerifyError: Error #1014: Class qnx.display::IowWindow could not be found.

if I set qnx-air.swc to external on library

 

and VerifyError: Error #1079: Native methods are not allowed in loaded code.

if I set qnx-air.swc to Merged into code.

 

how I fix the error?

 

thanks

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: play audio while backgrounded

I think the native methods error has to do with either the ANE are not being added to the app or select "Add platform specific libraries to library path" for the project packaging.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: play audio while backgrounded

You typically do not have to add individual BB libraries and change how they are added to the project (e.g. merge).
Developer
Developer
mdd
Posts: 225
Registered: ‎01-17-2012
My Device: PB

Re: play audio while backgrounded

This is the event I use to trigger the resource request:

			addEventListener( Event.DEACTIVATE, onDeactivate, false, 10 );			

 Regards,

Developer
aryono_mcm
Posts: 18
Registered: ‎05-06-2013
My Device: BB Z10

Re: play audio while backgrounded

yep, i have tinkered a bit with the library settings, I will reinstall the bb air sdk just to be sure :smileywink:
Developer
aryono_mcm
Posts: 18
Registered: ‎05-06-2013
My Device: BB Z10

Re: play audio while backgrounded

I got this error when try your code

 

ReferenceError: Error #1065: Variable qnx.system::QNXSystem is not defined.
at easytune_handset/deactivateHandler()[D:\YONO\htdocs\easytune_handset\src\easytune_handset.mxml:146]

 

on a post I found by searching this forum, the cause is ane's are not embedded,

i tried embed it in project->properties->flex build path

(QNXDevice.ane, QNXNetwork.ane, QNXSensors.ane, QNXSkins.ane)

but the error still there.

 

I will search some more :smileyhappy:

 

thank you

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: play audio while backgrounded

Are you auto adding the libraries?
Is your current SDK path set correctly?
Developer
aryono_mcm
Posts: 18
Registered: ‎05-06-2013
My Device: BB Z10

Re: play audio while backgrounded

I added the BB library from Project Properties->Flex Build Packaging->Blackberry->check "Add platform specific libraries to library path", is this the correct way to add BB library?

 

bb lib setting

 

 

my BB SDK path

bb sdk path