File: plaympeg.rb

package info (click to toggle)
libsdl-ruby 0.7-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 408 kB
  • ctags: 360
  • sloc: ansic: 2,714; ruby: 781; makefile: 120
file content (41 lines) | stat: -rw-r--r-- 641 bytes parent folder | download
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
35
36
37
38
39
40
41
require 'sdl'

SDL.init( SDL::INIT_VIDEO|SDL::INIT_AUDIO )

screen = SDL.setVideoMode( 320, 240, 16, SDL::SWSURFACE )

mpeg = SDL::MPEG.load( 'sample.mpg' )
info = mpeg.info

p(info)

mpeg.enableAudio true
mpeg.enableVideo true

mpeg.setDisplay(screen)
mpeg.setDisplayRegion( 0, 0, screen.w, screen.h )

mpeg.play

loop do

  case event = SDL::Event2.poll
  when SDL::Event2::Quit
    mpeg.stop
    exit
  when SDL::Event2::KeyDown
    case event.sym
    when SDL::Key::S
      mpeg.stop
    when SDL::Key::P
      mpeg.play
    when SDL::Key::R
      mpeg.rewind
    when SDL::Key::ESCAPE
      exit      
    end
  end

  sleep 0.1
  
end