View | Details | Raw Unified | Return to bug 20783
Collapse All | Expand All

(-)a/C4/HTML5Media.pm (-16 / +13 lines)
Lines 51-57 sub gethtml5media { Link Here
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
    foreach my $HTML5Media_field (@HTML5Media_fields) {
53
    foreach my $HTML5Media_field (@HTML5Media_fields) {
54
    my $isyoutube            = 0;
54
        my $is_youtube            = 0;
55
        my %HTML5Media;
55
        my %HTML5Media;
56
        # protocol
56
        # protocol
57
        if ( $HTML5Media_field->indicator(1) eq '1' ) {
57
        if ( $HTML5Media_field->indicator(1) eq '1' ) {
Lines 100-117 sub gethtml5media { Link Here
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
                if ($HTML5MediaYouTube == 1) {
102
                if ($HTML5MediaYouTube == 1) {
103
                    require WWW::YouTube::Download;
103
                    my $url = $HTML5Media_field->subfield('u');
104
                    import  WWW::YouTube::Download qw(playback_url);
104
                    # Credit for regex goes to https://stackoverflow.com/questions/3452546/how-do-i-get-the-youtube-video-id-from-a-url
105
                    my $youtube           = WWW::YouTube::Download->new;
105
                    next unless $url =~ m{^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*};
106
                    eval {
106
                    my $video_id = $2;
107
                        $HTML5Media{srcblock} = $youtube->playback_url(
107
                    next unless length($video_id) == 11; # Youtube video ids are 11 chars length
108
                            $HTML5Media_field->subfield('u'), {
108
                    $HTML5Media{srcblock} = sprintf '%s://www.youtube.com/embed/%s', $HTML5Media{protocol}, $video_id;
109
                                'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities
109
                    $HTML5Media{is_youtube} = 1;
110
                            }
110
                    $is_youtube = 1;
111
                        );
112
                    };
113
                    if ($@) { warn $@; }
114
                    else  { $isyoutube = 1;}
115
                }
111
                }
116
               else {
112
               else {
117
                   next; # do not embed youtube videos
113
                   next; # do not embed youtube videos
Lines 145-156 sub gethtml5media { Link Here
145
        else {
141
        else {
146
            $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0];
142
            $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0];
147
        }
143
        }
148
        if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $isyoutube != 1) ) {
144
        if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $is_youtube != 1) ) {
149
            next; # not a specified media file
145
            next; # not a specified media file
150
        }
146
        }
151
        # youtube
147
        # youtube
152
        if ($isyoutube == 1) {
148
        if ($is_youtube == 1) {
153
                $HTML5Media{mime} = 'video/webm';
149
            $HTML5Media{mime} = 'video/webm';
150
            $HTML5Media{type} = 'video';
154
        }
151
        }
155
        # mime
152
        # mime
156
        if ( $HTML5Media_field->subfield('c') ) {
153
        if ( $HTML5Media_field->subfield('c') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-6 / +10 lines)
Lines 195-201 Link Here
195
        </li>
195
        </li>
196
    [% END %]
196
    [% END %]
197
[% END %]
197
[% END %]
198
[% IF ( HTML5MediaEnabled ) %][% IF ( HTML5MediaSets ) %]<li id="media_tab"><a href="#html5media">Play media</a></li>[% END %][% END %]
198
[% IF HTML5MediaEnabled && HTML5MediaSets.size %]<li id="media_tab"><a href="#html5media">Play media</a></li>[% END %]
199
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
199
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
200
    <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li>
200
    <li class="NovelistSelect" style="display:none;"><a href="#NovelistSelect">NoveList Select</a></li>
201
[% END %]
201
[% END %]
Lines 820-829 Note that permanent location is a code, and location may be an authval. Link Here
820
<div id="html5media">
820
<div id="html5media">
821
          [% FOREACH HTML5MediaSet IN HTML5MediaSets %]
821
          [% FOREACH HTML5MediaSet IN HTML5MediaSets %]
822
            <p>
822
            <p>
823
              <[% HTML5MediaParent | html %] controls preload=none>
823
                [% IF HTML5MediaSet.is_youtube %]
824
                <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | html %]"[% HTML5MediaSet.typeblock | html %] />
824
                    <iframe id="player" type="text/html" width="640" height="360"
825
                [[% HTML5MediaParent | html %] tag not supported by your browser.]
825
                        src="[% HTML5MediaSet.srcblock %]" frameborder="0"></iframe>
826
              </[% HTML5MediaParent | html %]>
826
                [% ELSE %]
827
                  <[% HTML5MediaParent | html %] controls preload=none>
828
                    <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | url %]"[% HTML5MediaSet.typeblock | html %] />
829
                    [[% HTML5MediaParent | html %] tag not supported by your browser.]
830
                  </[% HTML5MediaParent | html %]>
831
                [% END %]
827
            </p>
832
            </p>
828
          [% END %]
833
          [% END %]
829
</div>
834
</div>
830
- 

Return to bug 20783