# Display iTunes Cover & Currently Playing Track

**URL:** <https://community.folivora.ai/t/display-itunes-cover-currently-playing-track/1005>\
**Category:** Setup/Preset Sharing\
**Tags:** touch-bar\
**Created:** [May 18, 2018, 1:49pm UTC](https://community.folivora.ai/t/display-itunes-cover-currently-playing-track/1005 "2018-05-18T13:49:41Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![liamb](https://community.folivora.ai/user_avatar/community.folivora.ai/liamb/32/211_2.png) [@liamb](https://community.folivora.ai/u/liamb)\
**Post date:** [June 26, 2018, 4:00am UTC](https://community.folivora.ai/t/display-itunes-cover-currently-playing-track/1005/22 "2018-06-26T04:00:15Z")

</div>

@GoldenChaos I haven't faced issues with Spotify, although it for some reason has converted Spotify to Spotify (Old) in my script? Then again the Spotify app has changed to Spotify (Old) for me too. Not sure what's happened. I rarely use Spotify though so hard to comment on.

I did come across an issue with iTunes if you use Apple Music. As the artwork is streamed it creates some issues searching for it. I was able to fix by checking if an artwork is available first though. Full iTunes code can be seen here:

> ```
> if application "iTunes" is running then
> tell application "iTunes" to tell current track
> if exists (every artwork) then
> tell artwork 1
> 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
> set fileName to ((((path to application support folder from user domain) as text) & "BetterTouchTool:" as text) & "itunes_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
> else
> set fileName to ((((path to application support folder from user domain) as text) & "BetterTouchTool:" as text) & "itunes.png")
> end if
> end tell
> set maxSize to 25
> tell application "iTunes"
> set playState to (player state as text)
> if playState is equal to "playing" then
> set trackName to name of current track
> set artistName to artist of current track
> set albumName to album of current track
> if length of trackName is greater than maxSize then
> set trackName to text 1 thru (maxSize - 3) of trackName & "..."
> end if
> if length of artistName is greater than maxSize then
> set artistName to text 1 thru (maxSize - 3) of artistName & "..."
> end if
> set trackInfo to trackName & " | " & artistName
> else
> set trackInfo to ""
> end if
> return "{\"text\":\"" & trackInfo & "\", \"icon_path\":\"" & (POSIX path of fileName as text) & "\"}"
> end tell
> end if
> 
> ```

---

_[View the full topic](https://community.folivora.ai/t/display-itunes-cover-currently-playing-track/1005)._
