File: plaympeg.rb

package info (click to toggle)
libsdl-ruby 1.1.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,320 kB
  • ctags: 1,157
  • sloc: ansic: 4,375; ruby: 1,837; makefile: 54
file content (48 lines) | stat: -rw-r--r-- 783 bytes parent folder | download | duplicates (3)
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
42
43
44
45
46
47
48
# This sample needs a MPEG file `sample.mpg'.
require 'sdl'

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

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

  if mpeg.status != SDL::MPEG::PLAYING then
    mpeg.stop
    exit
  end
      
  sleep 0.1
  
end