iPod Library returning an Asset with no tracks
I am using the MediaItem api to gather assets from the iPod library. There is a strange bug I am running into after the application has been running for a while. I will run the following code and the AVURLAsset will have no associated tracks.
NSURL* url = [iPodSong valueForProperty:MPMediaItemPropertyAssetURL];
mAssetToLoad = [[AVURLAsset alloc] initWithURL:url options:nil];
bool protectedCon = mAssetToLoad.hasProtectedContent;
bool exportable = true;//mAssetToLoad.exportable; //4.3 only
if(!protectedCon && exportable) {
AVAssetTrack* songTrack = [mAssetToLoad.tracks objectAtIndex:0];
//CRASH tracks is of size 0
The asset where the problem occurs s开发者_JS百科eems to change, and if I restart the app and load same asset again, it loads correctly.
Has anyone seen this before? Any idea what I might be doing wrong?
I believe the problem is the CMSampleBufferRef weren't being released. So too many items were open from the iPod library at one time. The same behavior did happen on other devices, it just took longer on those with more RAM.
精彩评论