Status now updates

CQTexperiment
vspader 2006-01-29 14:57:48 +00:00
parent 298ddf4b38
commit f035fd1cc2
9 changed files with 70 additions and 16 deletions

View File

@ -51,7 +51,7 @@
//Methods since this is SoundController's delegate
- (void)delegateNotifyStatusUpdate:(int)status;
- (void)delegateNotifyStatusUpdate:(NSNumber *)status;
- (void)delegateNotifyPositionUpdate:(double)pos;
- (void)delegateNotifyBitrateUpdate:(float)bitrate;
- (void)delegateNotifySongChanged:(double)length;

View File

@ -84,24 +84,36 @@
- (void)playEntry:(PlaylistEntry *)pe;
{
// DBLog(@"PlayEntry: %@ Sent!", [pe filename]);
if (playbackStatus != kCogStatusStopped)
[self stop:self];
[soundController play:[pe filename]];
}
- (IBAction)next:(id)sender
{
if ([playlistController next] == nil)
NSLog(@"CALLING: %i %i", playbackStatus, kCogStatusStopped);
if ([playlistController next] == NO)
return;
[self playEntry:[playlistController currentEntry]];
if (playbackStatus != kCogStatusStopped)
{
NSLog(@"STOPPING");
[self stop:self];
[self playEntry:[playlistController currentEntry]];
}
}
- (IBAction)prev:(id)sender
{
NSLog(@"CALLING");
if ([playlistController prev] == nil)
return;
[self playEntry:[playlistController currentEntry]];
if (playbackStatus != kCogStatusStopped)
{
[self stop:self];
[self playEntry:[playlistController currentEntry]];
}
}
- (IBAction)seek:(id)sender
@ -204,8 +216,9 @@
}
- (void)delegateNotifyStatusUpdate:(int)status
- (void)delegateNotifyStatusUpdate:(NSNumber *)s
{
int status = [s intValue];
if (status == kCogStatusStopped || status == kCogStatusPaused)
{
//Show play image

View File

@ -52,8 +52,8 @@
- (id)currentEntry;
- (void)setCurrentEntry:(PlaylistEntry *)pe;
- (void)next;
- (void)prev;
- (BOOL)next;
- (BOOL)prev;
- (PlaylistEntry *)entryAtOffset:(int)offset;
- (void)addShuffledListToBack;

View File

@ -319,29 +319,33 @@
}
}
- (void)next
- (BOOL)next
{
PlaylistEntry *pe;
pe = [self entryAtOffset:1];
if (pe == nil)
return;
return NO;
[self setCurrentEntry:pe];
return YES;
}
- (void)prev
- (BOOL)prev
{
PlaylistEntry *pe;
pe = [self entryAtOffset:-1];
if (pe == nil)
return;
return NO;
if (shuffle == YES)
shuffleIndex--;
[self setCurrentEntry:pe];
return YES;
}
- (void)addShuffledListToBack

View File

@ -154,4 +154,14 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
}
}
- (void)pause
{
AudioOutputUnitStop(outputUnit);
}
- (void)resume
{
AudioOutputUnitStart(outputUnit);
}
@end

View File

@ -23,6 +23,16 @@
[output start];
}
- (void)pause
{
[output pause];
}
- (void)resume
{
[output resume];
}
- (int)readData:(void *)ptr amount:(int)amount
{
int n;

View File

@ -2,7 +2,7 @@ Need to have soundcontroller or outputnode keep a count of how much was played.
Need to integrate with UI (AppController).
Limit the number of queued elements (2 would probably be good, maybe 3).
Need to finish implementation of setVolume, seekToTime, pause, play, resume, stop, etc.
Need to finish implementation of seekToTime, pause, play, resume, stop, etc.

View File

@ -38,6 +38,7 @@
- (void)setVolume:(double)v;
- (void)setNextSong:(NSString *)s;
- (void)setPlaybackStatus:(int)s;
@end

View File

@ -7,7 +7,7 @@
//
#import "SoundController.h"
#import "Status.h"
@implementation SoundController
@ -41,22 +41,29 @@
[output launchThread];
[bufferChain launchThreads];
[self setPlaybackStatus:kCogStatusPlaying];
}
- (void)stop
{
//Set shouldoContinue to NO on allll things
[self setShouldContinue:NO];
[self setPlaybackStatus:kCogStatusStopped];
}
- (void)pause
{
[output pause];
[self setPlaybackStatus:kCogStatusPaused];
}
- (void)resume
{
[output resume];
[self setPlaybackStatus:kCogStatusPlaying];
}
- (void)seekToTime:(double)time
@ -108,8 +115,12 @@
- (void)endOfInputPlayed
{
if ([chainQueue count] <= 0)
{
//End of playlist
[self setPlaybackStatus:kCogStatusStopped];
return;
}
// NSLog(@"SWAPPING BUFFERS");
[bufferChain release];
@ -125,6 +136,11 @@
// NSLog(@"SWAPPED");
}
- (void)setPlaybackStatus:(int)s
{
[delegate performSelectorOnMainThread:@selector(delegateNotifyStatusUpdate:) withObject:[NSNumber numberWithInt:s] waitUntilDone:NO];
}
- (BufferChain *)bufferChain
{
return bufferChain;