Thread View: comp.sys.next.programmer
1 messages
1 total messages
Started by Orion Edward Poplawski
Wed, 04 Nov 1992 22:01
Problems with Sound's didPlay: method (delegate), Sound optimization
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads