• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: QTSoundFilePlayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: QTSoundFilePlayer


  • Subject: Re: QTSoundFilePlayer
  • From: john <email@hidden>
  • Date: Mon, 27 Dec 2004 20:32:32 -0500

Hi Michael,

Just for reference perhaps, you should do an output in Xcode using NSLog() in the method being called and verify it is being called every 0.2 seconds (look at the times in each posting) - I'm sure it is correct. I suspect the control might not be updating itself as frequently as you're setting the value, so you might want to try one of the following:

- stick in a call to [mPlayerSlider setNeedsDisplay: YES]

or if that doesn't work

- [mPlayerSlider display]

I'm not certain this is your problem, but controls doesn't always update right away just because you set their value to something different.

-- John



Hello all.

I'm just learning Cocoa and Objective-c, and I'm trying to make a
simple sound player out of the QTSoundFilePlayer classes found at http://www.snoize.com/


The class uses QT to decode the file, converts it using SoundConverter and plays it via an AudioUnit.

I want to refresh the UI for the user, namely a subclass of an NSSlider
and a text-field.

so for instance:

- (IBAction)myPlayAction:(id)sender
{
	[myMainPlayer play];
	[myMediaTimeField setFloatValue:[myMainPlayer duration]];
	[sender setTitle:[NSString stringWithFormat:@"%C%C", 0x275A, 0x275A]];
	[sender setAction:@selector(myPauseAction:)];

	myPlayerTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2
target:self selector:@selector(refreshControls:) userInfo:nil
repeats:YES] retain];
	[[NSRunLoop currentRunLoop] addTimer: myPlayerTimer
forMode:NSModalPanelRunLoopMode];
	[[NSRunLoop currentRunLoop] addTimer: myPlayerTimer
forMode:NSEventTrackingRunLoopMode];
}

-(void)refreshControls:(NSTimer *)timer
{
	[myMediaTimeField setFloatValue:[myMainPlayer playbackPosition]];
	[myPlayerSlider setFloatValue:([myMainPlayer playbackPosition] /
[myMainPlayer duration])];
}



this seems to work OK, but the field doesn't refresh every 0.2
seconds(about every 1.5 seconds). Is it because I added the NSTimer to
the wrong thread(I know very little about threads)?



upon reading the class further I did this instead of the NSTimer:

I set MyDocument to be the delegate of the QTSoundFilePlayer. then I
added this code.

- (void)qtSoundFilePlayer:(QTSoundFilePlayer *)aPlayer
didPlayAudioBuffer:(AudioBuffer *)buffer
{
	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	[myMediaTimeField setFloatValue:[myMainPlayer playbackPosition]];
	[myPlayerSlider setFloatValue:([myMainPlayer playbackPosition] /
[myMainPlayer duration])];
	[pool release];
}

I added the NSAutoreleasePool code because I was getting this error
repeatedly:

2004-12-27 08:49:49.811 SimpleBufferedPlayer[2434] ***
_NSAutoreleaseNoPool(): Object 0xa815130 of class NSCFNumber
autoreleased with no pool in place - just leaking
2004-12-27 08:49:49.822 SimpleBufferedPlayer[2434] ***
_NSAutoreleaseNoPool(): Object 0xa815130 of class NSCFNumber
autoreleased with no pool in place - just leaking

the text field refreshes about the same(around 1 second, isn't the
buffer read much more often than that?), but the number in the text
field seems to report the playbackPosition to an increment around
1.5-1.8. Any idea why?


thanks for any help, and happy holidays! Michael

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >QTSoundFilePlayer (From: Michael Hanna <email@hidden>)

  • Prev by Date: Re: Sysex dump problem
  • Next by Date: Re: QTSoundFilePlayer
  • Previous by thread: QTSoundFilePlayer
  • Next by thread: Re: QTSoundFilePlayer
  • Index(es):
    • Date
    • Thread