AVAssetResourceLoader
AVAssetResourceLoader copied to clipboard
Stream from Parse
Hi there.
Congrats to the project, very nice!
Can it be configured to load audio from Parse.com ?
What and where in the code to start the changes ?
Thnx and cheerz
Hi!
Yes it can be configured to stream and cache audio from any cloud service. You should apply changes in LSFilePlayerResourceLoader.
- Change init method, instead of:
-(instancetype)initWithResourceURL:(NSURL *)url session:(YDSession *)session;
it should be something like this:
-(instancetype)initWithResourceURL:(NSURL *)url cloudService:(MYCloudService *)cloudService;
- In your cloud service API two methods should be implemented: -get info for item at path - this method available by default in cloud service API; -get partial data for file at path. In my case I just changed downloadItemAtPath method by adding additional parameter and changing callback.
- In LSFilePlayerResourceLoader.m change this lines with methods you implemented in step 2.
143. id<YDSessionRequest> req = [weakSelf.session partialContentForFileAtPath:weakSelf.path withParams:params response:nil data:^(UInt64 recDataLength, UInt64 totDataLength, NSData *recData)
163. self.contentInfoOperation = [self.session fetchStatusForPath:self.path completion:^(NSError *err, YDItemStat *item)
The full tutorial about how audio streaming was implemented in this sample project is available here: http://leshkoapps.com/wordpress/audio-streaming-and-caching-in-ios-using-avassetresourceloader-and-avplayer/