Can I make YouTube appear on the public sheet of my OS X app?

According to Apple documentation , YouTube is not included in the available sharing services, and indeed, when I look at the extensions of the general menus in the system settings, I do not see it there.

Presenting the listing for sharing in my own application using NSSharingServicePicker, as shown below, also does not include YouTube.

NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:@[movieFileURL]];
[sharingServicePicker showRelativeToRect:myView.bounds ofView:myView preferredEdge:NSMinYEdge];

However, when using a share in QuickTime Player or iMovie, YouTube is an option, as shown below. Is there a way to get YouTube to appear as an option in my application, or did Apple just add YouTube to these applications without adding it to the general list of the operating system?

YouTube sharing in quicktime playerYouTube sharing in iMovie

+4
1

, YouTube , QuickTime Player iMovie . (, API Google Objective C), , YouTube, ( , a NSSharingService YouTubeSharingService):

- (void)addSharingMenuItemsToMenu:(NSMenu *)menu {
    // Get the sharing services for the file.
    NSMutableArray *services = [[NSSharingService sharingServicesForItems:@[self.fileURL]] mutableCopy];
    [services addObject:[YouTubeSharingService new]];

    // Create menu items for the sharing services.
    for (NSSharingService *service in services) {
        NSMenuItem *menuItem = [[NSMenuItem alloc] init];
        menuItem.title = service.menuItemTitle;
        menuItem.image = service.image;
        menuItem.representedObject = service;
        menuItem.target = self;
        menuItem.action = @selector(executeSharingService:);
        [menu addItem:menuItem];
    }
}

- (void)executeSharingService:(id)sender {
    if ([sender isKindOfClass:[NSMenuItem class]]) {
        NSMenuItem *menuItem = sender;
        if ([menuItem.representedObject isKindOfClass:[NSSharingService class]]) {
            NSSharingService *sharingService = menuItem.representedObject;
            [sharingService performWithItems:@[self.fileURL]];
        }
    }
}
+4

All Articles