Sto provando a creare una nuova playlist utente utilizzando il bridge di scripting del cacao, ma non riesco a farlo funzionare. Ho finora:crea playlist iTunes con bridge di scripting
iTunesApplication *iTunes = [SBApplication
applicationWithBundleIdentifier:@"com.apple.iTunes"];
SBElementArray *iSources = [iTunes sources];
iTunesSource *library = nil;
for (iTunesSource *source in iSources) {
if ([[source name] isEqualToString:@"Library"]) {
library = source;
break;
}
}
// could not find the itunes library
if (!library) {
NSLog(@"Could not connect to the iTunes library");
return;
}
// now look for our playlist
NSString *playlistName = @"new playlist";
SBElementArray *playlists = [library userPlaylists];
iTunesUserPlaylist *playlist = nil;
for (iTunesUserPlaylist *thisList in playlists) {
if ([[thisList name] isEqualToString:playlistName]) {
playlist = thisList;
break;
}
}
// if the playlist was not found, create it
if (!playlist) {
playlist = [[[iTunes classForScriptingClass:@"playlist"] alloc] init];
[playlist setName:playlistName];
[[library userPlaylists] insertObject:playlist atIndex:0];
}
Quando provo e aggiungi un nome per la playlist, ottengo il messaggio di errore:
iTunesBridge [630: 80F] *** - [SBProxyByClass setName:] : l'oggetto non è stato ancora aggiunto a un contenitore; selettore non riconosciuto
Qualcuno può indicarmi la direzione corretta?
'[nome sorgente] isEqualToString: @" Libreria "]' l'hai testato in sistemi non inglesi? Sembra fragile ... – Kornel
In sistemi non inglesi, dovresti usare '([tipo di fonte] == iTunesESrcLibrary)' – fabian789