Skip to content

Instantly share code, notes, and snippets.

@joshuaswilcox
Last active July 29, 2024 00:14
Show Gist options
  • Save joshuaswilcox/7251527 to your computer and use it in GitHub Desktop.
Save joshuaswilcox/7251527 to your computer and use it in GitHub Desktop.

Revisions

  1. joshuaswilcox revised this gist Oct 31, 2013. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions current_song
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,3 @@
    --Get current states of iTunes and Spotify
    tell application "iTunes" to set itunesState to (player state as text)
    tell application "Spotify" to set spotifyState to (player state as text)

    if application "Spotify" is running and application "iTunes" is not running then
    tell application "Spotify"
    if player state is stopped then
    @@ -20,7 +16,11 @@ if application "Spotify" is running and application "iTunes" is not running then
    end if
    end tell
    else if application "Spotify" is running and application "iTunes" is running then
    if itunesState is "paused" and spotifyState is "playing" then
    --Get current states of iTunes and Spotify
    tell application "iTunes" to set itunesState to (player state as text)
    tell application "Spotify" to set spotifyState to (player state as text)

    if (itunesState is "paused" or itunesState is "stopped") and spotifyState is "playing" then
    tell application "Spotify"
    if player state is stopped then
    set display to "No Track Playing"
    @@ -37,7 +37,7 @@ else if application "Spotify" is running and application "iTunes" is running the
    set display to state & track_artist & " - " & track_name & " - " & (round ((seconds_played / track_duration) * 100)) & "%"
    end if
    end tell
    else if itunesState is "playing" and spotifyState is "paused" then
    else if itunesState is "playing" and (spotifyState is "paused" or spotifyState is "stopped") then
    tell application "iTunes"
    if player state is stopped then
    set display to "No Track Playing"
    @@ -54,7 +54,7 @@ else if application "Spotify" is running and application "iTunes" is running the
    set display to state & track_artist & " - " & track_name & " - " & (round ((seconds_played / track_duration) * 100)) & "%"
    end if
    end tell
    else if itunesState is "paused" and spotifyState is "paused" then
    else if (itunesState is "paused" or itunesState is "stopped") and spotifyState is "paused" then
    set display to "No Track Playing"
    else
    set display to "Crazyman!!!!"
  2. joshuaswilcox created this gist Oct 31, 2013.
    81 changes: 81 additions & 0 deletions current_song
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    --Get current states of iTunes and Spotify
    tell application "iTunes" to set itunesState to (player state as text)
    tell application "Spotify" to set spotifyState to (player state as text)

    if application "Spotify" is running and application "iTunes" is not running then
    tell application "Spotify"
    if player state is stopped then
    set display to "No Track Playing"
    else
    set track_artist to artist of current track
    set track_name to name of current track
    set track_duration to duration of current track
    set seconds_played to player position
    set state to ""
    if player state is paused then
    set state to "(Paused) "
    end if

    set display to state & track_artist & " - " & track_name & " - " & (round ((seconds_played / track_duration) * 100)) & "%"
    end if
    end tell
    else if application "Spotify" is running and application "iTunes" is running then
    if itunesState is "paused" and spotifyState is "playing" then
    tell application "Spotify"
    if player state is stopped then
    set display to "No Track Playing"
    else
    set track_artist to artist of current track
    set track_name to name of current track
    set track_duration to duration of current track
    set seconds_played to player position
    set state to ""
    if player state is paused then
    set state to "(Paused) "
    end if

    set display to state & track_artist & " - " & track_name & " - " & (round ((seconds_played / track_duration) * 100)) & "%"
    end if
    end tell
    else if itunesState is "playing" and spotifyState is "paused" then
    tell application "iTunes"
    if player state is stopped then
    set display to "No Track Playing"
    else
    set track_artist to artist of current track
    set track_name to name of current track
    set track_duration to duration of current track
    set seconds_played to player position
    set state to ""
    if player state is paused then
    set state to "(Paused) "
    end if

    set display to state & track_artist & " - " & track_name & " - " & (round ((seconds_played / track_duration) * 100)) & "%"
    end if
    end tell
    else if itunesState is "paused" and spotifyState is "paused" then
    set display to "No Track Playing"
    else
    set display to "Crazyman!!!!"
    end if
    else if application "iTunes" is running and application "Spotify" is not running then
    tell application "iTunes"
    if player state is stopped then
    set display to "No Track Playing"
    else
    set track_artist to artist of current track
    set track_name to name of current track
    set track_duration to duration of current track
    set seconds_played to player position
    set state to ""
    if player state is paused then
    set state to "(Paused) "
    end if

    set display to state & track_artist & " - " & track_name & " - " & (round ((seconds_played / track_duration) * 100)) & "%"
    end if
    end tell
    else
    set display to "No music app is running"
    end if