File: video-player.rb

package info (click to toggle)
ruby-gnome2 0.15.0-1.1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 7,704 kB
  • ctags: 8,558
  • sloc: ansic: 69,912; ruby: 19,511; makefile: 97; xml: 35; sql: 13
file content (34 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Video streaming via Gst::Playbin.

require 'gtk2'
require 'gst'

Gst.init

if ARGV.length != 1
    $stderr.puts "Usage: #{__FILE__} uri"
    exit 1
end

playbin = Gst::ElementFactory.make('playbin')
playbin.signal_connect('eos') do 
    puts "end of stream"; 
    Gtk.main_quit
end
playbin.signal_connect('error') do |element, source, error, debug|
    $stderr.puts "Error: #{error} (#{debug})"
    Gtk.main_quit
end
playbin.uri = ARGV.first
videosink = Gst::ElementFactory.make('xvimagesink')
playbin.video_sink = videosink

window = Gtk::Window.new
window.signal_connect('destroy') { Gtk.main_quit }
window.signal_connect('expose-event') { videosink.xwindow_id = window.window.xid  }
window.show_all

puts "Streaming #{playbin.uri}..."
playbin.play

Gtk.main