Rene (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Rene (Diskussion | Beiträge) |
||
| (5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
==Beschreibung== | ==Beschreibung== | ||
PlayMP3 ermöglicht das Einbinden des [http://emff.sourceforge.net/ EMFF Players]. Mit diesem Flash Player ist es möglich MP3 Audiodateien so in Mediawiki Projekte einzubinden das die Dateien ohne externen Player abgespielt werden können. | PlayMP3 ermöglicht das Einbinden des [http://emff.sourceforge.net/ EMFF Players]. Mit diesem Flash Player ist es möglich MP3 Audiodateien so in Mediawiki Projekte einzubinden das die Dateien ohne externen Player abgespielt werden können. | ||
Ist keine Datei angegeben bzw. die angegebenen Dateien existieren nicht so wird der Player nicht angezeigt. Dieses Verhalten kann mit dem Parameter show verändert werden. | |||
==Einsatz== | ==Einsatz== | ||
===Befehl=== | ===Befehl=== | ||
| Zeile 10: | Zeile 12: | ||
===Parameter=== | ===Parameter=== | ||
* autostart - Der Player startet automatisch mit der ersten Datei | * autostart - Der Player startet automatisch mit der ersten Datei | ||
* autoload - Die erste Datei wird sofort eingelsen | |||
* repeat - Der Player wiederholt die Dateien | * repeat - Der Player wiederholt die Dateien | ||
* shuffle - Die Dateien werden in zufälliger Reihenfolge abgespielt | * shuffle - Die Dateien werden in zufälliger Reihenfolge abgespielt | ||
* show - Der Player wird auch angezeigt wenn keine Dateien angegeben bzw. vorhanden sind | |||
* noerror - Es wird keine Fehlermeldung für nicht existierende Dateien ausgegeben. | |||
* groupname="name" - Ordnet den Player einer Gruppe zu. Nur ein Player einer Gruppe kann aktiv sein | |||
* volume=0..100 - Anfangs Lautstärke | |||
* balance=-100..100 - Rechts / Links - Verteilung des Tons | |||
* skin="name" - Auswahl des Playersskins. Mögliche Werte: | * skin="name" - Auswahl des Playersskins. Mögliche Werte: | ||
:easy_glaze, easy_glaze_small,position_blue,old,old_noborder,lila,lila_info,silk_button,silk,wooden,stuttgart | :easy_glaze, easy_glaze_small, position_blue, old, old_noborder, lila, lila_info, silk_button, silk, wooden, stuttgart, standard | ||
<pre><nowiki><playmp3 skin="name" autostart repeat shuffle>datei1.mp3,datei2.mp3</playmp3></nowiki></pre> | <pre><nowiki><playmp3 skin="name" autostart repeat shuffle>datei1.mp3,datei2.mp3</playmp3></nowiki></pre> | ||
===Skins Übersicht=== | ===Skins Übersicht=== | ||
{| width="100%" class="wikitable" | {| width="100%" class="wikitable" | ||
| Zeile 24: | Zeile 33: | ||
| <playmp3 skin="old_noborder">Captain Samantha Carter.mp3</playmp3> | | <playmp3 skin="old_noborder">Captain Samantha Carter.mp3</playmp3> | ||
|- | |- | ||
! lila !! lila_info !! silk<br />[[Vorlage: | ! lila !! lila_info !! silk<br />[[Vorlage:Audio]] !! silk_button<br />[[Vorlage:Audio]] | ||
|- | |- | ||
| <playmp3 skin="lila">Captain Samantha Carter.mp3</playmp3> | | <playmp3 skin="lila">Captain Samantha Carter.mp3</playmp3> | ||
| Zeile 31: | Zeile 40: | ||
| <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 38: | Zeile 47: | ||
| <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 alle möglichen Fehler werden behandelt. | ||
* 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(en)|Parameter1|Parameter2...}}</nowiki> | ||
* Probleme wenn <nowiki></playmp3></nowiki> fehlt | * Probleme wenn <nowiki></playmp3></nowiki> fehlt | ||
| Zeile 78: | Zeile 84: | ||
* <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 | |||
* show - show player if playlist is empty | |||
* noerror - do not show error message on missing file | |||
* | |||
* Example: | * Example: | ||
* <playmp3>music.mp3</playmp3> | * <playmp3>music.mp3,music1.mp3</playmp3> | ||
* | |||
*/ | */ | ||
| Zeile 85: | Zeile 105: | ||
$wgExtensionCredits['parserhook'][] = array( | $wgExtensionCredits['parserhook'][] = array( | ||
'name' => 'PlayMP3', | 'name' => 'PlayMP3', | ||
'description' => 'Plays mp3-files | 'description' => 'Plays mp3-files with embedded [http://emff.sourceforge.net Flashplayer EMFF]', | ||
'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.32' | ||
); | ); | ||
// | //Default Skin. Used if no skin defined | ||
define("SKIN"," | define("SKIN","standard"); | ||
define(" | define("PLAYERDIR",'/extensions/EMFF/'); // dirname(__FILE__).'/'; - better but did not work | ||
// | // Add function to MediaWiki | ||
function wfPlayMP3() { | function wfPlayMP3() { | ||
global $wgParser; | global $wgParser; | ||
| Zeile 103: | Zeile 122: | ||
// 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 = PLAYERDIR; | |||
// 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 117: | Zeile 139: | ||
'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)); | |||
$command_para = array('show','noerror'); | |||
$error_out = ''; | |||
$add = '&'; | $add = '&'; | ||
$ | // Check for commands | ||
$ | foreach($command_para as $value) { | ||
${$value} = isset($args[$value]); | |||
} | |||
// Check for tag 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 142: | Zeile 184: | ||
$args['skin'] = SKIN; | $args['skin'] = SKIN; | ||
} | } | ||
// | // Copy skin parameters | ||
$player_name = $player[$args['skin']]['name']; | $player_name = $player[$args['skin']]['name']; | ||
$player_width = $player[$args['skin']]['width']; | $player_width = $player[$args['skin']]['width']; | ||
$player_height = $player[$args['skin']]['height']; | $player_height = $player[$args['skin']]['height']; | ||
// player | |||
$ | // Get files as array | ||
foreach($ | $files = explode(",", htmlspecialchars($input)); | ||
if( | |||
$ | // Create list of files for the player | ||
$fpath = ''; $comma = ''; | |||
foreach($files as $value) { | |||
if($fpath = getMP3Title($value)) { | |||
$play_name .= $comma . $fpath; | |||
$comma = ','; | |||
} else { | |||
if(!$noerror) { | |||
$error_out = '<div class="noprint error">Datei nicht gefunden: '.$value.'</div>'; | |||
} | |||
} | } | ||
} | } | ||
// generate code | // generate code | ||
$output | $output = $error_out; | ||
if(strlen($play_name) > 0 or isset($args['show'])) { | |||
$output .= '<object type="application/x-shockwave-flash" data="'; | |||
$output .= $player_path.$player_name.'" width="'; | |||
$output .= $player_width.'" height="'; | |||
$output .= $player_height.'">'; | |||
$output .= '<param name="movie" value="'; | |||
$output .= $player_path.$player_name.'" />'; | |||
$output .= '<param name="FlashVars" value="src='; | |||
$output .= $play_name.$player_para.'" />'; | |||
$output .= "</object>\n"; | |||
} | |||
return $output; | return $output; | ||
} | } | ||
// Get Wiki URL - TODO: does not work with parametrs {{{}}} | // Get Wiki URL - TODO: does not work with parametrs like {{{1}}} | ||
function getMP3Title($file) { | function getMP3Title($file) { | ||
if(!$ | |||
return | if(!$fh = wfFindFile($file)) { | ||
return false; | |||
} else { | |||
return Image::imageUrl($file); | |||
} | } | ||
} | } | ||
</nowiki></pre> | </nowiki></pre> | ||