neekeetab / CachingPlayerItem

Play and cache media content simultaneously on your iOS device
MIT License
520 stars 89 forks source link

Respond data issue #1

Closed AF-cgi closed 6 years ago

AF-cgi commented 7 years ago

Hey,

I use your cachingPlayerItem and adopt it to Swift 3. Now my app crash by the follow code lines:

let range = NSRange(location: startOffset, length: bytesToRespond)
dataRequest.respond(with: (songData! as NSData).subdata(with: range))

The respond(with:)-method crashed. The reason isn't the optional. Here the crash report:

0x000000018d44beb0 _platform_memmove + 176
0x000000018edb43e8 -[_NSInlineData initWithBytes:length:] + 52
0x000000018edb42e0 -[_NSPlaceholderData initWithBytes:length:copy:deallocator:] + 96
0x000000018ee0b0e8 -[NSData(NSData) subdataWithRange:] + 280
0x00000001019147cc 0x1018d4000 + 264140
0x0000000101914834 0x1018d4000 + 264244
0x00000001001774d4 function signature specialization <Arg[0] = Owned To Guaranteed> of Tagesschau.CachingPlayerItem.ResourceLoaderDelegate.respondWithDataForRequest (__ObjC.AVAssetResourceLoadingDataRequest) -> Swift.Bool (CachingPlayerItem.swift:176)
0x0000000100172c30 Tagesschau.CachingPlayerItem.ResourceLoaderDelegate.processPendingRequests () -> () (CachingPlayerItem.swift:0)
0x00000001001778cc function signature specialization <Arg[0] = Dead, Arg[1] = Owned To Guaranteed> of Tagesschau.CachingPlayerItem.ResourceLoaderDelegate.resourceLoader (__ObjC.AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource : __ObjC.AVAssetResourceLoadingRequest) -> Swift.Bool (CachingPlayerItem.swift:79)
0x0000000100172130 @objc Tagesschau.CachingPlayerItem.ResourceLoaderDelegate.resourceLoader (__ObjC.AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource : __ObjC.AVAssetResourceLoadingRequest) -> Swift.Bool (CachingPlayerItem.swift:0)
neekeetab commented 7 years ago

Hi! I'll probably migrate the project to Swift 3 by myself. It will take a couple of days. For now, i can't tell how to fix it.

If you find a solution, please share it