-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswinsian-apple-script.scpt
39 lines (35 loc) · 1.11 KB
/
swinsian-apple-script.scpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
on psm(state)
if state is «constant ****kPSP» then
set ps to "playing"
else if state is «constant ****kPSp» then
set ps to "paused"
else if state is «constant ****kPSS» then
set ps to "stopped"
else
set ps to "unknown"
end if
return ps
end psm
if is_running("Swinsian") then
set output to "denis"
tell application "Swinsian"
set wab to my psm(player state)
if wab = "stopped" then
set output to "{}"
return output
end if
set pos to player position
set sfileformat to kind of current track
set strackname to name of current track
set strackartist to artist of current track
set strackalbum to album of current track
set drr to duration of current track
set sws to "{\"format\": \"" & sfileformat & "\",\"state\": \"" & wab & "\",\"song\": \"" & strackname & "\",\"artist\": \"" & strackartist & "\",\"album\": \"" & strackalbum & "\",\"pos\": \"" & pos & "\",\"dur\": \"" & drr & "\"}"
end tell
set output to "{ \"swinsian\": " & sws & "}"
else
set output to "{}"
end if