Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mac OS using MediaLibrary - how to define which Photos Library is loaded?

I'm sure this is right in front of my face, but I'm a bit of a nooob...

How can I define which Photos Library is loaded vs the current method which loads the System Library?

I presume it's somewhere along the lines of here from the sample code?

    // Setup the media library to load only photos, don't include other source types.
    let options: [String : AnyObject] =
        [MLMediaLoadSourceTypesKey: MLMediaSourceType.image.rawValue as AnyObject,
         MLMediaLoadIncludeSourcesKey: [MLMediaSourcePhotosIdentifier, MLMediaSourceiPhotoIdentifier] as AnyObject]

    // Create our media library instance to get our photo.
    mediaLibrary = MLMediaLibrary(options: options)

Is it a matter of having selected MLMediaSourceiPhotoIdentifier which defaults to the System Library? If so how do you go about opening other Libraries?

Help! Thankssss

like image 508
Lance Avatar asked Apr 25 '17 11:04

Lance


1 Answers

Per the documentation of MLMediaLibrary, there is only three other options except for the standard media sources:

Non-App-Specific Media Source Identifiers:

MLMediaSourceCustomFoldersIdentifier

The media source for custom folders. Currently, the only custom folder is the folder containing audio loops from Apple.

MLMediaSourceAppDefinedFoldersIdentifier

The media source for app-defined folders. This identifies a media source created from a relative path inside the caller’s app bundle.

MLMediaSourceMoviesFolderIdentifier

The media source for the user’s Movies folder.

Based on this, I'd say it's highly likely that the functionality to create a MLMediaLibrary from an arbitrary filePath does not exist. Indeed, the API will only allow you to interface to the library that is currently being used by iPhoto, iMovie or other apps respectively.

like image 90
Oskar Avatar answered Nov 07 '22 05:11

Oskar