• 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
QTSoundFilePlayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

QTSoundFilePlayer


  • Subject: QTSoundFilePlayer
  • From: Michael Hanna <email@hidden>
  • Date: Mon, 27 Dec 2004 15:07:53 -0500

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: QTSoundFilePlayer
      • From: Kevin Boyce <email@hidden>
    • Re: QTSoundFilePlayer
      • From: john <email@hidden>
  • Prev by Date: RE: Re: Sysex dump problem
  • Next by Date: Re: Sysex dump problem
  • Previous by thread: RE: Re: Sysex dump problem
  • Next by thread: Re: QTSoundFilePlayer
  • Index(es):
    • Date
    • Thread