hi,

i would like to implement a widget plugin to detect iTunes current
artist and current album call back to widget. i ran my widget plugin
in dashcode without crashing. however, i deployed the widget into
dashboard, it crashed all the time. following is part of my codes,
could any one give me hints to tell me which part may cause this
problem. thank you for your help. :)

- (id) initWithWebView:(WebView*)webView
{
        self = [super init];
        iTunes = [SBApplication 
applicationWithBundleIdentifier:@"com.apple.iTunes"];
        pTunesRun = TRUE;
        previousdatabaseID = @"";
        [NSThread detachNewThreadSelector:@selector(checkiTunesStatus)
toTarget:self withObject:nil];
        return self;
}

- (void) checkiTunesStatus
{       
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        while (pTunesRun) {
                if ([iTunes isRunning]) {
                        if ([iTunes playerState] == iTunesEPlSPaused || [iTunes
playerState] == iTunesEPlSStopped) {
                                trackInfo = [NSString stringWithFormat: @"%s", 
"NOT PLAYING"];
                        } else {
                                if (!iTunes.currentTrack.artist || 
!iTunes.currentTrack.album)
                                        trackInfo = [NSString stringWithFormat: 
@"%@|NULL|NULL",
iTunes.currentTrack.name];
                                else if (!iTunes.currentTrack.artist)
                                        trackInfo = [NSString stringWithFormat: 
@"%@|%@|NULL",
iTunes.currentTrack.name, iTunes.currentTrack.album];
                                else if (!iTunes.currentTrack.album)
                                        trackInfo = [NSString stringWithFormat: 
@"%@|NULL|%@",
iTunes.currentTrack.name, iTunes.currentTrack.artist];
                                else
                                        trackInfo = [NSString stringWithFormat: 
@"%@|%@|%@",
iTunes.currentTrack.name, iTunes.currentTrack.album,
iTunes.currentTrack.artist];
                        }
                        currentdatabaseID = [NSString stringWithFormat: @"%d",
iTunes.currentTrack.databaseID];
                } else {
                        trackInfo = [NSString stringWithFormat: @"%s", "NOT 
RUNNING"];
                }
                if (autoRefresh) {
                        if (![previousdatabaseID isEqualToString: 
currentdatabaseID]) {
                                NSArray* args = [NSArray arrayWithObjects:
                                                                 trackInfo,
                                                                 nil];
                                [webScriptObject 
callWebScriptMethod:@"_updateInfo" withArguments:args];
                                previousdatabaseID = [NSString 
stringWithFormat: @"%@", currentdatabaseID];
                        }
                }
                [NSThread sleepForTimeInterval:1.0];
        }
        [pool release];
        [NSThread release];
}

best, sam
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to