Skip to content

Commit

Permalink
Item14245: upgrade to mediaelement 2.23.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Dec 1, 2016
1 parent 8bc9ccf commit 4efc660
Show file tree
Hide file tree
Showing 9 changed files with 3,353 additions and 1,335 deletions.
2 changes: 2 additions & 0 deletions data/System/MediaElementPlugin.txt
Expand Up @@ -81,6 +81,8 @@ to render an audio player for your song as part of the page.
%$DEPENDENCIES%

---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 01 Dec 2016: | upgraded to mediaelement-2.23.4; use Foswiki::Func api to read files (oops) |
| 02 Sep 2016: | updated to latest release of mejs |
| 12 Dec 2014: | initial release |

Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/MediaElementPlugin.pm
Expand Up @@ -19,8 +19,8 @@ use strict;
use warnings;
use Foswiki::Plugins::JQueryPlugin ();

our $VERSION = '2.00';
our $RELEASE = '02 Sep 2016';
our $VERSION = '2.01';
our $RELEASE = '01 Dec 2016';
our $SHORTDESCRIPTION = "Cross-browser embedding of videos and audios";
our $NO_PREFS_IN_TOPIC = 1;

Expand Down
41 changes: 24 additions & 17 deletions lib/Foswiki/Plugins/MediaElementPlugin/Core.pm
Expand Up @@ -31,7 +31,7 @@ sub new {
$class->SUPER::new(
$session,
name => 'MediaElement',
version => '2.22.1',
version => '2.23.4',
author => 'John Dyer',
homepage => 'http://mediaelementjs.com',
css => ['pkg.css'],
Expand All @@ -54,6 +54,17 @@ sub handleVIDEO {
($web, $topic) = Foswiki::Func::normalizeWebTopicName($web, $topic);

my $mimeType = $params->{mime};
my $frame = $params->{frame} || 0;
my $width = $params->{width} || 320;
my $height = $params->{height} || '240';
my $placeholder = '%MAKETEXT{"No video playback capabilities"}%';

my $rotate = $params->{rotate};
my $style = '';
if ($rotate) {
$style = "style='-moz-transform:rotate(${rotate}deg);-webkit-transform:rotate(${rotate}deg);-o-transform:rotate(${rotate}deg);-ms-transform:rotate(${rotate}deg);transform:rotate(${rotate}deg);'";
}


my @videos = ();
foreach my $file (split/\s*,\s*/, $video) {
Expand All @@ -62,6 +73,12 @@ sub handleVIDEO {
$url = $file
} else {
$url = Foswiki::Func::getPubUrlPath() . '/' . $web . '/' . $topic . '/' . $file;

my $filePath = $Foswiki::cfg{PubDir} . '/' . $web . '/' . $topic . '/' . $file;
unless (-f $filePath) {
print STDERR "file not found: $filePath\n";
next;
}
}

push @videos, {
Expand All @@ -70,14 +87,13 @@ sub handleVIDEO {
file => $file,
url => $url,
mimeType => $mimeType || $this->getMimeType($file),
poster => '%IMAGE{"'.$url.'" frame="'.$frame.'" output="png" width="'.$width.'" '.($height ne 'auto'?'height="'.$height.'"':'').' format="$src" crop="on" '.($rotate?'rotate="'.$rotate.'"':'').' warn="off"}%',
placeholder => '%IMAGE{"'.$url.'" frame="'.$frame.'" output="png" width="'.$width.'" '.($height ne 'auto'?'height="'.$height.'"':'').' title="'.$placeholder.'" type="plain" crop="on"}%',
}
}

my $videos = join("\n", map {"<source type='$_->{mimeType}' src='$_->{url}'>"} @videos);

my $width = $params->{width} || 320;
my $height = $params->{height} || '240';

my $controls = "";
my $controlsBool = "false";
if (Foswiki::Func::isTrue($params->{controls}, 1)) {
Expand All @@ -92,25 +108,17 @@ sub handleVIDEO {
my $class = '';
$class="class='mejs-$skin" if $skin && $skin ne 'default';


my $rotate = $params->{rotate};
my $style = '';
if ($rotate) {
$style = "style='-moz-transform:rotate(${rotate}deg);-webkit-transform:rotate(${rotate}deg);-o-transform:rotate(${rotate}deg);-ms-transform:rotate(${rotate}deg);transform:rotate(${rotate}deg);'";
}

my $frame = $params->{frame} || 0;
my $poster = $params->{poster} || '';
my $placeholder = '%MAKETEXT{"No video playback capabilities}%';
if (!$autoplay && $poster !~ /^(none|off)$/) {
if ($poster) {
$poster = 'poster="'.$poster.'"';
} else {
$poster = 'poster="%IMAGE{"'.$videos[0]{url}.'" frame="'.$frame.'" output="png" width="'.$width.'" '.($height ne 'auto'?'height="'.$height.'"':'').' format="$src" crop="on" '.($rotate?'rotate="'.$rotate.'"':'').'}%"';
$placeholder = '%IMAGE{"'.$videos[0]{url}.'" frame="'.$frame.'" output="png" width="'.$width.'" '.($height ne 'auto'?'height="'.$height.'"':'').' title="'.$placeholder.'" type="plain" crop="on"}%';
$poster = "poster=$videos[0]{poster}";
$placeholder = $videos[0]{placeholder};
}
}


my $id = $params->{id} || "mej-". (int( rand(10000) ) + 1);

my $result = <<HERE;
Expand All @@ -124,7 +132,6 @@ sub handleVIDEO {
</video>
HERE


return $result;
}

Expand Down Expand Up @@ -164,7 +171,7 @@ sub getMimeType {
my $suffix = $1;

unless ($this->{types}) {
$this->{types} = Foswiki::readFile($Foswiki::cfg{MimeTypesFileName});
$this->{types} = Foswiki::Func::readFile($Foswiki::cfg{MimeTypesFileName});
}

if ($this->{types} =~ /^([^#]\S*).*?\s$suffix(?:\s|$)/im) {
Expand Down

0 comments on commit 4efc660

Please sign in to comment.