Permalink
Browse files

v0.1 commit. Initial release.

  • Loading branch information...
emirpprime committed Oct 13, 2011
0 parents commit 678241247b895416d7337f7e16e1651960b3699c
@@ -0,0 +1,51 @@
+# Copyright (C) 2011 Phil Banks
+# License GNU/GPL http://www.gnu.org/copyleft/gpl.html
+
+# pb_mediael.xml
+PLUGIN DESC=<h1>pb:MediaEl 0.1 [Plugin]</h1><strong>Based on Media Element.JS 2.2.3 (<a href="http://mediaelementjs.com" title="Homepage of Media Element.JS" target="_blank">http://mediaelementjs.com</a>)</strong><p><strong>Description:</strong><br />Content Plugin which provides a HTML5 Video Player for Joomla! 1.5.</p><p><strong>Syntax:</strong><br />Place the following code in an article: <pre wrap="wrap">{pb_mediael media=[video] width=[640] height=[480] autoplay=[true] preload=[true] loop=[true] video_mp4=[http://video-js.zencoder.com/oceans-clip.mp4] video_webm=[http://video-js.zencoder.com/oceans-clip.webm] video_ogg=[http://video-js.zencoder.com/oceans-clip.ogg] flash=[http://video-js.zencoder.com/oceans-clip.mp4] image=[http://video-js.zencoder.com/oceans-clip.png] image_visibility=[true]}</pre></p><p>These are all parameters. Minimum required is media, width, height and a source file.</p>
+
+# Video
+DEFAULT AUDIO PARAMETER=<strong>Audio Parameter</strong>
+
+LABEL AUDIO MP3=Audio [mp3]
+
+DESC AUDIO MP3=Default audio [mp3]. Leave blank for no default Audio.
+
+# Video
+DEFAULT VIDEO PARAMETER=<strong>Video Parameter</strong>
+
+LABEL VIDEO MP4=Video [mp4]
+LABEL VIDEO WEBM=Video [webm]
+LABEL VIDEO OGG=Video [ogg]
+LABEL FLASH=Flash Fallback [mp4]
+LABEL IMAGE=Poster Image
+LABEL IMAGE VISIBILITY=Image visible
+
+DESC VIDEO MP4=Default video [mp4]. Leave blank for no default Video.
+DESC VIDEO WEBM=Default video [webm]. Leave blank for no default Video.
+DESC VIDEO OGG=Default video [ogg]. Leave blank for no default Video.
+DESC FLASH=If video cannot display in HTML5, here you can set a default fallback video for flash. Leave blank for no default flash video.
+DESC IMAGE=Default poster image. Types: gif, jpg, png.
+DESC IMAGE VISIBILITY=Hide/display the poster image.
+
+# Player
+DEFAULT PLAYER PARAMETER=<strong>Player Parameter</strong>
+
+LABEL MEDIA=Media Type
+LABEL WIDTH=Width
+LABEL HEIGHT=Height
+LABEL AUTOPLAY=Autoplay
+LABEL PRELOAD=Preload
+LABEL LOOP=Loop
+LABEL DEFAULT VOLUME=Default Volume
+LABEL WMODE=WMode
+
+DESC MEDIA=Media type - video or audio.
+DESC WIDTH=Width.
+DESC HEIGHT=Height.
+DESC SKIN=Choose skin.
+DESC AUTOPLAY=Autoplay the video.
+DESC PRELOAD=Preload the video.
+DESC LOOP=Loops the video. Actually it works only in HTML.
+DESC DEFAULT VOLUME=Will be overridden by local volume if available.
+DESC WMODE=Here you can choose the wmode for flash player (e.g. opaque, to place elements above flash).
@@ -0,0 +1,256 @@
+<?php
+/**
+* @Copyright Copyright (C) 2011 Phil Banks
+* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
+**/
+
+defined( '_JEXEC' ) or die( 'Restricted access' );
+$mainframe->registerEvent( 'onPrepareContent', 'pluginPbMediaEl' );
+
+function pluginPbMediaEl(&$row, &$params) {
+
+ $plugin =& JPluginHelper::getPlugin('content', 'pb_mediael');
+ $pluginParams = new JParameter( $plugin->params );
+
+ if (!isset($GLOBALS['plg_pb_mediael'])) {
+ $GLOBALS['plg_pb_mediael'] = 1;
+ }
+
+ $hits = preg_match_all('#{pb_mediael\s*(.*?)}#s', $row->text, $matches);
+
+ if (!empty($hits)) {
+ $document =& JFactory::getDocument();
+
+ // Check if mediaelsentials script is loaded
+ $scripts = array_keys($document->_scripts);
+ $foundJqueryScripts = false;
+ for ($i = 0; $i<count($scripts); $i++) {
+ if (stripos($scripts[$i], 'jquery') !== false) {
+ $foundJqueryScripts = true;
+ }
+ }
+ if (!$foundJqueryScripts) {
+ $document->addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');
+ }
+ $foundMediaelScripts = false;
+ for ($i = 0; $i<count($scripts); $i++) {
+ if (stripos($scripts[$i], 'mediaelement-and-player.min.js') !== false) {
+ $foundMediaelScripts = true;
+ }
+ }
+ if (!$foundMediaelScripts) {
+ $document->addScript(JURI::base().'plugins/content/pb_mediael/mediaelement-and-player.min.js');
+ }
+ $foundMediaelJScripts = false;
+ for ($i = 0; $i<count($scripts); $i++) {
+ if (stripos($scripts[$i], 'mediaelementplayer') !== false) {
+ $foundMediaeljsScripts = true;
+ }
+ }
+ if (!$foundMediaelJScripts) {
+
+
+ for ($i=$GLOBALS['plg_pb_mediael']; $i<$GLOBALS['plg_pb_mediael']+$hits; $i++) {
+ $document->addScriptDeclaration('
+ var $j = jQuery.noConflict();
+ $j(document).ready(function() {
+ //$j(".PbMediaEl").hide();
+ $j("video,audio").mediaelementplayer({
+ startVolume: '.$pluginParams->get('defaultVolume', '0.85').',
+ enableAutosize: true,
+ });
+ });
+ ');
+
+
+ for ($j=0; $j<$hits; $j++) {
+ $videoParams = $matches[1][$j];
+ $videoParamsList = contentPbMediaEl_getParams($videoParams, $pluginParams);
+ $html = contentPbMediaEl_createHTML($i+$j, $pluginParams, $videoParamsList);
+ $pattern = str_replace('[', '\[', $matches[0][$j]);
+ $pattern = str_replace(']', '\]', $pattern);
+ $pattern = str_replace('/', '\/', $pattern);
+ $row->text = preg_replace('/'.$pattern.'/', $html, $row->text, 1);
+ }
+ }
+
+ }
+
+
+ // Count instances
+ $GLOBALS['plg_pb_mediael'] += $hits;
+
+ // Check if mediaelsentials stylesheets are loaded
+ $styleSheets = array_keys($document->_styleSheets);
+
+ $foundmediaelStyles = false;
+ for ($i = 0; $i<count($styleSheets); $i++) {
+ if (stripos($styleSheets[$i], 'mediaelementplayer.min.css') !== false) {
+ $foundmediaelStyles = true;
+ }
+ }
+ if (!$foundmediaelStyles) {
+ $document->addStyleSheet(JURI::base().'plugins/content/pb_mediael/mediaelementplayer.min.css');
+ }
+
+ } else {
+ return false;
+ }
+
+ return true;
+
+}
+
+function contentPbMediaEl_getParams($videoParams, $pluginParams) {
+
+ $videoParamsList['media'] = $pluginParams->get('media');
+ $videoParamsList['width'] = $pluginParams->get('width');
+ $videoParamsList['height'] = $pluginParams->get('height');
+ $videoParamsList['autoplay'] = $pluginParams->get('autoplay');
+ $videoParamsList['preload'] = $pluginParams->get('preload');
+ $videoParamsList['loop'] = $pluginParams->get('loop');
+ $videoParamsList['audio_mp3'] = $pluginParams->get('audio_mp3');
+ $videoParamsList['video_mp4'] = $pluginParams->get('video_mp4');
+ $videoParamsList['video_webm'] = $pluginParams->get('video_webm');
+ $videoParamsList['video_ogg'] = $pluginParams->get('video_ogg');
+ $videoParamsList['image'] = $pluginParams->get('image');
+ $videoParamsList['image_visibility'] = $pluginParams->get('image_visibility');
+ $videoParamsList['flash'] = $pluginParams->get('flash');
+
+ $items = explode(' ', $videoParams);
+
+ foreach ($items as $item) {
+ if ($item != '') {
+ $item = explode('=', $item);
+ $name = $item[0];
+ $value = strtr($item[1], array('['=>'', ']'=>''));
+ $videoParamsList[$name] = $value;
+ }
+ }
+
+ return $videoParamsList;
+}
+
+function contentPbMediaEl_createHTML($id, &$pluginParams, &$videoParamsList) {
+
+ $media = $videoParamsList['media'];
+ $width = $videoParamsList['width'];
+ $height = $videoParamsList['height'];
+ $autoplay = $videoParamsList['autoplay'];
+ $preload = $videoParamsList['preload'];
+ $loop = $videoParamsList['loop'];
+ $audio_mp3 = $videoParamsList['audio_mp3'];
+ $video_mp4 = $videoParamsList['video_mp4'];
+ $video_webm = $videoParamsList['video_webm'];
+ $video_ogg = $videoParamsList['video_ogg'];
+ $flash = $videoParamsList['flash'];
+ $image = $videoParamsList['image'];
+ $image_visibility = $videoParamsList['image_visibility'];
+ $wmode = $pluginParams->get('wmode', 'default');
+ $uri_flash = '';
+ $uri_image = '';
+
+ // Add URI for local flash video
+ if (stripos($flash, 'http://') === false) {
+ $uri_flash = JURI::base();
+ }
+
+ // Add URI for local flash image
+ if (stripos($image, 'http://') === false) {
+ $uri_image = JURI::base();
+ }
+
+ // Preload works for both HTML and Flash
+ if ($preload == "true" || $preload == "1") {
+ $preload_html = ' preload="auto"';
+ $preload_flash = '"autoBuffering":true';
+ } else {
+ $preload_html = ' preload="none"';
+ $preload_flash = '"autoBuffering":false';
+ }
+
+ // Autoplay works for both HTML and Flash
+ if ($autoplay == "true" || $autoplay == "1") {
+ $autoplay_html = ' autoplay="autoplay"';
+ $autoplay_flash = '"autoPlay":true';
+ } else {
+ $autoplay_html = '';
+ $autoplay_flash = '"autoPlay":false';
+ }
+
+ // Actually loop works only for HTML
+ if ($loop == "true" || $loop == "1") {
+ $loop_html = ' loop="loop"';
+ } else {
+ $loop_html = '';
+ }
+
+ // Poster image
+ if ($image_visibility == "true" || $image_visibility == "1") {
+ $poster_html = ' poster="'.$image;
+ } else {
+ $poster_html = '';
+ }
+
+ // HTML output
+ $html = '<'.$media.' width="'.$width.'" height="'.$height.'" controls="controls"'.$autoplay_html.$preload_html.$loop_html.$poster_html.'">';
+
+ if ($audio_mp3 != "") {
+ $html .= '<source src="'.$audio_mp3.'" type=\'audio/mp3\' />';
+ }
+
+ if ($video_mp4 != "") {
+ $html .= '<source src="'.$video_mp4.'" type="video/mp4; codecs=\'avc1.42E01E, mp4a.40.2\'" />';
+ }
+
+ if ($video_webm != "") {
+ $html .= '<source src="'.$video_webm.'" type=\'video/webm; codecs="vp8, vorbis"\' />';
+ }
+
+ if ($video_ogg != "") {
+ $html .= '<source src="'.$video_ogg.'" type=\'video/ogg; codecs="theora, vorbis"\' />';
+ }
+
+ if ($flash != "") {
+ $html .= '<object width="'.$width.'" height="'.$height.'" type="application/x-shockwave-flash" data="'.JURI::base().'plugins/content/pb_mediael/flashmediaelement.swf">
+ <param name="movie" value="'.JURI::base().'plugins/content/pb_mediael/flashmediaelement.swf" />';
+ if ($wmode != 'default') {
+ $html .= '<param name="wmode" value="'.$wmode.'" />';
+ }
+
+ $html .= '<param name="flashvars" value="controls=true&poster='.$uri_image.$image.'&file='.$uri_flash.$flash.'" />';
+
+ if ($image_visibility == "true" || $image_visibility == "1") {
+ $html .= '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" alt="Poster Image" title="No video playback capabilities." />';
+ }
+
+ $html .= '</object>';
+ }
+
+ $html .='<p class="PbMediaEl"><strong>If you cannot see the media above - download here: </strong>';
+
+ if ($audio_mp3 != "") {
+ $html .= '<a href="'.$audio_mp3.'">MP3</a> ';
+ }
+
+ if ($video_mp4 != "") {
+ $html .= '<a href="'.$video_mp4.'">MP4</a> ';
+ }
+
+ if ($video_webm != "") {
+ $html .= '<a href="'.$video_webm.'">WebM</a> ';
+ }
+
+ if ($video_ogg != "") {
+ $html .= '<a href="'.$video_ogg.'">Ogg</a><br>';
+ }
+
+ $html .= '</p>
+ </div>';
+
+ $html .= '</'.$media.'>';
+
+
+ return $html;
+
+}
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<install version="1.5" type="plugin" method="upgrade" group="content">
+ <name>Content - pb:MediaEl</name>
+ <author>Phil Banks</author>
+ <creationDate>October 2011</creationDate>
+ <copyright>(C) 2011 Phil Banks. All rights reserved.</copyright>
+ <license>GNU/GPL http://www.gnu.org/copyleft/gpl.html</license>
+ <authorEmail>pb@mrc-lmb.cam.ac.uk</authorEmail>
+ <authorUrl>www2.mrc-lmb.cam.ac.uk</authorUrl>
+ <version>0.1</version>
+ <description>PLUGIN DESC</description>
+ <files>
+ <filename plugin="pb_mediael">pb_mediael.php</filename>
+ <folder>pb_mediael</folder>
+ </files>
+ <languages>
+ <language tag="en-GB">language/en-GB.plg_content_pb_mediael.ini</language>
+ </languages>
+ <params>
+ <param name="media" type="list" default="video" label="LABEL MEDIA" description="DESC MEDIA">
+ <option value="video">video</option>
+ <option value="audio">audio</option>
+ </param>
+ <param name="@spacer" type="spacer" default="DEFAULT AUDIO PARAMETER" label="" description="" />
+ <param name="audio_mp3" type="text" default="" label="LABEL AUDIO MP3" description="DESC AUDIO MP3" size="40" />
+ <param name="@spacer" type="spacer" default="DEFAULT VIDEO PARAMETER" label="" description="" />
+ <param name="video_mp4" type="text" default="" label="LABEL VIDEO MP4" description="DESC VIDEO MP4" size="40" />
+ <param name="video_webm" type="text" default="" label="LABEL VIDEO WEBM" description="DESC VIDEO WEBM" size="40" />
+ <param name="video_ogg" type="text" default="" label="LABEL VIDEO OGG" description="DESC VIDEO OGG" size="40" />
+ <param name="flash" type="text" default="" label="LABEL FLASH" description="DESC FLASH" size="40" />
+ <param name="image" type="text" default="" label="LABEL IMAGE" description="DESC IMAGE" size="40" />
+ <param name="image_visibility" type="radio" default="1" label="LABEL IMAGE VISIBILITY" description="DESC IMAGE VISIBILITY">
+ <option value="0">off</option>
+ <option value="1">on</option>
+ </param>
+ <param name="@spacer" type="spacer" default="DEFAULT PLAYER PARAMETER" label="" description="" />
+ <param name="width" type="text" default="640" label="LABEL WIDTH" description="DESC WIDTH" size="3" />
+ <param name="height" type="text" default="480" label="LABEL HEIGHT" description="DESC HEIGHT" size="3" />
+ <param name="autoplay" type="radio" default="0" label="LABEL AUTOPLAY" description="DESC AUTOPLAY">
+ <option value="0">off</option>
+ <option value="1">on</option>
+ </param>
+ <param name="preload" type="radio" default="1" label="LABEL PRELOAD" description="DESC PRELOAD">
+ <option value="0">off</option>
+ <option value="1">on</option>
+ </param>
+ <param name="loop" type="radio" default="0" label="LABEL LOOP" description="DESC LOOP">
+ <option value="0">off</option>
+ <option value="1">on</option>
+ </param>
+ <param name="defaultVolume" type="text" default="0.85" label="LABEL DEFAULT VOLUME" description="DESC DEFAULT VOLUME" size="3" />
+ <param name="wmode" type="list" default="default" label="LABEL WMODE" description="DESC WMODE">
+ <option value="default">default</option>
+ <option value="opaque">opaque</option>
+ <option value="transparent">transparent</option>
+ </param>
+ </params>
+</install>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 6782412

Please sign in to comment.