Permalink
Browse files

Add ability to Pause

  • Loading branch information...
tonywok committed Mar 12, 2012
1 parent 7ae140c commit 6adc06fe096dd6cdb7ed6b227a9d6ea1b65c535a
Showing with 11 additions and 5 deletions.
  1. +1 −1 CoccoaSpotbox/SpotboxPlayer.h
  2. +7 −1 CoccoaSpotbox/SpotboxPlayer.m
  3. +3 −3 CoccoaSpotbox/ZmqDispatch.m
@@ -11,7 +11,7 @@
#import "ZmqDispatch.h"
@interface SpotboxPlayer : NSObject <SPSessionDelegate, ZmqDispatchDelegate> {
- SPPlaybackManager *playback_manager;
+ SPPlaybackManager *playback_manager;
}
@property(retain) SPPlaybackManager *playback_manager;
@@ -43,7 +43,13 @@ - (void) play_track:(NSString *)track_str {
}
- (void) pause_track {
-
+ if ([playback_manager isPlaying]) {
+ [playback_manager setIsPlaying:NO];
+ } else {
+ NSTimeInterval track_position = [playback_manager trackPosition];
+ [playback_manager seekToTrackPosition:track_position];
+ [playback_manager setIsPlaying:YES];
+ }
}
- (void) stop_track {
@@ -61,12 +61,12 @@ - (void) receiveData:(NSTimer *)timer {
NSDictionary *parsedMessage = [self parseMessage:msg];
NSString *method_name = [parsedMessage valueForKey:@"method"];
- if ([method_name isEqual:@"play"]) {
+ if ([method_name isEqualToString:@"play"]) {
NSString *track_str = [[parsedMessage valueForKey:@"args"] objectAtIndex:0];
[delegate zmqDispatchDidReceivePlay:track_str];
- } else if ([method_name isEqual:@"stop"]) {
+ } else if ([method_name isEqualToString:@"stop"]) {
[delegate zmqDispatchDidReceiveStop];
- } else if ([method_name isEqual:@"pause"]) {
+ } else if ([method_name isEqualToString:@"pause"] || [method_name isEqualToString:@"unpause"]) {
[delegate zmqDispatchDidReceivePause];
} else {
NSLog(@"Unsupported method: %@ w/ raw msg: %@", method_name, msg);

0 comments on commit 6adc06f

Please sign in to comment.