PDA

View Full Version : QT Capture Widget




I'm a Mac
Apr 10, 2008, 03:34 PM
I created a widget based off of the QT capture widget that I found on Apple's Developer Website, but whenever I deploy the widget to dashboard, and even after I close it, my iSight thinks it's still in use, and I must restart or sleep and wake my computer. Any ideas?



kainjow
Apr 10, 2008, 03:46 PM
How does this widget work? I'm not familiar with it, could you post a link?

What you probably need to do is make sure the video stream is closed when the widget is done working. I'm not sure if the widget gets a notification when it's closing or being hidden, but if so that'd be a good place to do it.

Edit: found the link (http://developer.apple.com/samplecode/QTCaptureWidget/index.html).

Looking at the code for qtcapture.js, I see this:

if (window.widget) {
widget.onremove = remove;
widget.onhide = hide;
widget.onshow = show;
widget.onsync = sync;
}

So it looks like it's setup to automatically handle stopping the capture when the widget is hidden or removed. I'd double-check and make sure those functions are getting called.

I'm a Mac
Apr 10, 2008, 04:29 PM
So it looks like it's setup to automatically handle stopping the capture when the widget is hidden or removed. I'd double-check and make sure those functions are getting called.

I see the code there in .js file but how to I check if its being called?

I have no coding knowledge, sorry.

Also, if I have a glass button on my widget, how do I get it to move every time it's clicked?

lee1210
Apr 10, 2008, 05:29 PM
I don't know if widgets will acts like "any other javascript", but if so you should be able to put an alert("Message"); in those four functions and see if the alert shows up.

-Lee

I'm a Mac
Apr 11, 2008, 03:21 PM
Arghh... I still have to restart my computer after launching the widget. I wish I could send it to someone who actually HAS coding knowledge. :o

lee1210
Apr 11, 2008, 03:46 PM
Are you sure you're closing the widget? Even when I used the sample code, it didn't "let go" of the camera until I actually closed it. Leaving the dashboard, etc. didn't do it. i had to click the "+" on the bottom left of the dashboard, then click the "X" at the upper left of the widget.

-Lee

lazydog
Apr 11, 2008, 05:26 PM
I think you need to look at the code for QTCapturePlugin. Looks like the video input device isn't removed from the capture session. I've had a quick go at fixing it but no success yet.

b e n

I'm a Mac
Apr 11, 2008, 10:51 PM
Yes, I am actually closing the widget. But somethings weird because in the QTCapture widget files, the widgetproj file is different from the actual widget, and i had to use the widgetproj file.

lazydog
Apr 12, 2008, 04:18 AM
Well I managed to fix it so the iSight turns off when you hide the widget. I put a call to captureDelete in the stopRecording method of the plugin, and a captureInit in startRecording. It was a quick hack though.
b e n

I'm a Mac
Apr 12, 2008, 12:10 PM
Well I managed to fix it so the iSight turns off when you hide the widget. I put a call to captureDelete in the stopRecording method of the plugin, and a captureInit in startRecording. It was a quick hack though.
b e n


How do I do that?

lazydog
Apr 12, 2008, 05:27 PM
hi i'm a mac

I changed these methods in MyCaptureView.m like this:-


/* start capturing */
-(void)startCapture
{
if ([mCaptureSession isRunning] == NO)
{
[self captureInit] ;
if (([[mCaptureVideoDeviceInput device] isOpen] == YES) && ([[mCaptureAudioDeviceInput device] isOpen] == YES))
{
[mCaptureSession startRunning];
}
}

}

/* stop capturing */
-(void)stopCapture
{
if ([mCaptureSession isRunning] == YES)
{
[self captureDelete] ;
[mCaptureSession stopRunning];
}

}


Like I said, it was a quick hack just to force the input devices to be released. You might want to look through captureDelete and captureInit to see what you need for your own, better solution.

good luck!

b e n