line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Video; |
2
|
1
|
|
|
1
|
|
17556
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
sub to_embed { |
5
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
6
|
0
|
|
|
|
|
|
my $url = $self->url; |
7
|
0
|
0
|
|
|
|
|
my $type = $url->path =~ /\.(\w+)$/ ? $1 : 'unknown'; |
8
|
0
|
|
|
|
|
|
my %args = @_; |
9
|
0
|
|
|
|
|
|
my @extra; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
0
|
|
|
|
$type = $self->_types->type($type) || "unknown/$type"; |
12
|
0
|
|
0
|
|
|
|
$args{height} ||= $self->DEFAULT_VIDEO_HEIGHT; |
13
|
0
|
|
0
|
|
|
|
$args{width} ||= $self->DEFAULT_VIDEO_WIDTH; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
local $" = ' '; |
16
|
0
|
0
|
|
|
|
|
push @extra, 'autoplay' if $args{autoplay}; |
17
|
0
|
0
|
|
|
|
|
unshift @extra, '' if @extra; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return $self->tag( |
20
|
|
|
|
|
|
|
video => width => $args{width}, |
21
|
|
|
|
|
|
|
height => $args{height}, |
22
|
|
|
|
|
|
|
class => 'link-embedder', |
23
|
|
|
|
|
|
|
@extra, |
24
|
|
|
|
|
|
|
preload => 'metadata', |
25
|
|
|
|
|
|
|
controls => undef, |
26
|
|
|
|
|
|
|
sub { |
27
|
0
|
|
|
0
|
|
|
return join('', |
28
|
|
|
|
|
|
|
$self->tag(source => src => $url, type => $type), |
29
|
|
|
|
|
|
|
$self->tag(p => class => 'alert', 'Your browser does not support the video tag.')); |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |