Bonjour,
J'aurais besoin de pouvoir transmettre à Cocoa l'illustration d'iTunes.
J'ai écrit (vite fait) un applescript pour récupérer l'illustration dans iTunes :
j'obtiens alors l'illustration sous forme de data.
J'ai créé ensuite un projet Cocoa et une méthode pour récupérer l'illustration dans Cocoa.
code Cocoa
Mais là pas moyen d'exploiter le résultat du script, j'obtiens des messages d'erreur :
Que faut-il faire pour que Cocoa accepte mes data, quelle syntaxe ?
Merci d'avance à ceux qui se pencheront sur mon problème car là je sèche.
J'aurais besoin de pouvoir transmettre à Cocoa l'illustration d'iTunes.
J'ai écrit (vite fait) un applescript pour récupérer l'illustration dans iTunes :
Bloc de code:
set theControllerSelection to selection_iTunes()
tell theControllerSelection to update_info_selection()
set theIllustration to return_illustration() of theControllerSelection
on selection_iTunes()
script
property songs_list : {}
property firstIllustrationFound : null
on return_list()
return songs_list
end return_list
on return_illustration()
return firstIllustrationFound
end return_illustration
on update_info_selection()
tell application "iTunes"
-- récupération de la liste des chansons
set iTunes_list to the selection of the browser window 1
set my songs_list to every item of iTunes_list
end tell
set iTunesArtwork to get_iTunes_illustration()
set my firstIllustrationFound to iTunesArtwork
end update_info_selection
on get_iTunes_illustration()
tell application "iTunes"
repeat with i in my songs_list
try
set itunes_artwork to artwork 1 of i
if ((format of itunes_artwork) as string) contains "PNG" or ((format of itunes_artwork) as string) contains "JPEG" then
-- une illustration a été trouvée
set illustration_data to data of itunes_artwork
exit repeat
else
set illustration_data to ""
end if
on error
set illustration_data to ""
end try
end repeat
end tell
return illustration_data
end get_iTunes_illustration
end script
end selection_iTunes
j'obtiens alors l'illustration sous forme de data.
J'ai créé ensuite un projet Cocoa et une méthode pour récupérer l'illustration dans Cocoa.
code Cocoa
Bloc de code:
- (IBAction)loadImage:(id)sender
{
illustration = [[NSImage alloc] initWithData: [script executeAndReturnError:nil]];
[viewIllustration setImage:illustration];
}
Mais là pas moyen d'exploiter le résultat du script, j'obtiens des messages d'erreur :
2004-10-08 22:22:34.483 testImage[1106] *** -[NSAppleEventDescriptor bytes]: selector not recognized
2004-10-08 22:22:34.520 testImage[1106] *** -[NSAppleEventDescriptor bytes]: selector not recognized
Que faut-il faire pour que Cocoa accepte mes data, quelle syntaxe ?
Merci d'avance à ceux qui se pencheront sur mon problème car là je sèche.