Help:Music Stream
from WikiMusicGuide, the free music guide. Your music wiki.
Contents |
Introduction
MusicStream is an extension that allows you to link an .mp3 or .ogg file in any MediaWiki based website.
About
MusicStream is a media extension that allows anyone who has an .mp3 or .ogg file to stream/play it using the WikiMusicGuide Free Streaming Service. You can play music without waiting for the download to complete or installing complicated web media players. Linking your .mp3 or .ogg file on your page will let your browser download the song to either save it on your disk or open it in your preferred media player.
This simple but useful application that WikiMusicGuide offers will surely give an enjoyable interactive experience to its visitors, contributors, and all independent artists and bands in the music industry.
Installation
If you have an .mp3 or .ogg file and you want to share it with WikiMusicGuide and others, please refer to the wiki text below.
Syntax
<musicstream> url=http://yourdomain.com/song.mp3 label=Song </musicstream>
URL is the address of the .mp3 or .ogg file.
Label is the title of the .mp3 or .ogg file.
Demo
Code
<?php
# Using this extension will allow you to stream your music. It takes a mp3 or ogg file
# as input and outputs a m3u streaming file.
#
# To activate the extension, include the following at the end of your LocalSettings.php
# require_once("extensions/musicstream.php");
#
# Syntax:
# <musicstream>
# url=http://yourdomain.com/song.mp3
# label=Song
# </musicstream>
$wgExtensionFunctions[] = "wfMusicStream";
function wfMusicStream() {
global $wgParser;
$wgParser->setHook( "musicstream", "renderMusicStream" );
}
function renderMusicStream($input) {
getOption($url,$input,'url');
getOption($text,$input,'label');
$output = "<a href='http://www.wikimusicguide.com/stream.php?url=$url'>$text</a> <img src='http://www.wikimusicguide.com/images/musicstream.gif' border='1' />";
return $output;
}
function getOption(&$value,&$input,$name,$isNumber=false) {
if(preg_match("/^\s*$name\s*=\s*(.*)/mi",$input,$matches)) {
if($isNumber) {
$value=intval($matches[1]);
} else {
$value=htmlspecialchars($matches[1]);
}
}
}
?>

