/[Frey]/trunk/lib/Frey/Web/FLVPlayer.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Web/FLVPlayer.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 847 by dpavlin, Mon Dec 15 18:57:04 2008 UTC revision 855 by dpavlin, Mon Dec 15 21:40:28 2008 UTC
# Line 12  with 'Frey::Web'; Line 12  with 'Frey::Web';
12  #with 'Frey::Storage';  #with 'Frey::Storage';
13  with 'Frey::File::FLV';  with 'Frey::File::FLV';
14    
15    use Video::Subtitle::SRT;
16    
17  has title => (  has title => (
18          is => 'rw',          is => 'rw',
19          isa => 'Str',          isa => 'Str',
# Line 31  has player_swf => ( Line 33  has player_swf => (
33          default => 'http://flv-player.net/medias/player_flv_maxi.swf',          default => 'http://flv-player.net/medias/player_flv_maxi.swf',
34  );  );
35    
36    has FlashVars => (
37            is => 'rw',
38            isa => 'ArrayRef[Str]',
39            default => sub { [] },
40            lazy => 1, # hide it from user
41    );
42    
43  sub as_markup {  sub as_markup {
44          my ($self) = @_;          my ($self) = @_;
45    
# Line 44  sub as_markup { Line 53  sub as_markup {
53          my %info = $self->flv_info;          my %info = $self->flv_info;
54          warn "# info ", $self->dump( \%info );          warn "# info ", $self->dump( \%info );
55    
56          my $width  = $info{meta_width};          my $width  = $info{video_width};
57          my $height = $info{meta_height};          my $height = $info{video_height};
58    
59          my @var = ( "flv=$url" );          $self->FlashVars( [ "flv=$url", "autoload=1", "showtime=1" ] );
60    
61          my $srt = $path;          push @{ $self->FlashVars }, 'showvolume=1' if $info{audio_count} > 0;
         $srt =~ s{\.flv}{.srt};  
         if ( -e $srt ) {  
                 push @var, "srt=1";  
         }  
62    
63          push @var, 'title=' . $self->title if $self->title;          my $subtitles = $self->subtitles_as_markup;
64    
65          my $FlashVars = join('&', @var);          push @{ $self->FlashVars }, 'title=' . $self->title if $self->title;
66    
67            my $FlashVars = join('&', @{ $self->FlashVars });
68    
69            my $info = $self->dropdown( $self->path, \%info );
70          qq|          qq|
71                  <object type="application/x-shockwave-flash" data="$swf" width="$width" height="$height">                  <object type="application/x-shockwave-flash" data="$swf" width="$width" height="$height">
72                  <param name="movie" value="$swf" />                  <param name="movie" value="$swf" />
73                  <param name="FlashVars" value="$FlashVars" />                  <param name="FlashVars" value="$FlashVars" />
74                  </object>                  </object>
75                    <div>$info</div>
76                    $subtitles
77          |;          |;
78    
79  }  }
80    
81    sub subtitles_as_markup {
82            my ( $self ) = @_;
83    
84            my $srt = $self->path;
85            $srt =~ s{\.flv}{.srt};
86            my $html = '';
87    
88            if ( -e $srt ) {
89                    push @{ $self->FlashVars }, 'srt=1';
90    
91                    my $callback = sub {
92                            my $data = shift;
93                            $html .= qq|<tr><td> $data->{start_time} </td><td> $data->{end_time} </td><td> $data->{text} </td></tr>|;
94                    };
95    
96                    my $subtitle = Video::Subtitle::SRT->new($callback);
97                    $subtitle->debug(1);
98                    $subtitle->parse( $srt );
99    
100                    $html = qq|
101                            <table class="html">
102                                    <thead>
103                                            <tr><th>from</th><th>to</th><th>subtitle</th></tr>
104                                    </thead>
105                                    <tbody>
106                                            $html
107                                    <tbody>
108                            </table>
109                    |;
110            }
111    
112            return $html;
113    }
114    
115  1;  1;

Legend:
Removed from v.847  
changed lines
  Added in v.855

  ViewVC Help
Powered by ViewVC 1.1.26