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

Native Development

Reply
Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

issues resuming the camera

Have a few questions if anyone can help 

 

Working on resuming the camera if the device goes to sleep of if the applications active state is changed etc.., one thing i'm not sure how to do is to tell if the camera is currently opened or closed

 

onCreationCompleted: {
Application.asleep.connect(onAsleep);
Application.awake.connect(onAwake);
}
function onAsleep() {
if (camera.open() == true){ camera.close();} applicationAsleep(); } function onAwake() {
if (camera.closed() == false){ camera.open();} applicationAwake(); }

 ... tried that method & it doesn't seem to work, but when the if statement is removed it does, however it ends up restarting the camera when i dont want it to.  

 

 

& I was aslo curious on how to stop a page being pushed at a certain point in the screen (3/4, middle)

navigationPane.push(page){but stop half way};

i've looked and have not been able to find anything describing how to stop a push at a certain point

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: issues resuming the camera

Hi! This is partial solution. It won't work if user presses lock button rapidly two times in succession (awake event will not be fired but the camera will go to sleep).

 

Have you seen that thread?

 

http://supportforums.blackberry.com/t5/Native-Development/The-proper-way-to-deal-with-camera-and-dev...

 

I don't know how to get the camera handle though. Does anyone have any suggestions? Tnx.

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: issues resuming the camera

Saw that post, i've also got onFullscreen in there to combat the awake issue, its just i'm not sure on how to find out if the camera is currently opened or closed, using QML so that the camera isnt opening/closing when it shouldn't be

Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: issues resuming the camera

Reading through docs and the only thing i've been able to find on being able to tell the camera's status is 

camera_devstatus_t

 

however the way camera is built (like photobomber) I cannont use ^  

is there another way to tell if the camera is currently powered on & active in QML

 

 

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: issues resuming the camera

[ Edited ]

I've asked the cascades Camera API folks to look into providing a cascades-equivalent to the native solution.

They should just need to expose a signal for when the camera hardware wakes up from powerdown.  This would solve the rapid-shutdown-wakeup button-press problem.

 

To solve the general problem of determining whether the camera is active or not -- you should be able to track this in your application by setting a flag to true after receiving the onViewfinderStarted signal, and setting it to false if you get the onCameraResourceReleased signal.  There is still the race described in the aforementioned thread, but should be solvable with an additional signal.

Contributor
Posts: 20
Registered: ‎10-17-2012
My Device: BB10 Dev Alpha
My Carrier: Wind Mobile

Re: issues resuming the camera

In your example

 

function onAwake() {
if (camera.closed() == false){ camera.open();} applicationAwake(); }

 

what is applicationAwake() ?  is that a function you define or some internal function ?? I've been seeing it everywhere

Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: issues resuming the camera

I'm not sure what it is either, it was just in all the Examples... I eventually removed it because it only sends back an  invalid error on my slog2info, everything works fine without it so I dont believe its neccesary