PageRenderTime 30ms CodeModel.GetById 11ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/SDL/SMPEG.pm

http://github.com/PerlGameDev/SDL
Perl | 119 lines | 91 code | 27 blank | 1 comment | 4 complexity | 2fbe91b8c072df40288018e86af25d92 MD5 | raw file
  1package SDL::SMPEG;
  2
  3use strict;
  4use warnings;
  5use Carp;
  6use SDL;
  7use SDL::Surface;
  8use SDL::SMPEG::Info;
  9use Scalar::Util 'refaddr';
 10use Data::Dumper;
 11our @ISA = qw(Exporter DynaLoader);
 12
 13use SDL::Internal::Loader;
 14internal_load_dlls(__PACKAGE__);
 15
 16our $VERSION = 2.548;
 17
 18bootstrap SDL::SMPEG;
 19
 20my %_info;
 21
 22sub new {
 23	my $class   = shift;
 24	my %options = @_;
 25
 26	my $n = $options{-name}
 27		|| die "SDL::SMPEG must supply a filename to SDL::SMPEG::new\n";
 28	my $a = $options{'-audio'} ? 1 : 0;
 29	my $info = SDL::SMPEG::Info->new();
 30
 31	my $self = NewSMPEG( $n, $info, $a );
 32	$_info{ refaddr $self } = $info;
 33	Carp::confess SDL::get_error() unless $self;
 34	$self->audio(1);
 35	$self->video(1);
 36	return $self;
 37}
 38
 39sub DESTROY {
 40	FreeSMPEG(  $_[0] );
 41	}
 42
 43sub error {
 44	SMPEGError( $_[0] );
 45}
 46
 47sub audio {
 48	SMPEGEnableAudio( $_[0], $_[1] );
 49}
 50
 51sub video {
 52	SMPEGEnableVideo( $_[0], $_[1] );
 53}
 54
 55sub volume {
 56	SMPEGSetVolume(  $_[0] , $_[1] );
 57}
 58
 59sub display {
 60	Carp::confess "Display requires a SDL::Surface\n"
 61		unless $_[1]->isa('SDL::Surface');
 62	SMPEGSetDisplay( $_[0],  $_[1] , 0 );
 63}
 64
 65sub scale {
 66	return SMPEGScaleXY( $_[0], $_[1], $_[2] ) if ( @_ == 3 );
 67	return SMPEGScaleXY(  $_[0], $_[1]->width(), $_[1]->height() )
 68		if $_[1]->isa('SDL::Surface');
 69	SMPEGScale( $_[0] , $_[1] );
 70}
 71
 72sub play {
 73	SMPEGPlay( $_[0]);
 74}
 75
 76sub pause {
 77	SMPEGPause( $_[0] );
 78}
 79
 80sub stop {
 81	SMPEGStop( $_[0] );
 82}
 83
 84sub rewind {
 85	SMPEGRewind( $_[0] );
 86}
 87
 88sub seek {
 89	SMPEGSeek( $_[0], $_[1] );
 90}
 91
 92sub skip {
 93	SMPEGSkip( $_[0], $_[1] );
 94}
 95
 96sub loop {
 97	SMPEGLoop(  $_[0], $_[1] );
 98}
 99
100sub region {
101	Carp::confess "region requires a SDL::Rect\n"
102		unless $_[1]->isa('SDL::Rect');
103	SMPEGDisplayRegion( $_[0], $_[1] );
104}
105
106sub frame {
107	SMPEGRenderFrame(  $_[0],  $_[1] );
108}
109
110sub info {
111#	SDL::SMPEG::Info->new( -from => $_[0] );
112	$_info{ refaddr $_[0] };
113}
114
115sub status {
116	SMPEGStatus( $_[0] );
117}
118
1191;