Class: OpenHAB::Core::Actions::Audio
- Inherits:
-
Object
- Object
- OpenHAB::Core::Actions::Audio
- Defined in:
- lib/openhab/core/actions/audio.rb
Overview
Class Method Summary collapse
-
.play_sound(filename, sink: nil, volume: nil) ⇒ void
Play an audio file via openHAB sound service, Audio.playSound().
-
.play_stream(url, sink: nil) ⇒ void
Play an audio stream from an URL to the given sink(s).
Class Method Details
.play_sound(filename, sink: nil, volume: nil) ⇒ void
This method returns an undefined value.
Play an audio file via openHAB sound service, Audio.playSound()
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/openhab/core/actions/audio.rb', line 24 def play_sound(filename, sink: nil, volume: nil) volume = PercentType.new(volume) unless volume.is_a?(PercentType) || volume.nil? # JRuby calls the wrong overloaded method when volume is given, but sink is nil # will call playSound(String, String, float) instead of playSound(String, String, PercentType) # and end up with argument type mismatched. So we need to give it a bit of help here. if sink playSound(sink.to_s, filename.to_s, volume) else playSound(filename.to_s, volume) end end |
.play_stream(url, sink: nil) ⇒ void
This method returns an undefined value.
Play an audio stream from an URL to the given sink(s). Set url to nil if streaming should be stopped
47 48 49 |
# File 'lib/openhab/core/actions/audio.rb', line 47 def play_stream(url, sink: nil) playStream(sink&.to_s, url) end |