~urbanape/ubuntuone-ios-client/2.0-13-prerelease

« back to all changes in this revision

Viewing changes to musicstreaming/view_controllers/SongViewController.m

  • Committer: Jason Foreman
  • Date: 2011-06-16 18:33:42 UTC
  • mfrom: (191.1.60 master)
  • Revision ID: jason.foreman@canonical.com-20110616183342-vl7a4804xsf0s1b5
Merging branches for v 2.0.

lp:~threeve/ubuntuone-ios-client/master
lp:~urbanape/ubuntuone-ios-client/downloader

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#import "iSubAppDelegate.h"
33
33
#import "StreamingPlayer.h"
34
34
#import "AudioStreamer.h"
35
 
#import "AsynchronousImageViewCached.h"
 
35
#import "Album.h"
36
36
#import "Song.h"
37
37
#import <QuartzCore/CoreAnimation.h>
38
38
#import <MediaPlayer/MediaPlayer.h>
106
106
        [volumeSlider addSubview:volumeView];
107
107
        [volumeView sizeToFit];
108
108
        
 
109
        loader = [[AlbumArtLoader alloc] init];
 
110
        loader.delegate = self;
 
111
        loader.imageSize = 640;
 
112
 
109
113
        [self configureInfoBox];
110
114
        
111
115
        [self updateCurrentSong];
132
136
        
133
137
        if ([StreamingPlayer sharedStreamingPlayer].isShuffle)
134
138
        {
135
 
                [shuffleButton setImage:[UIImage imageNamed:@"shuffle-highlight.png"] forState:UIControlStateNormal];
 
139
                [shuffleButton setImage:[UIImage imageNamed:@"shuffle-highlight"] forState:UIControlStateNormal];
136
140
        }
137
141
        else
138
142
        {
139
 
                [shuffleButton setImage:[UIImage imageNamed:@"05-shuffle.png"] forState:UIControlStateNormal];
 
143
                [shuffleButton setImage:[UIImage imageNamed:@"05-shuffle"] forState:UIControlStateNormal];
140
144
        }
141
145
}
142
146
 
148
152
                {
149
153
                        //transition to repeat all
150
154
                        [StreamingPlayer sharedStreamingPlayer].repeatMode = RepeatModeAll;
151
 
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-highlight.png"] forState:UIControlStateNormal];
 
155
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-highlight"] forState:UIControlStateNormal];
152
156
                        
153
157
                        break;
154
158
                }
156
160
                {
157
161
                        //transition to repeat one
158
162
                        [StreamingPlayer sharedStreamingPlayer].repeatMode = RepeatModeOne;
159
 
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-one-highlight.png"] forState:UIControlStateNormal];
 
163
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-one-highlight"] forState:UIControlStateNormal];
160
164
                        
161
165
                        break;
162
166
                }
164
168
                {
165
169
                        //transition to repeat off
166
170
                        [StreamingPlayer sharedStreamingPlayer].repeatMode = RepeatModeOff;
167
 
                        [repeatButton setImage:[UIImage imageNamed:@"03-loopback.png"] forState:UIControlStateNormal];
 
171
                        [repeatButton setImage:[UIImage imageNamed:@"03-loopback"] forState:UIControlStateNormal];
168
172
                        break;
169
173
                }
170
174
        }
232
236
- (void)viewDidUnload
233
237
{
234
238
        [super viewDidUnload];
235
 
        
 
239
 
 
240
        loader.delegate = nil;
 
241
        [loader release], loader = nil;
 
242
    
236
243
        self.songInfoBox = NULL;
237
244
        self.backButton = NULL;
238
245
        self.artistLabel = NULL;
263
270
        [super dealloc];
264
271
}
265
272
 
 
273
- (void)reloadImages
 
274
{
 
275
        return;
 
276
}
 
277
 
266
278
@end
267
279
 
268
280
@implementation SongViewController (Private)
281
293
- (void)configureInfoBox
282
294
{
283
295
        scrubberSlider.backgroundColor = [UIColor clearColor];  
284
 
        UIImage *stetchLeftTrack = [[UIImage imageNamed:@"blueTrack.png"]
 
296
        UIImage *stetchLeftTrack = [[UIImage imageNamed:@"blueTrack"]
285
297
                                                                stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
286
 
        UIImage *stetchRightTrack = [[UIImage imageNamed:@"whiteTrack.png"]
 
298
        UIImage *stetchRightTrack = [[UIImage imageNamed:@"whiteTrack"]
287
299
                                                                 stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
288
 
        [scrubberSlider setThumbImage: [UIImage imageNamed:@"whiteSlide.png"] forState:UIControlStateNormal];
 
300
        [scrubberSlider setThumbImage: [UIImage imageNamed:@"whiteSlide"] forState:UIControlStateNormal];
289
301
        [scrubberSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
290
302
        [scrubberSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
291
303
        
316
328
                }
317
329
                case RepeatModeOne:
318
330
                {
319
 
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-one-highlight.png"] forState:UIControlStateNormal];
 
331
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-one-highlight"] forState:UIControlStateNormal];
320
332
                        break;
321
333
                }
322
334
                case RepeatModeAll:
323
335
                {
324
 
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-highlight.png"] forState:UIControlStateNormal];
 
336
                        [repeatButton setImage:[UIImage imageNamed:@"loopback-highlight"] forState:UIControlStateNormal];
325
337
                        break;
326
338
                }
327
339
        }
328
340
        
329
341
        if ([StreamingPlayer sharedStreamingPlayer].isShuffle)
330
342
        {
331
 
                [shuffleButton setImage:[UIImage imageNamed:@"shuffle-highlight.png"] forState:UIControlStateNormal];
 
343
                [shuffleButton setImage:[UIImage imageNamed:@"shuffle-highlight"] forState:UIControlStateNormal];
332
344
        }
333
345
}
334
346
 
368
380
        NSURL *songURL = [[Subsonic sharedSubsonic] getStreamingURLForSongId:[StreamingPlayer sharedStreamingPlayer].currentSong.songId];
369
381
        [StreamingPlayer sharedStreamingPlayer].songUrl = songURL;
370
382
 
371
 
    [self.coverArtImageView loadImageId:[StreamingPlayer sharedStreamingPlayer].currentSong.coverArtId forSize:640];
372
 
        [StreamingPlayer sharedStreamingPlayer].currentCoverArt = self.coverArtImageView.image;
 
383
    NSString *albumCoverArtId = nil;
 
384
    
 
385
    // By default, try to reuse the album's artwork, falling back on the track's coverArtId if we really need it.
 
386
    if ([StreamingPlayer sharedStreamingPlayer].currentSong.albumEntity.coverArtId)
 
387
    {
 
388
        albumCoverArtId = [StreamingPlayer sharedStreamingPlayer].currentSong.albumEntity.coverArtId;
 
389
    }
 
390
    else
 
391
    {
 
392
        albumCoverArtId = [StreamingPlayer sharedStreamingPlayer].currentSong.coverArtId;
 
393
    }
 
394
 
 
395
    if (albumCoverArtId)
 
396
    {
 
397
        NSError *error = nil;
 
398
        coverArtImageView.image = [loader imageForArtID:albumCoverArtId error:&error];
 
399
        
 
400
        if ([error code]) {
 
401
            [loader download:albumCoverArtId];
 
402
        }
 
403
    }
 
404
 
 
405
        [StreamingPlayer sharedStreamingPlayer].currentCoverArt = coverArtImageView.image;
373
406
}
374
407
 
375
408
- (void)updatePlayPauseState