AVAssetResourceLoader icon indicating copy to clipboard operation
AVAssetResourceLoader copied to clipboard

Stream from Parse

Open lorencogonzaga opened this issue 10 years ago • 1 comments

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

lorencogonzaga avatar Feb 21 '15 20:02 lorencogonzaga

Hi!

Yes it can be configured to stream and cache audio from any cloud service. You should apply changes in LSFilePlayerResourceLoader.

  1. 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;
  1. 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.
  2. 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/

everappz avatar Feb 21 '15 23:02 everappz