Status now updates
parent
298ddf4b38
commit
f035fd1cc2
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
|
|
||||||
//Methods since this is SoundController's delegate
|
//Methods since this is SoundController's delegate
|
||||||
- (void)delegateNotifyStatusUpdate:(int)status;
|
- (void)delegateNotifyStatusUpdate:(NSNumber *)status;
|
||||||
- (void)delegateNotifyPositionUpdate:(double)pos;
|
- (void)delegateNotifyPositionUpdate:(double)pos;
|
||||||
- (void)delegateNotifyBitrateUpdate:(float)bitrate;
|
- (void)delegateNotifyBitrateUpdate:(float)bitrate;
|
||||||
- (void)delegateNotifySongChanged:(double)length;
|
- (void)delegateNotifySongChanged:(double)length;
|
||||||
|
|
|
@ -84,24 +84,36 @@
|
||||||
- (void)playEntry:(PlaylistEntry *)pe;
|
- (void)playEntry:(PlaylistEntry *)pe;
|
||||||
{
|
{
|
||||||
// DBLog(@"PlayEntry: %@ Sent!", [pe filename]);
|
// DBLog(@"PlayEntry: %@ Sent!", [pe filename]);
|
||||||
|
if (playbackStatus != kCogStatusStopped)
|
||||||
|
[self stop:self];
|
||||||
[soundController play:[pe filename]];
|
[soundController play:[pe filename]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)next:(id)sender
|
- (IBAction)next:(id)sender
|
||||||
{
|
{
|
||||||
if ([playlistController next] == nil)
|
NSLog(@"CALLING: %i %i", playbackStatus, kCogStatusStopped);
|
||||||
|
if ([playlistController next] == NO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self playEntry:[playlistController currentEntry]];
|
if (playbackStatus != kCogStatusStopped)
|
||||||
|
{
|
||||||
|
NSLog(@"STOPPING");
|
||||||
|
[self stop:self];
|
||||||
|
[self playEntry:[playlistController currentEntry]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)prev:(id)sender
|
- (IBAction)prev:(id)sender
|
||||||
{
|
{
|
||||||
|
NSLog(@"CALLING");
|
||||||
if ([playlistController prev] == nil)
|
if ([playlistController prev] == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self playEntry:[playlistController currentEntry]];
|
if (playbackStatus != kCogStatusStopped)
|
||||||
|
{
|
||||||
|
[self stop:self];
|
||||||
|
[self playEntry:[playlistController currentEntry]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)seek:(id)sender
|
- (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)
|
if (status == kCogStatusStopped || status == kCogStatusPaused)
|
||||||
{
|
{
|
||||||
//Show play image
|
//Show play image
|
||||||
|
|
|
@ -52,8 +52,8 @@
|
||||||
- (id)currentEntry;
|
- (id)currentEntry;
|
||||||
- (void)setCurrentEntry:(PlaylistEntry *)pe;
|
- (void)setCurrentEntry:(PlaylistEntry *)pe;
|
||||||
|
|
||||||
- (void)next;
|
- (BOOL)next;
|
||||||
- (void)prev;
|
- (BOOL)prev;
|
||||||
|
|
||||||
- (PlaylistEntry *)entryAtOffset:(int)offset;
|
- (PlaylistEntry *)entryAtOffset:(int)offset;
|
||||||
- (void)addShuffledListToBack;
|
- (void)addShuffledListToBack;
|
||||||
|
|
|
@ -319,29 +319,33 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)next
|
- (BOOL)next
|
||||||
{
|
{
|
||||||
PlaylistEntry *pe;
|
PlaylistEntry *pe;
|
||||||
|
|
||||||
pe = [self entryAtOffset:1];
|
pe = [self entryAtOffset:1];
|
||||||
if (pe == nil)
|
if (pe == nil)
|
||||||
return;
|
return NO;
|
||||||
|
|
||||||
[self setCurrentEntry:pe];
|
[self setCurrentEntry:pe];
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)prev
|
- (BOOL)prev
|
||||||
{
|
{
|
||||||
PlaylistEntry *pe;
|
PlaylistEntry *pe;
|
||||||
|
|
||||||
pe = [self entryAtOffset:-1];
|
pe = [self entryAtOffset:-1];
|
||||||
if (pe == nil)
|
if (pe == nil)
|
||||||
return;
|
return NO;
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
shuffleIndex--;
|
shuffleIndex--;
|
||||||
|
|
||||||
[self setCurrentEntry:pe];
|
[self setCurrentEntry:pe];
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addShuffledListToBack
|
- (void)addShuffledListToBack
|
||||||
|
|
|
@ -154,4 +154,14 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)pause
|
||||||
|
{
|
||||||
|
AudioOutputUnitStop(outputUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)resume
|
||||||
|
{
|
||||||
|
AudioOutputUnitStart(outputUnit);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -23,6 +23,16 @@
|
||||||
[output start];
|
[output start];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)pause
|
||||||
|
{
|
||||||
|
[output pause];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)resume
|
||||||
|
{
|
||||||
|
[output resume];
|
||||||
|
}
|
||||||
|
|
||||||
- (int)readData:(void *)ptr amount:(int)amount
|
- (int)readData:(void *)ptr amount:(int)amount
|
||||||
{
|
{
|
||||||
int n;
|
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).
|
Need to integrate with UI (AppController).
|
||||||
Limit the number of queued elements (2 would probably be good, maybe 3).
|
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)setVolume:(double)v;
|
||||||
|
|
||||||
- (void)setNextSong:(NSString *)s;
|
- (void)setNextSong:(NSString *)s;
|
||||||
|
- (void)setPlaybackStatus:(int)s;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "SoundController.h"
|
#import "SoundController.h"
|
||||||
|
#import "Status.h"
|
||||||
|
|
||||||
@implementation SoundController
|
@implementation SoundController
|
||||||
|
|
||||||
|
@ -41,22 +41,29 @@
|
||||||
|
|
||||||
[output launchThread];
|
[output launchThread];
|
||||||
[bufferChain launchThreads];
|
[bufferChain launchThreads];
|
||||||
|
|
||||||
|
[self setPlaybackStatus:kCogStatusPlaying];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)stop
|
- (void)stop
|
||||||
{
|
{
|
||||||
//Set shouldoContinue to NO on allll things
|
//Set shouldoContinue to NO on allll things
|
||||||
[self setShouldContinue:NO];
|
[self setShouldContinue:NO];
|
||||||
|
[self setPlaybackStatus:kCogStatusStopped];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pause
|
- (void)pause
|
||||||
{
|
{
|
||||||
[output pause];
|
[output pause];
|
||||||
|
|
||||||
|
[self setPlaybackStatus:kCogStatusPaused];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)resume
|
- (void)resume
|
||||||
{
|
{
|
||||||
[output resume];
|
[output resume];
|
||||||
|
|
||||||
|
[self setPlaybackStatus:kCogStatusPlaying];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)seekToTime:(double)time
|
- (void)seekToTime:(double)time
|
||||||
|
@ -108,8 +115,12 @@
|
||||||
- (void)endOfInputPlayed
|
- (void)endOfInputPlayed
|
||||||
{
|
{
|
||||||
if ([chainQueue count] <= 0)
|
if ([chainQueue count] <= 0)
|
||||||
|
{
|
||||||
|
//End of playlist
|
||||||
|
[self setPlaybackStatus:kCogStatusStopped];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// NSLog(@"SWAPPING BUFFERS");
|
// NSLog(@"SWAPPING BUFFERS");
|
||||||
[bufferChain release];
|
[bufferChain release];
|
||||||
|
|
||||||
|
@ -125,6 +136,11 @@
|
||||||
// NSLog(@"SWAPPED");
|
// NSLog(@"SWAPPED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setPlaybackStatus:(int)s
|
||||||
|
{
|
||||||
|
[delegate performSelectorOnMainThread:@selector(delegateNotifyStatusUpdate:) withObject:[NSNumber numberWithInt:s] waitUntilDone:NO];
|
||||||
|
}
|
||||||
|
|
||||||
- (BufferChain *)bufferChain
|
- (BufferChain *)bufferChain
|
||||||
{
|
{
|
||||||
return bufferChain;
|
return bufferChain;
|
||||||
|
|
Loading…
Reference in New Issue