File: plaympeg.rb

package info (click to toggle)
ruby-sdl 2.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,344 kB
  • ctags: 4,200
  • sloc: cpp: 7,598; ansic: 4,475; ruby: 2,258; sh: 102; makefile: 97
file content (44 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (4)
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
# This sample needs a MPEG file `sample.mpg'.
require 'sdl'

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

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

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

info = mpeg.info

p(info)

mpeg.enable_audio true
mpeg.enable_video true

mpeg.set_display(screen)
mpeg.set_display_region( 0, 0, screen.w, screen.h )
mpeg.play

loop do

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