Class: Audio
- Inherits:
-
Object
- Object
- Audio
- Defined in:
- lib/kita/audio.rb
Overview
Initialise Gstreamer for sounds
Instance Method Summary collapse
-
#initialize ⇒ Audio
constructor
A new instance of Audio.
- #play(uri) ⇒ Object
- #repeat ⇒ Object
- #setup_gst ⇒ Object
Constructor Details
#initialize ⇒ Audio
Returns a new instance of Audio.
7 8 9 |
# File 'lib/kita/audio.rb', line 7 def initialize setup_gst end |
Instance Method Details
#play(uri) ⇒ Object
23 24 25 26 27 |
# File 'lib/kita/audio.rb', line 23 def play(uri) @playbin.stop @playbin.uri = Gst.filename_to_uri("#{RootPath}/sounds/#{uri}.ogg") @playbin.play end |
#repeat ⇒ Object
29 30 31 32 |
# File 'lib/kita/audio.rb', line 29 def repeat @playbin.stop @playbin.play end |
#setup_gst ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kita/audio.rb', line 11 def setup_gst Gst.init @playbin = Gst::ElementFactory.make('playbin3') @playbin.bus.add_watch do |_bus, | case .type when Gst::MessageType::EOS @playbin.stop end end end |