Lines 50-56
sub gethtml5media {
Link Here
|
50 |
my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") ); |
50 |
my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") ); |
51 |
my $HTML5MediaYouTube = C4::Context->preference("HTML5MediaYouTube"); |
51 |
my $HTML5MediaYouTube = C4::Context->preference("HTML5MediaYouTube"); |
52 |
my $marcflavour = C4::Context->preference("marcflavour"); |
52 |
my $marcflavour = C4::Context->preference("marcflavour"); |
53 |
my $isyoutube = 0; |
53 |
my $is_embed = 0; |
54 |
foreach my $HTML5Media_field (@HTML5Media_fields) { |
54 |
foreach my $HTML5Media_field (@HTML5Media_fields) { |
55 |
my %HTML5Media; |
55 |
my %HTML5Media; |
56 |
# protocol |
56 |
# protocol |
Lines 99-117
sub gethtml5media {
Link Here
|
99 |
if ( $HTML5Media_field->subfield('u') ) { |
99 |
if ( $HTML5Media_field->subfield('u') ) { |
100 |
$HTML5Media{srcblock} = $HTML5Media_field->subfield('u'); |
100 |
$HTML5Media{srcblock} = $HTML5Media_field->subfield('u'); |
101 |
if (grep /youtu\.?be/, $HTML5Media_field->subfield('u') ) { |
101 |
if (grep /youtu\.?be/, $HTML5Media_field->subfield('u') ) { |
|
|
102 |
$HTML5Media{srcblock} = ""; |
102 |
if ($HTML5MediaYouTube == 1) { |
103 |
if ($HTML5MediaYouTube == 1) { |
103 |
require WWW::YouTube::Download; |
104 |
use HTML::Video::Embed; |
104 |
import WWW::YouTube::Download qw(playback_url); |
105 |
my $embedder = HTML::Video::Embed->new({ |
105 |
my $youtube = WWW::YouTube::Download->new; |
106 |
class => 'html5-embed-video' |
|
|
107 |
}); |
108 |
|
106 |
eval { |
109 |
eval { |
107 |
$HTML5Media{srcblock} = $youtube->playback_url( |
110 |
my $html_embed_code = $embedder->url_to_embed( $HTML5Media_field->subfield('u') ); |
108 |
$HTML5Media_field->subfield('u'), { |
111 |
$HTML5Media{embed} = $html_embed_code; |
109 |
'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities |
|
|
110 |
} |
111 |
); |
112 |
}; |
112 |
}; |
113 |
if ($@) { warn $@; } |
113 |
if ($@) { warn $@; } |
114 |
else { $isyoutube = 1;} |
114 |
else { $is_embed = 1;} |
115 |
} |
115 |
} |
116 |
else { |
116 |
else { |
117 |
next; # do not embed youtube videos |
117 |
next; # do not embed youtube videos |
Lines 145-157
sub gethtml5media {
Link Here
|
145 |
else { |
145 |
else { |
146 |
$HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0]; |
146 |
$HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0]; |
147 |
} |
147 |
} |
148 |
if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $isyoutube != 1) ) { |
148 |
if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $is_embed != 1) ) { |
149 |
next; # not a specified media file |
149 |
next; # not a specified media file |
150 |
} |
150 |
} |
151 |
# youtube |
|
|
152 |
if ($isyoutube == 1) { |
153 |
$HTML5Media{mime} = 'video/webm'; |
154 |
} |
155 |
# mime |
151 |
# mime |
156 |
if ( $HTML5Media_field->subfield('c') ) { |
152 |
if ( $HTML5Media_field->subfield('c') ) { |
157 |
$HTML5Media{codecs} = $HTML5Media_field->subfield('c'); |
153 |
$HTML5Media{codecs} = $HTML5Media_field->subfield('c'); |
Lines 222-228
sub gethtml5media {
Link Here
|
222 |
$HTML5Media{type} = 'track'; |
218 |
$HTML5Media{type} = 'track'; |
223 |
} |
219 |
} |
224 |
# push |
220 |
# push |
225 |
if ( $HTML5Media{srcblock} && $HTML5Media{type} ) { |
221 |
if ( ($HTML5Media{srcblock} && $HTML5Media{type}) || $HTML5Media{embed} ) { |
226 |
push (@HTML5Media_sets, \%HTML5Media); |
222 |
push (@HTML5Media_sets, \%HTML5Media); |
227 |
} |
223 |
} |
228 |
} |
224 |
} |
Lines 252-258
sub gethtml5media {
Link Here
|
252 |
} |
248 |
} |
253 |
|
249 |
|
254 |
return ( |
250 |
return ( |
255 |
HTML5MediaEnabled => ( (scalar(@HTML5Media_sets) > 0) && ($HTML5MediaParent) ), |
251 |
HTML5MediaEnabled => ( (scalar(@HTML5Media_sets) > 0 && $HTML5MediaParent) || $is_embed ), |
256 |
HTML5MediaSets => \@HTML5Media_sets, |
252 |
HTML5MediaSets => \@HTML5Media_sets, |
257 |
HTML5MediaParent => $HTML5MediaParent, |
253 |
HTML5MediaParent => $HTML5MediaParent, |
258 |
HTML5MediaWidth => $HTML5MediaWidth, |
254 |
HTML5MediaWidth => $HTML5MediaWidth, |