Meadow + Anything で音楽CDを操作

Meadow に組み込みの mw32-mci-send-string 関数を使って CD ドライブを操作する anything ソースを考えてみました。

(defvar anything-c-source-cdplayer
  '((name . "CDPlayer")
    (candidates . ("play" "stop" "eject"))
    (action
     ("Do" . (lambda (cmd)
               (cond ((string= cmd "play")
                      (mw32-mci-send-string
                       "Set CDAudio Door Closed Wait")
                      ;; XXX: the above command may not return properly
                      (run-with-timer 2
                                      nil
                                      (lambda ()
                                        (mw32-mci-send-string
                                         "Play CDAudio"))))
                     ((string= cmd "stop")
                      (mw32-mci-send-string "Stop CDAudio"))
                     ((string= cmd "eject")
                      (mw32-mci-send-string
                       "Set CDAudio Door Open Wait"))))))))

eject でドライブを開き、play でドライブを(開いていれば)閉じ、演奏します。

いやぁ楽しいですね、何でもありって感じで。