-
Notifications
You must be signed in to change notification settings - Fork 28
/
SMPEG.pm
117 lines (91 loc) · 1.79 KB
/
SMPEG.pm
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package SDL::SMPEG;
use strict;
use warnings;
use Carp;
use SDL;
use SDL::Surface;
use SDL::SMPEG::Info;
use Scalar::Util 'refaddr';
use Data::Dumper;
our @ISA = qw(Exporter DynaLoader);
use SDL::Internal::Loader;
internal_load_dlls(__PACKAGE__);
bootstrap SDL::SMPEG;
my %_info;
sub new {
my $class = shift;
my %options = @_;
my $n = $options{-name}
|| die "SDL::SMPEG must supply a filename to SDL::SMPEG::new\n";
my $a = $options{'-audio'} ? 1 : 0;
my $info = SDL::SMPEG::Info->new();
my $self = NewSMPEG( $n, $info, $a );
$_info{ refaddr $self } = $info;
Carp::confess SDL::get_error() unless $self;
$self->audio(1);
$self->video(1);
return $self;
}
sub DESTROY {
FreeSMPEG( $_[0] );
}
sub error {
SMPEGError( $_[0] );
}
sub audio {
SMPEGEnableAudio( $_[0], $_[1] );
}
sub video {
SMPEGEnableVideo( $_[0], $_[1] );
}
sub volume {
SMPEGSetVolume( $_[0] , $_[1] );
}
sub display {
Carp::confess "Display requires a SDL::Surface\n"
unless $_[1]->isa('SDL::Surface');
SMPEGSetDisplay( $_[0], $_[1] , 0 );
}
sub scale {
return SMPEGScaleXY( $_[0], $_[1], $_[2] ) if ( @_ == 3 );
return SMPEGScaleXY( $_[0], $_[1]->width(), $_[1]->height() )
if $_[1]->isa('SDL::Surface');
SMPEGScale( $_[0] , $_[1] );
}
sub play {
SMPEGPlay( $_[0]);
}
sub pause {
SMPEGPause( $_[0] );
}
sub stop {
SMPEGStop( $_[0] );
}
sub rewind {
SMPEGRewind( $_[0] );
}
sub seek {
SMPEGSeek( $_[0], $_[1] );
}
sub skip {
SMPEGSkip( $_[0], $_[1] );
}
sub loop {
SMPEGLoop( $_[0], $_[1] );
}
sub region {
Carp::confess "region requires a SDL::Rect\n"
unless $_[1]->isa('SDL::Rect');
SMPEGDisplayRegion( $_[0], $_[1] );
}
sub frame {
SMPEGRenderFrame( $_[0], $_[1] );
}
sub info {
# SDL::SMPEG::Info->new( -from => $_[0] );
$_info{ refaddr $_[0] };
}
sub status {
SMPEGStatus( $_[0] );
}
1;