Re: QTKit quickie
Re: QTKit quickie
- Subject: Re: QTKit quickie
- From: Matt Neuburg <email@hidden>
- Date: Wed, 06 Jul 2005 10:34:14 -0700
On Tue, 5 Jul 2005 16:31:59 -0700, Tim Monroe <email@hidden> said:
>
>On Jul 4, 2005, at 1:20 AM, Matt Neuburg wrote:
>
>> I was hoping to use the Tiger QTKit simply to play a sound. The reason for
>> introducing the overhead of QTKit into it is that this way I can also easily
>> set the volume of the sound (relative to the system volume) without bothering
>> to use any QuickTime Carbon calls. It works perfectly in about four lines of
>> code if I use a QTMovieView, which is pretty slick but also really does seem
>> like overkill. I tried just telling the QTMovie to play, *without* assigning
>> it to a QTMovieView, but nothing seemed to happen. Is this whole idea just a
>> case of barking up the wrong tree? m.
>
>Can you show us the code you are trying to use? I have some ideas, but
>I rather not speculate until I see the code.
Sure, thanks.
The goal here is very simple: to play a sound from a sound file (stored as a
resource in my app's bundle) while taking control of its volume (actually,
the user is to be able to control the volume through a preference).
I started out by using NSSound, but this, oddly, allows no control whatever
over the characteristics of the sound's playback (volume, etc.). FWIW, I
regard this as a bug in NSSound, since who wouldn't want this sort of
control?
Anyway, the alternative, up to now, has been to load the sound as an NSMovie
and "fall through" into QuickTime by way of -[NSMovie QTMovie]. Once you're
in the QuickTime world, you can do anything. So (omitting memory management
details of retention and deallocation):
NSMovie *movie;
movie = [[NSMovie alloc] initWithURL:[NSURL fileURLWithPath:s]
byReference:NO];
void* m = [movie QTMovie];
SetMovieVolume(m,whatever);
StartMovie(m);
That's fine, and I've no objection to it. But then when Tiger's QTKit came
along, I thought: so surely this will provide (if I may put it this way
non-prejudicially) a "pure Cocoa" way of doing something so simple as
playing a sound at a specified volume. So I tried to create a QTKit analogy
to the above, like this:
QTMovie* mov;
mov = [QTMovie movieWithFile:s error:nil];
[mov setVolume: whatever];
// [moviePlayer setMovie:mov];
[mov play];
It doesn't work (no sound emerges). But if I have an outlet to a QTMovieView
called "moviePlayer" and I uncomment the commented line, it works just fine.
The QTMovieView needn't be visible (or have any controller or even any
size), but still, this seems like excessive overhead just for the sake of
controlling the sound volume.
Hence, my question. Thx again for any comments - m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden