dsabecky

Now Playing for Textual (Spotify/iTunes/QuickTime/VLC)

Sep 27th, 2011
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # save as ~/Library/Application Scripts/com.codeux.irc.textual/np.scpt
  2.  
  3. on textualcmd()
  4.    
  5.     set nowPlaying to "I'm not currently playing anything."
  6.    
  7.     # Spotify
  8.     if isRunning("Spotify") then
  9.         tell application "Spotify"
  10.             if player state is playing then set nowPlaying to "Spotify: " & artist of current track & " - " & name of current track & " (" & album of current track & ")"
  11.         end tell
  12.     end if
  13.    
  14.     # iTunes
  15.     if isRunning("iTunes") then
  16.         tell application "iTunes"
  17.             if player state is playing then set nowPlaying to "iTunes: " & artist of current track & " - " & name of current track & " (" & album of current track & ")"
  18.         end tell
  19.     end if
  20.    
  21.     # QuickTime Player
  22.     if isRunning("QuickTime Player") then
  23.         tell application "QuickTime Player"
  24.             if playing of document 1 then set nowPlaying to "QuickTime: " & name of document 1
  25.         end tell
  26.     end if
  27.    
  28.     # VLC Media Player
  29.     if isRunning("VLC") then
  30.         tell application "VLC"
  31.             if playing then set nowPlaying to "VLC: " & name of first window
  32.         end tell
  33.     end if
  34.    
  35.     return nowPlaying
  36.    
  37. end textualcmd
  38.  
  39. on isRunning(mediaPlayer)
  40.     tell application "System Events"
  41.         tell application "System Events" to return exists (processes where name is mediaPlayer)
  42.     end tell
  43. end isRunning
Advertisement
Add Comment
Please, Sign In to add comment