-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added compatibility with MacOS <10.15 along with >=10.15
- Loading branch information
Showing
4 changed files
with
146 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/resources/scripts/macos15/itunes_track_info_script.applescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
set STR_STOPPED to "STOPPED" | ||
set STR_PLAYING to "PLAYING" | ||
set STR_PAUSED to "PAUSED" | ||
|
||
set state to "" | ||
|
||
property savedTrack : missing value | ||
property savedPlayerState : missing value | ||
|
||
repeat | ||
delay 1 | ||
# If iTunes is not running, set the state to "STOPPED" and do nothing | ||
if application "Music" is not running then | ||
if state is not STR_STOPPED then | ||
set state to STR_STOPPED | ||
log state | ||
end if | ||
else | ||
# If iTunes is running, execute the logic inside a try block so that, if iTunes is closed during the execution, the script doesn't launch an exception | ||
try | ||
tell application "Music" | ||
set currentPlayerState to player state | ||
|
||
if currentPlayerState is not playing and currentPlayerState is not paused then | ||
# If there's no song playing or paused, set the state to "STOPPED" and do nothing | ||
if state is not STR_STOPPED then | ||
set state to STR_STOPPED | ||
log state | ||
end if | ||
else | ||
set currentTrack to current track | ||
|
||
# If the current song or the player status has changed, log the new track information | ||
if currentPlayerState is not savedPlayerState or currentTrack is not savedTrack then | ||
if currentPlayerState is playing then | ||
set state to STR_PLAYING | ||
else | ||
set state to STR_PAUSED | ||
end if | ||
|
||
# Write the track main information in the log | ||
log name of currentTrack & ";;" & artist of currentTrack & ";;" & album of currentTrack & ";;" & state & ";;" & player position & ";;" & duration of currentTrack & ";;" & track number of currentTrack & ";;" & track count of currentTrack | ||
end if | ||
|
||
# Update the player state and song name to detect when the track changes | ||
set savedPlayerState to currentPlayerState | ||
set savedTrack to currentTrack | ||
end if | ||
end tell | ||
on error | ||
# If iTunes is closed, set the state to "STOPPED" and do nothing | ||
if state is not STR_STOPPED then | ||
set state to STR_STOPPED | ||
log state | ||
end if | ||
end try | ||
end if | ||
end repeat |