Class: AlexaRuby::AudioPlayer
- Inherits:
-
Object
- Object
- AlexaRuby::AudioPlayer
- Defined in:
- lib/alexa_ruby/response/audio_player.rb
Overview
AudioPlayer class encapsulates all Alexa audio player directives
Instance Method Summary collapse
-
#clear_queue(behavior = :clear_all) ⇒ Hash
Build AudioPlayer.ClearQueue directive.
-
#play(params) ⇒ Hash
Build an AudioPlayer.Play directive.
-
#stop ⇒ Hash
Build AudioPlayer.Stop directive.
Instance Method Details
#clear_queue(behavior = :clear_all) ⇒ Hash
Build AudioPlayer.ClearQueue directive
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/alexa_ruby/response/audio_player.rb', line 34 def clear_queue(behavior = :clear_all) clear_behavior = case behavior when :clear_all 'CLEAR_ALL' when :clear_queue 'CLEAR_ENQUEUED' else 'CLEAR_ALL' end { type: 'AudioPlayer.ClearQueue', clearBehavior: clear_behavior } end |
#play(params) ⇒ Hash
Build an AudioPlayer.Play directive
14 15 16 17 18 19 20 21 |
# File 'lib/alexa_ruby/response/audio_player.rb', line 14 def play(params) @opts = params if invalid_url?(@opts[:url]) raise ArgumentError, 'Audio URL must be a valid ' \ 'SSL-enabled (HTTPS) endpoint' end play_directive end |
#stop ⇒ Hash
Build AudioPlayer.Stop directive
26 27 28 |
# File 'lib/alexa_ruby/response/audio_player.rb', line 26 def stop { type: 'AudioPlayer.Stop' } end |