Skip to content

Commit

Permalink
More documentation. STKAutoRecoveringHTTPDataSource is now default fo…
Browse files Browse the repository at this point in the history
…r HTTP
  • Loading branch information
tumtumtum committed Jan 31, 2014
1 parent b903ee5 commit 83bc40d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions ExampleApp/ExampleApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ -(void) audioPlayerViewPlayFromHTTPSelected:(AudioPlayerView*)audioPlayerView
{
NSURL* url = [NSURL URLWithString:@"http://fs.bloom.fm/oss/audiosamples/sample.mp3"];

STKAutoRecoveringHTTPDataSource* dataSource = [[STKAutoRecoveringHTTPDataSource alloc] initWithHTTPDataSource:(STKHTTPDataSource*)[STKAudioPlayer dataSourceFromURL:url]];
STKDataSource* dataSource = [STKAudioPlayer dataSourceFromURL:url];

[audioPlayer setDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
}
Expand All @@ -66,16 +66,20 @@ -(void) audioPlayerViewQueueShortFileSelected:(AudioPlayerView*)audioPlayerView
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"airplane" ofType:@"aac"];
NSURL* url = [NSURL fileURLWithPath:path];

STKDataSource* dataSource = [STKAudioPlayer dataSourceFromURL:url];

[audioPlayer queueDataSource:[STKAudioPlayer dataSourceFromURL:url] withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
[audioPlayer queueDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
}

-(void) audioPlayerViewPlayFromLocalFileSelected:(AudioPlayerView*)audioPlayerView
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4a"];
NSURL* url = [NSURL fileURLWithPath:path];

[audioPlayer setDataSource:[STKAudioPlayer dataSourceFromURL:url] withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
STKDataSource* dataSource = [STKAudioPlayer dataSourceFromURL:url];

[audioPlayer setDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
}

@end
4 changes: 4 additions & 0 deletions StreamingKit/StreamingKit/STKAudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ STKAudioPlayerOptions;
-(id) init;
-(id) initWithReadBufferSize:(int)readBufferSizeIn andOptions:(STKAudioPlayerOptions)options;

/// Creates a datasource from a given URL
/// URLs with FILE schemes will return an STKLocalFileDataSource
/// URLs with HTTP schemes will return an STKHTTPDataSource wrapped within an STKAutoRecoveringHTTPDataSource
/// URLs with unrecognised schemes will return nil
+(STKDataSource*) dataSourceFromURL:(NSURL*)url;
/// Plays an item from the given URL (all pending queued items are removed)
-(void) play:(NSString*)urlString;
Expand Down
7 changes: 4 additions & 3 deletions StreamingKit/StreamingKit/STKAudioPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This product includes software developed by Thong Nguyen ([email protected])
#import "STKAudioPlayer.h"
#import "AudioToolbox/AudioToolbox.h"
#import "STKHTTPDataSource.h"
#import "STKAutoRecoveringHTTPDataSource.h"
#import "STKLocalFileDataSource.h"
#import "STKQueueEntry.h"
#import "NSMutableArray+STKAudioPlayer.h"
Expand Down Expand Up @@ -367,15 +368,15 @@ -(void) stopSystemBackgroundTask

+(STKDataSource*) dataSourceFromURL:(NSURL*)url
{
STKDataSource* retval;
STKDataSource* retval = nil;

if ([url.scheme isEqualToString:@"file"])
{
retval = [[STKLocalFileDataSource alloc] initWithFilePath:url.path];
}
else
else if ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])
{
retval = [[STKHTTPDataSource alloc] initWithURL:url];
retval = [[STKAutoRecoveringHTTPDataSource alloc] initWithHTTPDataSource:[[STKHTTPDataSource alloc] initWithURL:url]];
}

return retval;
Expand Down

0 comments on commit 83bc40d

Please sign in to comment.