Status now updates
parent
298ddf4b38
commit
f035fd1cc2
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
- (id)currentEntry;
|
||||
- (void)setCurrentEntry:(PlaylistEntry *)pe;
|
||||
|
||||
- (void)next;
|
||||
- (void)prev;
|
||||
- (BOOL)next;
|
||||
- (BOOL)prev;
|
||||
|
||||
- (PlaylistEntry *)entryAtOffset:(int)offset;
|
||||
- (void)addShuffledListToBack;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -154,4 +154,14 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
}
|
||||
}
|
||||
|
||||
- (void)pause
|
||||
{
|
||||
AudioOutputUnitStop(outputUnit);
|
||||
}
|
||||
|
||||
- (void)resume
|
||||
{
|
||||
AudioOutputUnitStart(outputUnit);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -23,6 +23,16 @@
|
|||
[output start];
|
||||
}
|
||||
|
||||
- (void)pause
|
||||
{
|
||||
[output pause];
|
||||
}
|
||||
|
||||
- (void)resume
|
||||
{
|
||||
[output resume];
|
||||
}
|
||||
|
||||
- (int)readData:(void *)ptr amount:(int)amount
|
||||
{
|
||||
int n;
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
- (void)setVolume:(double)v;
|
||||
|
||||
- (void)setNextSong:(NSString *)s;
|
||||
- (void)setPlaybackStatus:(int)s;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue