Sha256: ed314f621d3b64b108e8968c8134e703da8d0c221b4563b69e03c0e3f2e31790

Contents?: true

Size: 1010 Bytes

Versions: 42

Compression:

Stored size: 1010 Bytes

Contents

#!/usr/bin/env ruby

require 'gst'

if ARGV.size != 1
  puts "Usage: #{$0} audio-file"
  exit
end

file = ARGV.first

pipeline = Gst::Pipeline.new

file_src = Gst::ElementFactory.make("filesrc")
file_src.location = file

decoder = Gst::ElementFactory.make("decodebin")

audio_convert = Gst::ElementFactory.make("audioconvert")

audio_resample = Gst::ElementFactory.make("audioresample")

audio_sink = Gst::ElementFactory.make("autoaudiosink")

pipeline.add(file_src, decoder, audio_convert, audio_resample, audio_sink)
file_src >> decoder
audio_convert >> audio_resample >> audio_sink

decoder.signal_connect("new-decoded-pad") do |element, pad|
  sink_pad = audio_convert["sink"]
  pad.link(sink_pad)
end

loop = GLib::MainLoop.new(nil, false)

bus = pipeline.bus
bus.add_watch do |bus, message|
  case message.type
  when Gst::Message::EOS
    loop.quit
  when Gst::Message::ERROR
    p message.parse
    loop.quit
  end
  true
end

pipeline.play
begin
  loop.run
rescue Interrupt
ensure
  pipeline.stop
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
gstreamer-1.2.6-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.6 sample/audio-player.rb
gstreamer-1.2.5-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.5 sample/audio-player.rb
gstreamer-1.2.4-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.4 sample/audio-player.rb
gstreamer-1.2.3-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.3 sample/audio-player.rb
gstreamer-1.2.2-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.2 sample/audio-player.rb
gstreamer-1.2.1-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.1 sample/audio-player.rb
gstreamer-1.2.0-x86-mingw32 sample/audio-player.rb
gstreamer-1.2.0 sample/audio-player.rb
gstreamer-1.1.9-x86-mingw32 sample/audio-player.rb
gstreamer-1.1.9 sample/audio-player.rb
gstreamer-1.1.8-x86-mingw32 sample/audio-player.rb
gstreamer-1.1.8 sample/audio-player.rb
gstreamer-1.1.7 sample/audio-player.rb
gstreamer-1.1.7-x86-mingw32 sample/audio-player.rb