Getting iTunes Artwork

  1. 4 days ago

    Josh H

    May 15 Pre-Release Testers, Xojo Pro

    I've got the following code which works fine in Script Editor:

    on run
    	tell application "System Events"
    		set the process_flag to (exists process "iTunes")
    	end tell
    	if the process_flag is false then
    		ignoring application responses
    			tell application "iTunes" to launch
    		end ignoring
    	end if
    	
    	tell application "iTunes"
    		try
    			set lib_ref to first library playlist
    			set track_ref to first track of lib_ref
    			tell track_ref
    				if artworks exists then
    					set artworkData to (data of artwork 1)
    					return artworkData
    				end if
    				return null
    			end tell
    		end try
    	end tell
    	return null
    end run

    Then the code in Xojo always returns null:

    Dim xAppleScript As NSAppleScriptMBS
    Dim dError As Dictionary
    Dim xEvent As NSAppleEventDescriptorMBS
    
    xAppleScript = New NSAppleScriptMBS(AppleScriptTunesArtwork)
    Call xAppleScript.Compile()
    xEvent = xAppleScript.Execute(dError)
    
    break

    Any ideas how to get iTunes song artwork?

  2. Norman P

    May 15 Pre-Release Testers, Xojo Pro Freeport, Bahamas

    Isnt there an entitlement you need for AppleScripting other apps ?

    https://stackoverflow.com/questions/21924932/how-to-run-an-applescript-from-a-sandboxed-application-on-a-mac-os-x

  3. Josh H

    May 15 Pre-Release Testers, Xojo Pro

    Yes, I am using:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>com.apple.security.app-sandbox</key>
    <false/>
    <key>com.apple.security.personal-information.calendars</key>
    <true/>
    <key>com.apple.security.personal-information.addressbook</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.files.bookmarks.app-scope</key>
    <true/>
    <key>com.apple.security.files.bookmarks.document-scope</key>
    <true/>
    <key>com.apple.security.files.bookmarks.collection-scope</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.automation.apple-events</key>
    <true/>
    <key>com.apple.security.inherit</key>
    <true/>
    <key>com.apple.security.assets.music.read-only</key>
    <true/>
    <key>com.apple.security.scripting-targets</key>
    <dict>
    <key>com.apple.iTunes</key>
    <array>
    <string>com.apple.iTunes.library.read</string>
    <string>com.apple.iTunes.user-interface</string>
    <string>com.apple.iTunes.playback</string>
    </array>
    </dict>
    <key>com.apple.security.print</key>
    <true/>
    </dict>
    </plist>

  4. Sam R

    May 15 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    If you're running Mojave, you also need to add the new "Privacy" bullshit to your plist file. Which can be done in App Wrapper 3.9.

    If you have access to the file; you could try seeing if you can get the artwork via MDS or even reading the file's meta data.

  5. Josh H

    May 15 Pre-Release Testers, Xojo Pro

    Yeah I’ve done that too but manually. No go. Not sure what’s up. I’ve just switched to media library MBs class instead

  6. Christian S

    May 15 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    MLMediaObjectMBS ArtworkImage property may help.

or Sign Up to reply!