/[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 882 by dpavlin, Fri Dec 19 14:01:01 2008 UTC revision 883 by dpavlin, Tue Dec 23 21:00:14 2008 UTC
# Line 66  sub as_markup { Line 66  sub as_markup {
66    
67          my $FlashVars = join('&', @{ $self->FlashVars });          my $FlashVars = join('&', @{ $self->FlashVars });
68    
69            $self->add_css(q|
70                    #subtitle small {
71                            color: #888;
72                    }
73            |);
74    
75            $self->add_js(q|
76                    var _subtitle_active = -1;
77    
78                    function flv_subtitle(subtitle,nr) {
79    
80                            // remove current subtitle
81                            if ( _subtitle_active >= 0 ) {
82                                    document.getElementById('subtitle-' + _subtitle_active).style.background = '#fff';
83                            }
84    
85                            var s = document.getElementById('subtitle');
86                            if ( subtitle.message ) {
87                                    s.innerHTML = ''
88                                            + subtitle.message
89                                            + ' <small>'
90                                            + nr + ' ' +
91                                            + subtitle.timeStart
92                                            + ' ... '
93                                            + subtitle.timeEnd
94                                            + '</small>'
95                                            ;
96                                    document.getElementById('subtitle-' + nr).style.background = '#ff0';
97                                    _subtitle_active = nr;
98                            } else {
99                                    s.innerHTML = '&nbsp;';
100                                    _subtitle_active = -1;
101                            }
102                    }
103            |);
104    
105          my $info = $self->dropdown( $self->path, \%info );          my $info = $self->dropdown( $self->path, \%info );
106          qq|          qq|
107                  <object id="flvplayer" type="application/x-shockwave-flash" data="$swf" width="$width" height="$height">                  <object id="flvplayer" type="application/x-shockwave-flash" data="$swf" width="$width" height="$height">
108                  <param name="movie" value="$swf" />                  <param name="movie" value="$swf" />
109                  <param name="FlashVars" value="$FlashVars" />                  <param name="FlashVars" value="$FlashVars" />
110                    <param name="AllowScriptAccess" value="always"> <!-- domain -->
111                  </object>                  </object>
112                  <div>$info</div>                  <div id="subtitle">&nbsp;<small>no subtitle</small></div>
113                    <div style="border: 1px slashed #888;">
114                    <input type="button" onclick="document.getElementById('flvplayer').SetVariable('player:jsPlay', '');" value="Play" >
115                    <input type="button" onclick="alert(document.getElementById('flvplayer').GetVariable('method:getPosition'))" value="getPosition" >
116                    </div>
117                  $subtitles                  $subtitles
118                    <div>$info</div>
119          |;          |;
120    
121  }  }
# Line 88  sub subtitles_as_markup { Line 130  sub subtitles_as_markup {
130          if ( -e $srt ) {          if ( -e $srt ) {
131                  push @{ $self->FlashVars }, 'srt=1';                  push @{ $self->FlashVars }, 'srt=1';
132    
133                    my $nr = 0;
134    
135                    $self->add_js(qq|
136                            function play_from(position) {
137                                    var p = document.getElementById('flvplayer');
138                                    p.SetVariable('player:jsSetPosition', position);
139                                    p.SetVariable('player:jsPlay','');
140                                    return false;
141                            }
142                    |);
143    
144                    sub jump_to {
145                            my $t = shift;
146                            my $position =
147                                    $1 * 60 * 60 +
148                                    $2 * 60 +
149                                    $3
150                                    if ( $t =~ m/(\d\d):(\d\d):(\d\d),\d/ );
151                            ;
152    
153                            qq|<a href="#$t" onclick="return play_from($position);">$t</a>|;
154                    }
155    
156                  my $callback = sub {                  my $callback = sub {
157                          my $data = shift;                          my $data = shift;
158                          $html .= qq|<tr><td> $data->{start_time} </td><td> $data->{end_time} </td><td> $data->{text} </td></tr>|;                          my $s = jump_to( $data->{start_time} );
159                            my $e = jump_to( $data->{end_time} );
160                            $html .= qq|<tr id="subtitle-$nr"><td>$s</td><td>$e</td><td> $data->{text} </td></tr>|;
161                            $nr++;
162                  };                  };
163    
164                  my $subtitle = Video::Subtitle::SRT->new($callback);                  my $subtitle = Video::Subtitle::SRT->new($callback);

Legend:
Removed from v.882  
changed lines
  Added in v.883

  ViewVC Help
Powered by ViewVC 1.1.26