|
@@ -34,8 +34,6 @@ static void * PlayerStatusObservationContext = &PlayerStatusObservationContext;
|
|
|
@property (nonatomic, copy) MKRAVPlayerURLRequsetBlcok block;
|
|
|
@property (nonatomic, assign) BOOL isSeeking;//是否快进或快退
|
|
|
@property (nonatomic, assign) NSTimeInterval seekTime;//快进或者快退的目标时间
|
|
|
-@property (nonatomic, strong) NSMutableArray *resourcePlayList;//MKRRadioResorce播放列表
|
|
|
-@property (nonatomic, assign) BOOL initByUrlPlayList;//是字符串播放列表
|
|
|
@end
|
|
|
|
|
|
@implementation MKRAVPlayer
|
|
@@ -71,7 +69,6 @@ NSURL * MKRUrlWithString(NSString *string){
|
|
|
- (id)initWithPlayList:(NSArray<NSString *> *)playList{
|
|
|
self = [self init];
|
|
|
if (self) {
|
|
|
- self.initByUrlPlayList = YES;
|
|
|
self.playList = playList;
|
|
|
}
|
|
|
return self;
|
|
@@ -88,7 +85,6 @@ NSURL * MKRUrlWithString(NSString *string){
|
|
|
- (id)initWithContentURL:(NSURL *)aUrl{
|
|
|
self = [self init];
|
|
|
if (self) {
|
|
|
- self.initByUrlPlayList = YES;
|
|
|
self.playUrl = aUrl;
|
|
|
self.playList = [NSArray arrayWithObject:aUrl];
|
|
|
}
|
|
@@ -101,24 +97,12 @@ NSURL * MKRUrlWithString(NSString *string){
|
|
|
}
|
|
|
|
|
|
- (id)initWithObjectsPlayList:(NSArray<id<MKRRadioResorce>> *)playList{
|
|
|
- NSMutableArray *urls = [NSMutableArray arrayWithArray:[self.playList valueForKey:@"songUrl"]];
|
|
|
- for (NSInteger i = 0; i<urls.count; i++) {
|
|
|
- if ([urls[i] isEqual:[NSNull null]]) {
|
|
|
- [urls replaceObjectAtIndex:i withObject:@""];
|
|
|
- }
|
|
|
- }
|
|
|
- self.resourcePlayList = [NSMutableArray arrayWithArray:playList];
|
|
|
+ NSArray *urls = [playList valueForKey:@"songUrl"];
|
|
|
return [self initWithPlayList:urls];
|
|
|
}
|
|
|
|
|
|
- (id)initWithObjectsPlayList:(NSArray<id<MKRRadioResorce>> *)playList playMode:(MKRAVPlayerPlayMode)playMode{
|
|
|
- NSMutableArray *urls = [NSMutableArray arrayWithArray:[self.playList valueForKey:@"songUrl"]];
|
|
|
- for (NSInteger i = 0; i<urls.count; i++) {
|
|
|
- if ([urls[i] isEqual:[NSNull null]]) {
|
|
|
- [urls replaceObjectAtIndex:i withObject:@""];
|
|
|
- }
|
|
|
- }
|
|
|
- self.resourcePlayList = [NSMutableArray arrayWithArray:playList];
|
|
|
+ NSArray *urls = [playList valueForKey:@"songUrl"];
|
|
|
return [self initWithPlayList:urls playMode:playMode];
|
|
|
}
|
|
|
|
|
@@ -130,16 +114,6 @@ NSURL * MKRUrlWithString(NSString *string){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)updateResourcePlayList:(NSArray<id<MKRRadioResorce>> *)playList{
|
|
|
- NSMutableArray *urls = [NSMutableArray arrayWithArray:[self.playList valueForKey:@"songUrl"]];
|
|
|
- for (NSInteger i = 0; i<urls.count; i++) {
|
|
|
- if ([urls[i] isEqual:[NSNull null]]) {
|
|
|
- [urls replaceObjectAtIndex:i withObject:@""];
|
|
|
- }
|
|
|
- }
|
|
|
- self.playList = urls;
|
|
|
-}
|
|
|
-
|
|
|
#pragma mark - 播放相关
|
|
|
|
|
|
- (void)play{
|
|
@@ -169,7 +143,6 @@ NSURL * MKRUrlWithString(NSString *string){
|
|
|
self.currentIndex = index;
|
|
|
NSString *url = [self.playList objectAtIndex:index];
|
|
|
self.playUrl = MKRUrlWithString(url);
|
|
|
- self.currentResource = self.resourcePlayList[index];
|
|
|
[self play];
|
|
|
}
|
|
|
}
|
|
@@ -421,7 +394,6 @@ NSURL * MKRUrlWithString(NSString *string){
|
|
|
}
|
|
|
[self resetPlayer];
|
|
|
self.currentIndex = nextIndex;
|
|
|
- self.currentResource = self.resourcePlayList[nextIndex];
|
|
|
self.currentStatus = nil;
|
|
|
NSString *url = [self.playList objectAtIndex:self.currentIndex];
|
|
|
self.playUrl = MKRUrlWithString(url);
|