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', |
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 |
|
|
56 |
my $width = $info{meta_width}; |
my $width = $info{meta_width}; |
57 |
my $height = $info{meta_height}; |
my $height = $info{meta_height}; |
58 |
|
|
59 |
my @var = ( "flv=$url" ); |
push @{ $self->FlashVars }, "flv=$url"; |
60 |
|
|
61 |
my $srt = $path; |
my $subtitles = $self->subtitles_as_markup; |
|
$srt =~ s{\.flv}{.srt}; |
|
|
if ( -e $srt ) { |
|
|
push @var, "srt=1"; |
|
|
} |
|
62 |
|
|
63 |
push @var, 'title=' . $self->title if $self->title; |
push @{ $self->FlashVars }, 'title=' . $self->title if $self->title; |
64 |
|
|
65 |
my $FlashVars = join('&', @var); |
my $FlashVars = join('&', @{ $self->FlashVars }); |
66 |
|
|
67 |
qq| |
qq| |
68 |
<object type="application/x-shockwave-flash" data="$swf" width="$width" height="$height"> |
<object type="application/x-shockwave-flash" data="$swf" width="$width" height="$height"> |
69 |
<param name="movie" value="$swf" /> |
<param name="movie" value="$swf" /> |
70 |
<param name="FlashVars" value="$FlashVars" /> |
<param name="FlashVars" value="$FlashVars" /> |
71 |
</object> |
</object> |
72 |
|
$subtitles |
73 |
|; |
|; |
74 |
|
|
75 |
} |
} |
76 |
|
|
77 |
|
sub subtitles_as_markup { |
78 |
|
my ( $self ) = @_; |
79 |
|
|
80 |
|
my $srt = $self->path; |
81 |
|
$srt =~ s{\.flv}{.srt}; |
82 |
|
my $html = ''; |
83 |
|
|
84 |
|
if ( -e $srt ) { |
85 |
|
push @{ $self->FlashVars }, 'srt=1'; |
86 |
|
|
87 |
|
my $callback = sub { |
88 |
|
my $data = shift; |
89 |
|
$html .= qq|<tr><td> $data->{start_time} </td><td> $data->{end_time} </td><td> $data->{text} </td></tr>|; |
90 |
|
}; |
91 |
|
|
92 |
|
my $subtitle = Video::Subtitle::SRT->new($callback); |
93 |
|
$subtitle->debug(1); |
94 |
|
$subtitle->parse( $srt ); |
95 |
|
|
96 |
|
$html = qq| |
97 |
|
<table class="html"> |
98 |
|
<thead> |
99 |
|
<tr><th>from</th><th>to</th><th>subtitle</th></tr> |
100 |
|
</thead> |
101 |
|
<tbody> |
102 |
|
$html |
103 |
|
<tbody> |
104 |
|
</table> |
105 |
|
|; |
106 |
|
} |
107 |
|
|
108 |
|
return $html; |
109 |
|
} |
110 |
|
|
111 |
1; |
1; |