Skip to content

Commit

Permalink
play button switches to pause correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Mar 10, 2012
1 parent ad1f583 commit 5d7f991
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Mixtape/AudioController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (void)awakeFromNib {
#pragma mark playing / pausing delegate callbacks

-(void)playbackManagerWillStartPlayingAudio:(SPPlaybackManager *)aPlaybackManager{
NSLog(@"started playing");
[_playPauseButton setImage:[UIImage imageNamed:@"pause"] forState:UIControlStateNormal];
}

// someone else is using the app
Expand Down
5 changes: 4 additions & 1 deletion Mixtape/MainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
IBOutlet UIImageView *_background;
IBOutlet UIImageView *_offlineIndicator;
IBOutlet UILabel *_offlineTextLabel;
IBOutlet UIProgressView *_offlineProgressView;

UIView *_CACanvasView;
LayoutController *_layout;
}

int _totalTracks;
}

@property (retain, nonatomic) IBOutlet UIView *canvas;
@property (retain, nonatomic) UIPopoverController *flipsidePopoverController;
Expand Down
16 changes: 15 additions & 1 deletion Mixtape/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

@interface MainViewController (private)
- (void)playlistsAreOffline;
- (void)getTrackCount;
@end

@implementation MainViewController
Expand All @@ -36,9 +37,10 @@ - (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playlistsReady:) name:@"PlaylistsSet" object:[[UIApplication sharedApplication] delegate]];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showHelp:) name:ORHelpNotification object: nil];

_offlineIndicator.hidden = YES;
_offlineTextLabel.hidden = YES;
_offlineProgressView.hidden = YES;
}

- (void)showHelp:(NSNotification*)notification {
Expand Down Expand Up @@ -68,9 +70,19 @@ - (void)playlistsReady:(id)notification {
[self.layout setupAlbumArtwork];
[self.layout transitionIntoFloorView];
[self.layout setupGestureReconition];

[[SPSession sharedSession] addObserverForKeyPath:@"offlinePlaylistsRemaining" task:^(id obj, NSDictionary *change) {
NSLog(@"progress %f", _offlineProgressView.progress);
_offlineProgressView.progress = _totalTracks / (_totalTracks - [SPSession sharedSession].offlineTracksRemaining);
}];

[NSTimer scheduledTimerWithTimeInterval:OROfflineTimerInterval target:self selector:@selector(checkPlaylistsAreOffline:) userInfo:nil repeats:YES];
}

- (void)getTrackCount {
_totalTracks = [SPSession sharedSession].offlineTracksRemaining;
}

- (void)checkPlaylistsAreOffline:(NSTimer *)timer {
_offlineIndicator.hidden = NO;
_offlineTextLabel.hidden = NO;
Expand All @@ -81,6 +93,7 @@ - (void)checkPlaylistsAreOffline:(NSTimer *)timer {
playlist.markedForOfflinePlayback = YES;
}
if ([playlist offlineStatus] != SP_PLAYLIST_OFFLINE_STATUS_YES) {
_offlineProgressView.hidden = NO;
return;
}
}
Expand All @@ -98,6 +111,7 @@ - (void)fadeOutOfflineInfo {
[UIView setAnimationDuration:1.0];
[_offlineIndicator setAlpha: 0];
[_offlineTextLabel setAlpha:0];
[_offlineProgressView setAlpha:0];
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut];
[UIView commitAnimations];
}
Expand Down
24 changes: 19 additions & 5 deletions Mixtape/en.lproj/MainViewController_iPad.xib
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIProgressView" id="803475118">
<object class="IBUIProgressView" id="850539169">
<reference key="NSNextResponder" ref="975558063"/>
<int key="NSvFlags">289</int>
<string key="NSFrame">{{908, 102}, {64, 9}}</string>
Expand Down Expand Up @@ -234,7 +234,6 @@
<string key="NSFrame">{{301, -10}, {121, 121}}</string>
<reference key="NSSuperview" ref="878246342"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:241</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
Expand Down Expand Up @@ -414,6 +413,14 @@
</object>
<int key="connectionID">51</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">_offlineProgressView</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="850539169"/>
</object>
<int key="connectionID">54</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">showInfo:</string>
Expand Down Expand Up @@ -572,7 +579,7 @@
<reference key="object" ref="975558063"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="803475118"/>
<reference ref="850539169"/>
</object>
<reference key="parent" ref="191373211"/>
<string key="objectName">Canvas View</string>
Expand Down Expand Up @@ -636,7 +643,7 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">53</int>
<reference key="object" ref="803475118"/>
<reference key="object" ref="850539169"/>
<reference key="parent" ref="975558063"/>
</object>
</object>
Expand Down Expand Up @@ -710,7 +717,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">53</int>
<int key="maxID">54</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -854,6 +861,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_background</string>
<string>_offlineIndicator</string>
<string>_offlineProgressView</string>
<string>_offlineTextLabel</string>
<string>audio</string>
<string>canvas</string>
Expand All @@ -864,6 +872,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIImageView</string>
<string>UIImageView</string>
<string>UIProgressView</string>
<string>UILabel</string>
<string>AudioController</string>
<string>UIView</string>
Expand All @@ -877,6 +886,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_background</string>
<string>_offlineIndicator</string>
<string>_offlineProgressView</string>
<string>_offlineTextLabel</string>
<string>audio</string>
<string>canvas</string>
Expand All @@ -893,6 +903,10 @@
<string key="name">_offlineIndicator</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">_offlineProgressView</string>
<string key="candidateClassName">UIProgressView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">_offlineTextLabel</string>
<string key="candidateClassName">UILabel</string>
Expand Down
Loading

0 comments on commit 5d7f991

Please sign in to comment.