2

デスクトップの背景を iTunes で現在再生中の曲のアルバム アートワークに設定するアプリケーションを作成しようとしていますが、スクリプトが Apple Music の曲のアルバム アートを読み取ることができないという問題に遭遇しました。ユーザーの音楽コレクションまたはプレイリストに追加されました。

現在、このコードを使用してアルバム アートを抽出しています。

-- get the raw bytes of the artwork into a var
tell application "iTunes" to tell artwork 1 of current track
    set srcBytes to raw data
    -- figure out the proper file extension
    if format is «class PNG » then
        set ext to ".png"
    else
        set ext to ".jpg"
    end if
end tell

-- get the filename to ~/Desktop/cover.ext
set fileName to (((path to desktop) as text) & "cover" & ext)
-- write to file
set outFile to open for access file fileName with write permission
-- truncate the file
set eof outFile to 0
-- write the image bytes to the file
write srcBytes to outFile
close access outFile

Apple Music から直接再生するときにこれが機能しない理由を知っている人はいますか?
したがって、Apple Music の曲をライブラリまたはプレイリストに追加でき、スクリプトはそのアルバム アートを読み取ることができます (曲をダウンロードする必要はありません)。曲を再生すると、スクリプトがそれを読み取らず、アプリケーションがクラッシュします。

このアプリケーションを使用できるようにしたい人なら誰でも大好きなので、どんな提案でも大歓迎です。

4

1 に答える 1

1

申し訳ありませんが、Apple Music をストリーミングしている場合、現在のトラックURL トラックです。これはtrackから継承されますが、アートワーク要素リストは iTunes のスクリプタビリティを通じて公開されないため、カバー アートは使用できません。

tell application "iTunes"
    tell current track
        if exists (every artwork) then
            tell artwork 1
                get properties
            end tell
        else
            tell me to display alert "No Cover Art found."
        end if
    end tell
end tell
于 2016-05-27T01:38:25.387 に答える