Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better playlist switching

  • Loading branch information...
commit b077e6e3a0b5f5fbee65c17b8f8f0ff303227802 1 parent c2acbce
@snarshad snarshad authored
View
2  SGCarouselProtocols.h
@@ -35,7 +35,7 @@
- (id <SGMediaPlaylist>)nextPlaylist;
@property (readwrite, retain) id <SGMediaItem> currentItem;
@property (readwrite, retain) NSString *sourceName;
-@property (nonatomic, readwrite, retain) id <SGMediaPlaylist> currentPlaylist;
+@property (nonatomic, retain) id <SGMediaPlaylist> currentPlaylist;
@property (readwrite, retain) NSArray *playlists;
@property (readwrite, retain) UIColor *splashColor;
View
2  SGIPodSource.h
@@ -21,7 +21,7 @@
- (id <SGMediaPlaylist>)nextPlaylist;
@property (readwrite, retain) id <SGMediaItem> currentItem;
@property (readwrite, retain) NSString *sourceName;
-@property (nonatomic, readwrite, retain) id <SGMediaPlaylist> currentPlaylist;
+@property (nonatomic, retain) id <SGMediaPlaylist> currentPlaylist;
@property (readwrite, retain) NSArray *playlists;
@property (readwrite, assign) id<SGSourceDelegate> delegate;
@end
View
23 SGIPodSource.m
@@ -79,10 +79,9 @@ - (void)play:(id)sender
[[MPMusicPlayerController applicationMusicPlayer] stop];
if (self.currentPlaylist == nil)
{
-// if (self.playlists.count > 0)
-// {
-// self.currentPlaylist = [self.playlists objectAtIndex:0];
-// }
+ MPMediaQuery *query = [MPMediaQuery songsQuery];
+ [[MPMusicPlayerController applicationMusicPlayer] setQueueWithQuery:query];
+
}
[[MPMusicPlayerController applicationMusicPlayer] play];
@@ -95,16 +94,19 @@ - (void)stop:(id)sender
- (void)setCurrentPlaylist:(id<SGMediaPlaylist>)playlist
{
+ [self willChangeValueForKey:@"currentPlaylist"];
if (playlist != nil)
{
-
NSString *pid = [(SGIPodPlaylist *)playlist persistentId];
MPMediaQuery *query = [MPMediaQuery songsQuery];
MPMediaPropertyPredicate *mpp = [MPMediaPropertyPredicate predicateWithValue:pid forProperty:MPMediaPlaylistPropertyPersistentID comparisonType:MPMediaPredicateComparisonEqualTo];
[query addFilterPredicate:mpp];
-
[[MPMusicPlayerController applicationMusicPlayer] setQueueWithQuery:query];
}
+ id tmp = [playlist retain];
+ [currentPlaylist release];
+ currentPlaylist = tmp;
+ [self didChangeValueForKey:@"currentPlaylist"];
}
- (void)togglePlay:(id)sender
@@ -137,12 +139,13 @@ - (void)togglePlay:(id)sender
- (void)playNextPlaylist
{
- id <SGMediaPlaylist>next = [self nextPlaylist];
- if (!next)
+ id <SGMediaPlaylist>nextPlaylist = [self nextPlaylist];
+ if (!nextPlaylist)
return;
- [delegate playlistWillChange:next.title direction:0];
- self.currentPlaylist = next;
+ [delegate playlistWillChange:nextPlaylist.title direction:0];
+ self.currentPlaylist = nextPlaylist;
+ NSLog(@"%@ vs: %@", self.currentPlaylist, nextPlaylist);
[self willChangeValueForKey:@"currentItem"];
[self play:nil];
[self didChangeValueForKey:@"currentItem"];
View
34 SongGong.xcodeproj/DummySource.h
@@ -7,7 +7,41 @@
//
#import <Foundation/Foundation.h>
+#import "SGCarouselProtocols.h"
+#import "SGIPodSource.h"
@interface DummySource : NSObject
+- (void)play:(id)sender;
+- (void)togglePlay:(id)sender;
+- (void)stop:(id)sender;
+
+- (id <SGMediaPlaylist>)previousPlaylist;
+- (id <SGMediaPlaylist>)nextPlaylist;
+@property (readwrite, retain) id <SGMediaItem> currentItem;
+@property (readwrite, retain) NSString *sourceName;
+@property (nonatomic, readwrite, retain) id <SGMediaPlaylist> currentPlaylist;
+@property (readwrite, retain) NSArray *playlists;
+@property (readwrite, assign) id<SGSourceDelegate> delegate;
+@end
+
+
+@interface SGRdioItem : SGIPodItem <SGMediaItem>
+- (void)togglePlay:(id)sender;
+@property (readonly) UIImage *thumbnail;
+@property (readwrite, retain) NSString *title;
+@property (readwrite, retain) NSString *album;
+@property (readwrite, retain) NSString *artist;
+@property (readwrite, retain) NSString *persistentId;
+@end
+
+@interface SGRdioPlaylist : SGIPodPlaylist <SGMediaPlaylist>
+- (id <SGMediaItem>)previousItem;
+- (id <SGMediaItem>)nextItem;
+- (void)playItem:(id <SGMediaItem>)item;
+@property (readwrite, retain) NSString *title;
+@property (readwrite, retain) id <SGMediaItem> currentItem;
+@property (readwrite, retain) NSArray *itemIds;
+@property (readwrite, retain) NSString *persistentId;
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.