Article View: comp.sys.next.programmer
Article #146Problems with Sound's didPlay: method (delegate), Sound optimization
From: Orion Edward Poplawski
Date: Wed, 04 Nov 1992 22:01
Date: Wed, 04 Nov 1992 22:01
70 lines
2705 bytes
2705 bytes
I am working on a Juke Box program and am having a couple of problems.
First, I do not always receive the didPlay: message that should be sent by
a sound when it stops playing. This causes my program to stop, and not play
the next song. This behavior is erratic, i.e. sometimes I get the message,
sometimes I don't. The more I am doing elsewhere (the more in the background
the program is) the less likely it is to get the message).
Second, I am getting a lot of drop outs when I play the songs. This may be
unavoidable as the songs are stored in compressed format on a NFS mounted
drive, but any suggestions would be appreciated.
Here is a copy of the relevant code:
// This is in -init, sets up two sound objs, and sets me as their delegates.
songPlaying = [Sound new];
[songPlaying setDelegate:self];
nextSong = [Sound new];
[nextSong setDelegate:self];
// This is called when I press the play button...
playing = YES;
// I get a song number, and then... (the matrix contains the filename)
[songPlaying readSoundfile:
[[playlistMatrix cellAt:song:0] stringValue]]; // load it
[songPlaying play]; // and play it
// I get a new song number, and prep the nextSong....
[nextSong readSoundfile:[[playlistMatrix cellAt:song:0] stringValue]];
// This code gets called by -didPlay:
- playNext
{
// Swap the sounds
swap = songPlaying;
songPlaying = nextSong;
nextSong = swap;
// This was added because when you get the didPlay message, the sound is not
// done cleaning up. This seems to work, but is a definite hack, any
// other suggestions would be appreciated
cthread_yield();
[songPlaying play]; // play the next song
// Get the next song number, and again prepare nextSong....
[nextSong readSoundfile:[[playlistMatrix cellAt:song:0] stringValue]];
return self;
}
// This should be sent by the sound object when it is done playing
- didPlay:sender;
{
if (playing == YES) [self playNext];
return self;
}
Please email responses. Will summarize to the net.
--
Orion Poplawski
Physics Dept. Paraprofessional
The Colorado College
orion@proxima.cc.colorado.edu (NeXT mail OK)
(719)389-6750
Technical Details
Message-ID:
<Bx7p5u.Gq4@csn.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!ukma!cs.widener.edu!dsinc!ub!csn!newsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!cs.widener.edu!dsinc!ub!csn!news From: orion@proxima.cc.colorado.edu (Orion Edward Poplawski) Newsgroups: comp.sys.next.programmer Subject: Problems with Sound's didPlay: method (delegate), Sound optimization Message-ID: <Bx7p5u.Gq4@csn.org> Date: 4 Nov 92 22:01:03 GMT Sender: news@csn.org (news) Reply-To: orion@proxima.cc.colorado.edu Organization: Colorado SuperNet, Inc. Lines: 70 Nntp-Posting-Host: proxima.cc.colorado.edu