Support iTunes Media Library#116
Support iTunes Media Library#116ghfghfg23 wants to merge 3 commits intotumtumtum:masterfrom ghfghfg23:master
Conversation
|
Hi dude. Thanks for this. I'm concerned that rather than pulling out the frames from the iTunes library it's writing a temporary file which will have performance and wear consequences for iOS devices. :-\ |
|
Copying a file should not be a big problem, if you do it ahead of time. |
|
Actually, there is a big problem with this code - where it locks until the file is done copying. This is a bad approach for a buffering model. |
|
Yes, for a long time I've had the intention to make STKAudioPlayer consume a compressed audio data source so that it consumes raw header-less frames (like those coming from AVAssetReader) leaving it up to the DataSources to manually provide information that would normally be in the header. This would me the player better support non file-like sources. |
|
+1 |
|
playing from iPod library doesn't work. Even in your test project. Error 2 -> STKAudioPlayerErrorStreamParseBytesFailed @ghfghfg23 @tumtumtum |
|
ghfghfg23, Thanks for your amazing job. I am facing a small issue. I am not able to play song which has duration more than 5 minutes. It is giving errorcode 2. Small songs works fine. Any idea on this? Thanks. |
| [self unregisterForEvents]; | ||
| CFReadStreamClose(stream); | ||
| _trackData = nil; | ||
| stream = 0; |
There was a problem hiding this comment.
Add CFRelease(stream)
| // } | ||
| // | ||
| // return (AudioFileTypeID)number.intValue; | ||
| //} |
There was a problem hiding this comment.
Why keep all this commented block here? Get rid of it.
| // const uint16_t bitDepth = 16; // 16 bit/sample/channel | ||
| // const uint16_t channels = 2; // 2 channel/sample (stereo) | ||
|
|
||
| // NSDictionary *opts = [NSDictionary dictionary]; |
There was a problem hiding this comment.
Get rid of commented stuff
| // [NSNumber numberWithInt:bitDepth], AVLinearPCMBitDepthKey, | ||
| // [NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved, | ||
| // [NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey, | ||
| // [NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey, settings]; |
There was a problem hiding this comment.
Get rid of commented stuff, also misaligned
| playFromiTunesLibrary = [UIButton buttonWithType:UIButtonTypeRoundedRect]; | ||
| playFromiTunesLibrary.frame = CGRectMake(playFromLocalFileButton.frame.origin.x + playFromLocalFileButton.frame.size.width, playFromLocalFileButton.frame.origin.y, size.width * 0.7f, size.height); | ||
| [playFromiTunesLibrary addTarget:self action:@selector(playFromiTunesLibraryTouched) forControlEvents:UIControlEventTouchUpInside]; | ||
| [playFromiTunesLibrary setTitle:@"from iTunes Lib" forState:UIControlStateNormal]; |
| dispatch_semaphore_signal(sema); | ||
| }]; | ||
| STKLocalFileDataSource *localFileDataSource = [[STKLocalFileDataSource alloc] initWithFilePath:filePath]; | ||
| dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); |
There was a problem hiding this comment.
DISPATCH_TIME_FOREVER is unacceptable here
| + (NSString *)temporaryFilePath | ||
| { | ||
| NSString *filename = [NSString stringWithFormat:@"streamingkittemporaryfile.caf"]; | ||
| NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:filename]; |
There was a problem hiding this comment.
You should use URLForDirectory:inDomain:appropriateForURL:create:error: of NSFileManager as preferred method here.
|
|
||
| + (NSString *)temporaryFilePath | ||
| { | ||
| NSString *filename = [NSString stringWithFormat:@"streamingkittemporaryfile.caf"]; |
There was a problem hiding this comment.
I would use a random generated name here
| @@ -0,0 +1,41 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
I'm not sure you should have added this...
|
|
||
| #import "STKMediaLibraryFileDataSource.h" | ||
| #import <AVFoundation/AVFoundation.h> | ||
| @interface STKMediaLibraryFileDataSource() |
There was a problem hiding this comment.
I see a lot of stuff in common with STKLocalFileDataSource, why not extending STKLocalFileDataSource and overriding what you actually need to change?
Added loading audio from URL with scheme "ipod-library://"