Get GPS location from MLMediaObject on OS X

早过忘川 提交于 2019-12-08 12:44:06

问题


I'm getting started with the Media Library Framework on OS X, specifically with regard to accessing a user's Photos library. After a lot of wrangling I was able to get access to each photo as a MLMediaObject, but now I've hit a roadblock:

How can I access the GPS location of the photo, from the MLMediaObject?

This sort of information is easy to get from the old ALAssetsLibrary system, or from the Photos Framework on iOS, using a CLLocation property associated with the media object, but I can't seem to figure it out with the Media Library Framework. The documentation lists these as the only properties of the MLMediaObject:

attributes
mediaType
contentType
name
URL
originalURL
fileSize
modificationDate
thumbnailURL
artworkImage

At first I thought attributes looked promising, but as far as I can tell there are a very small number of options for that property, and none of them are related to the location.

Then I thought, if I have the file's URL, I ought to be able to get the GPS info directly from the file, but that is proving much more difficult than I expected.

Is there an established means of getting the CLLocation, or other form of GPS data, from a photo using the MLMediaObject? Or if not, can anyone think of a more roundabout way of getting access to that information, starting from an MLMediaObject?


回答1:


In my case I have keys latitude and longitude in attributes. So I assume that it's GPS location of the photo.



来源:https://stackoverflow.com/questions/34932712/get-gps-location-from-mlmediaobject-on-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!