Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

I'm a Mac

macrumors 6502
Original poster
Nov 5, 2007
436
0
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

Moderator emeritus
Jun 15, 2000
7,958
7
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.

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

Code:
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

macrumors 6502
Original poster
Nov 5, 2007
436
0
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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

macrumors 6502
Original poster
Nov 5, 2007
436
0
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. :eek:
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
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

macrumors 6502
Original poster
Nov 5, 2007
436
0
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

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
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

macrumors 6502
Original poster
Nov 5, 2007
436
0
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

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
hi i'm a mac

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

Code:
/* 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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.