objective-c - 从相册/UIimagepickercontroller 中获取电影的创建日期
<p><p>如何获取通过 UIimagepickercontroller 获得的电影的创建日期。
我得到了以下代码,但没有关于创建日期的信息。我也尝试了文件属性,但没有运气。 </p>
<pre><code>NSURL *url = urlfromimagepicker;
NSDictionary *options = @{ AVURLAssetPreferPreciseDurationAndTimingKey : @YES };
AVURLAsset *asset = [ initWithURL:url options:options];
NSArray *metadata = ;
for ( AVMetadataItem* item in metadata ) {
NSString *key = ;
NSString *value = ;
NSLog(@"key = %@, value = %@", key, value);
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString* mediaType = ;
if(CFStringCompare((CFStringRef) mediaType,kUTTypeMovie, 0) == kCFCompareEqualTo)
{
//Dismiss the media picker view
;
//Get the URL of the chosen content, then get the data from that URL
NSURL *videoURL = ;
NSData *webData = ;
//Gets the path for the URL, to allow it to be saved to the camera roll
NSString *moviePath = [ path];
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath))
{
ALAssetsLibrary *lib = [ init];
//The key UIImagePickerControllerReferenceURL allows you to get an ALAsset, which then allows you to get metadata (such as the date the media was created)
resultBlock:^(ALAsset *asset) {
NSLog(@"created: %@", );
} failureBlock:^(NSError *error) {
NSLog(@"error: %@", error);
}];
}
}
}
</code></pre>
<p>引用这个问题:<a href="https://stackoverflow.com/questions/8474058/how-can-i-keep-track-of-media-created-chosen-by-uiimagepickercontroller" rel="noreferrer noopener nofollow">How can I keep track of media created/chosen by UIImagePickerController?</a> </p></p>
<p style="font-size: 20px;">关于objective-c - 从相册/UIimagepickercontroller 中获取电影的创建日期,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/13189783/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/13189783/
</a>
</p>
页:
[1]