Rene (Diskussion | Beiträge) |
Rene (Diskussion | Beiträge) Version 0.3 - Mehr Parameter |
||
| Zeile 36: | Zeile 36: | ||
| <playmp3 skin="silk_button">Captain Samantha Carter.mp3</playmp3> | | <playmp3 skin="silk_button">Captain Samantha Carter.mp3</playmp3> | ||
|- | |- | ||
! position_blue !! wooden !! stuttgart !! | ! position_blue !! wooden !! stuttgart !! standard<br />Default Skin | ||
|- | |- | ||
| <playmp3 skin="position_blue">Captain Samantha Carter.mp3</playmp3> | | <playmp3 skin="position_blue">Captain Samantha Carter.mp3</playmp3> | ||
| Zeile 43: | Zeile 43: | ||
| <playmp3 skin="standard">Captain Samantha Carter.mp3</playmp3> | | <playmp3 skin="standard">Captain Samantha Carter.mp3</playmp3> | ||
|} | |} | ||
==Probleme, Ideen== | ==Probleme, Ideen== | ||
* | * Playlisten werden bis auf weiteres nicht unterstützt. | ||
* Nicht alle möglichen Fehler werden behandelt. Nicht vorhandene Dateien werden einfach ignoriert. | * Nicht alle möglichen Fehler werden behandelt. Nicht vorhandene Dateien werden einfach ignoriert. | ||
* Variablen <nowiki>{{{1}}}</nowiki> werden nicht ersetzt. In Vorlagen sollte die Erweiterung daher so benutzt werden: <nowiki>{{#tag:playmp3|Datei|Parameter1|Parameter2...}}</nowiki> | * Variablen <nowiki>{{{1}}}</nowiki> werden nicht ersetzt. In Vorlagen sollte die Erweiterung daher so benutzt werden: <nowiki>{{#tag:playmp3|Datei|Parameter1|Parameter2...}}</nowiki> | ||
| Zeile 82: | Zeile 80: | ||
* <playmp3 skin="name" autostart repeat shuffle>mp3</playmp3> | * <playmp3 skin="name" autostart repeat shuffle>mp3</playmp3> | ||
* | * | ||
* Parameters : | |||
* skin="name" - define skin (look EMFF for skin names) | |||
* autostart - player will start after page is loaded | |||
* autoload - load the first file after page is loaded | |||
* repeat - play loop | |||
* shuffle - mix the playlist | |||
* shortcuts - enable key shortcuts | |||
* volume=0..100 - initial volume | |||
* balance=-100..100 - initial balance | |||
* groupname="name" - name of the group | |||
* | |||
* Example: | * Example: | ||
* <playmp3>music.mp3</playmp3> | * <playmp3>music.mp3,music1.mp4</playmp3> | ||
*/ | */ | ||
| Zeile 92: | Zeile 101: | ||
'author' => 'René Raule', | 'author' => 'René Raule', | ||
'url' => 'http://www.stargate-wiki.de/index.php/Benutzer:Rene/PlayMP3', | 'url' => 'http://www.stargate-wiki.de/index.php/Benutzer:Rene/PlayMP3', | ||
'version' => 'v0. | 'version' => 'v0.3' | ||
); | ); | ||
// Parameters | // Parameters | ||
define("SKIN"," | define("SKIN","standard"); | ||
// Init | // Init | ||
| Zeile 107: | Zeile 114: | ||
// The callback function for converting the input text to HTML output | // The callback function for converting the input text to HTML output | ||
function renderPlayMP3($input, $args) { | function renderPlayMP3($input, $args, &$parser) { | ||
global $wgScriptPath; | |||
// Place where EMFF Player is stored | |||
$player_path = '/extensions/EMFF/'; //dirname(__FILE__).'/'; | |||
// Parameters for the skins | |||
$player= array( | $player= array( | ||
'easy_glaze'=>array('name'=>'emff_easy_glaze.swf','width'=>32,'height'=>32), | 'easy_glaze'=>array('name'=>'emff_easy_glaze.swf','width'=>32,'height'=>32), | ||
| Zeile 121: | Zeile 131: | ||
'silk'=>array('name'=>'emff_silk.swf','width'=>84,'height'=>32), | 'silk'=>array('name'=>'emff_silk.swf','width'=>84,'height'=>32), | ||
'wooden'=>array('name'=>'emff_wooden.swf','width'=>120,'height'=>60), | 'wooden'=>array('name'=>'emff_wooden.swf','width'=>120,'height'=>60), | ||
'standard'=>array('name'=>'emff_standard.swf','width'=>110,'height'=>34), | |||
'stuttgart'=>array('name'=>'emff_stuttgart.swf','width'=>140,'height'=>30) | 'stuttgart'=>array('name'=>'emff_stuttgart.swf','width'=>140,'height'=>30) | ||
); | ); | ||
$ | $bool_para = array('autostart','repeat','shuffle','autoload','shortcuts'); | ||
$text_para = array('groupname'); | |||
$digit_para = array('volume'=>array(0,100),'balance'=>array(-100,100)); | |||
$add = '&'; | $add = '&'; | ||
$ | // player parameters | ||
$ | $player_para = ''; | ||
foreach($bool_para as $value) { | |||
if(isset($args[$value])) { | |||
$player_para .= $add.$value.'=yes'; | |||
} | |||
} | |||
foreach($text_para as $value) { | |||
if(isset($args[$value])) { | |||
$player_para .= $add.$value.'='.$args[$value]; | |||
} | |||
} | |||
foreach($digit_para as $value => $minmax) { | |||
if(isset($args[$value])) { | |||
$digit = $args[$value]; | |||
if(is_int($digit)) { | |||
if($digit >= $minmax[0] and $digit <= $minmax[1]) { | |||
$player_para .= $add.$value.'='.$args[$value]; | |||
} | |||
} | |||
} | |||
} | |||
// Use default skin if no skin defined | // Use default skin if no skin defined | ||
if(!isset($args['skin'])) { | if(!isset($args['skin'])) { | ||
| Zeile 150: | Zeile 174: | ||
$player_width = $player[$args['skin']]['width']; | $player_width = $player[$args['skin']]['width']; | ||
$player_height = $player[$args['skin']]['height']; | $player_height = $player[$args['skin']]['height']; | ||
// | |||
$ | // Get files as array | ||
foreach($ | $files = explode(",", htmlspecialchars($input)); | ||
// Create list of files | |||
$add = ''; | |||
foreach($files as $key => $value) { | |||
$play_name .= $add . getMP3Title($value); | |||
$add = ','; | |||
} | } | ||
// generate code | // generate code | ||
$output = '<object type="application/x-shockwave-flash" data="'; | $output = '<object type="application/x-shockwave-flash" data="'; | ||
| Zeile 173: | Zeile 201: | ||
// Get Wiki URL - TODO: does not work with parametrs {{{}}} | // Get Wiki URL - TODO: does not work with parametrs {{{}}} | ||
function getMP3Title($file) { | function getMP3Title($file) { | ||
if(!$title = Title::makeTitleSafe("Image",$file)) { | if(!$title = Title::makeTitleSafe("Image",$file)) { | ||
return ''; | return ''; | ||