Permalink
Browse files

+ iTunes dialog revamped

  • Loading branch information...
floere committed Jun 28, 2011
1 parent 28e0dc5 commit 5ac8c7fa5bed479664173fbaa304e820ec217eb4
Showing with 11 additions and 12 deletions.
  1. +11 −12 examples/itunes_dialog.rb
View
@@ -8,27 +8,26 @@
#
# This is a very simple James example.
#
-# It has only one state, :time, and a single
-# entry/hook phrase, "What time is it?"
-#
-# How could you enhance it to answer "What date is it?" ?
-#
James.dialog do
- hear 'Open iTunes and play' => :itunes
+ hear "How about some music?" => :itunes
state :itunes do
+ hear 'Previous track' => ->() do
+ `osascript -e 'tell application "iTunes"' -e "previous track" -e "end tell"`
+ "Going to previous track, Sir."
+ end
hear 'Next track' => ->() do
`osascript -e 'tell application "iTunes"' -e "next track" -e "end tell"`
- "Playing next track, Sir."
+ "Going to next track, Sir."
end
- hear 'Previous track' => ->() do
- `osascript -e 'tell application "iTunes"' -e "previous track" -e "end tell"`
- "Playing previous track, Sir."
+ hear 'Stop track' => ->() do
+ `osascript -e 'tell application "iTunes" to stop'`
+ "Stopping current track, Sir."
end
- into do
+ hear 'Play track' => ->() do
`osascript -e 'tell application "iTunes" to play'`
- "Opening i Tunes, Sir."
+ "Playing current track, Sir."
end
end

0 comments on commit 5ac8c7f

Please sign in to comment.