I dont want to select again n again the same sound to play as background in my app. How can i copy sound file into my app assigned folders/files? I can play file in the method mediaPicker:didPickMediaItems: How to save that sound file?
Asked
Active
Viewed 800 times
1 Answers
1
MPMediaItem and MPMediaItemCollection both support NSCoding, so you should be able to serialize it and store it using NSKeyedArchiver, see the documentation. If obj is whatever object supporting NSCoding,
NSData*data=[NSKeyedArchiver archivedDataWithRootObject:obj];
converts it to an NSData instance. Or, you can get the persistent ID MPMediaItemPropertyPersistentID of a song by
NSNumber*persistentID=[mediaItem valueForProperty:MPMediaItemPropertyPersistentID];
and then yo ucan save the persistentID into somewhere, like NSUserDefaults.
Yuji
- 34,103
- 3
- 70
- 88