0

I already refered this link

iMedia

Now i am using NSOpenPanel to open iPhoto library folder.

Here is the code which allow to open.

int i = 0;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"public.image",@"public.video",nil]];
[openDlg setAllowsMultipleSelection:TRUE];
[openDlg setAllowsOtherFileTypes:NO];

if ( [openDlg runModal] == NSOKButton )
{
    NSArray *files = [openDlg URLs];
    for( i = 0; i < [files count]; i++ )
    {
        NSLog(@"File path: %@", [[files objectAtIndex:i] path]);
    }
}

This code always open my Finder library folder, As i want to open Media Photo and Movies folder directly.

Please give me any solution.

I have attached here one screen shot.

enter image description here

Thanks & Regards,

Solid Soft
  • 1,872
  • 2
  • 25
  • 55

2 Answers2

3

You may consider adding the following code snipet:

    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSError *error = nil;
    NSURL *picturesURL = [fileManager URLForDirectory:NSPicturesDirectory inDomain:NSUserDomainMask appropriateForURL:NULL create:NO error:&error];
    NSURL *iPhotoURL = [picturesURL URLByAppendingPathComponent:@"iPhoto Library.photolibrary"];

    [openDlg setDirectoryURL:iPhotoURL];

    // Now run the dialog

This won't help if the user has moved his iPhoto library to some non-standard location.

aLevelOfIndirection
  • 3,522
  • 14
  • 18
  • Your code is working, Thanks a lot. But i can not click on Videos. Any other extra stuff required for that ? – Solid Soft Apr 05 '13 at 03:04
  • Now done dude, I have just change allowFileType to @"public.video" replace by @"public.movie" and works.. – Solid Soft Apr 05 '13 at 03:10
  • Hi jaggie_Gamer! I wanted to do a quick test with an openPanel and the answer aLevelOfIndirection replied you but I didn't have the result like you; My openPanel shows the content of the iPhoto Library package. Did you added any option on you openPanel like setCanChooseDirectories or setTreatsFilePackagesAsDirectories maybe; set both to NO. – thebenjiman Apr 29 '13 at 09:45
  • Also did you by any mean tried to extract that view (the one you have once you clicked on the Photos button) and succeeded to do so? – thebenjiman Apr 29 '13 at 09:47
  • Go to the finder, and right click on the iPhoto library. Pick "Show Package Contents" and then locate the subdirectory that you need. Append the missing part to the above URL. – aLevelOfIndirection Apr 29 '13 at 10:37
  • 1
    I'm talking about the view displayed on the right of the panel once you have clicked on Photos in media (the one that includes a IKImageBrowserView and an NSOutlineView) – thebenjiman Apr 29 '13 at 10:45
  • any updates? I don't see the focus shifting to "media->Photos", I can only see that it opens as a directory. – Arjun May 23 '18 at 14:18
0

There is a private API of Apple that contains exactly the control you want to access; this control is an ILMediaBrowserView and provides the exact same view than the one in NSOpenDialog. If you are planning an AppStore release of your app don't use it but it can be useful. The framework to integrate to your project to get that view is iLifeMediaBrowser.framework in /System/Library/PrivateFrameworks.

thebenjiman
  • 187
  • 1
  • 5
  • @thebenjiman: Do you know if you can set a standard open panel to auto-select the Photos media item so that this browser appears? – Dalmazio Aug 18 '16 at 22:41