From 4ec75af910a41173a0e2bce5aff67534c1bfc5b1 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 11 Oct 2009 21:46:30 +0200 Subject: [PATCH] collect video:file.ogv files from subtitles --- bin/mplayer.pl | 40 ++++++++++++++++++++++++++++++++++++---- www/tv.html | 2 ++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/bin/mplayer.pl b/bin/mplayer.pl index 1cde29a..c282bec 100755 --- a/bin/mplayer.pl +++ b/bin/mplayer.pl @@ -95,20 +95,33 @@ sub html5tv { my @slide_t; + my @videos; + foreach my $s ( @subtitles ) { push @{ $sync->{htmlEvents}->{'#subtitle'} }, { startTime => $s->[0], - endTime => $s->[1], - html => $s->[2], + endTime => $s->[1], + html => $s->[2], }; + + if ( $s->[2] =~ m{video:(.+)} ) { + my $video = $1; + my $path = "www/media/$video"; + if ( ! -e $path ) { + warn "MISSING $path: $!\n"; + } else { + push @videos, $video; + } + } + next unless $s->[2] =~ m{\[(\d+)\]}; my $res = ( $prop->{width} / 4 ) . 'x' . ( $prop->{height} / 4 ); push @{ $sync->{customEvents} }, { startTime => $s->[0], - endTime => $s->[1], - action => 'chapterChange', + endTime => $s->[1], + action => 'chapterChange', args => { carousel => 'theCarousel', id => "chapter$1", @@ -156,12 +169,31 @@ sub html5tv { } } + $html5tv->{video_tags} = + join("\n", + map { + qq| +
+ +
+ | + } @videos + ) + ; + warn "html5tv ", dump $html5tv; my $sync_path = 'www/media/video.js'; write_file $sync_path, "var html5tv = " . to_json($html5tv) . " ;\n"; warn "sync $sync_path ", -s $sync_path, " bytes\n"; + my $html = read_file 'www/tv.html'; + $html =~ s|{([^}]+)}|my $n = $1; $n =~ s(\.)(}->{)g; eval "\$html5tv->{$n}"|egs || + warn "no interpolation in template!"; + + write_file 'www/media.html', $html; } diff --git a/www/tv.html b/www/tv.html index 763c84c..1596917 100644 --- a/www/tv.html +++ b/www/tv.html @@ -54,6 +54,8 @@ +{video_tags} +

This web interface is based on BBC R&D TV HTML 5 and timed media from the RAD blog

-- 2.20.1