MyBB Community Forums

Full Version: INSERT AUDIO/VIDEO
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to have a feature available, probably only for MODS and above. I would like them to have a button that allows them to upload and insert audio/video-clips. This is important to me as we collect money for our organization through annual reunions and we want to hype up these events as much as possible to boost the registrations and what would be better than to show videos from previous reunions....I think PHP2 has these mod available so maybe there would be even a way to port it?

Cheers,
Kimmo
EDIT: I found a better way than the previous one. Smile
Open functions_post.php and find
	$message = preg_replace("#\\[email=(.*?)\\](.*?)\\[/email\\]#i", "<a href=\\"mailto:$1\\">$2</a>", $message);
After, add:
	$message = preg_replace("#\\[media=([0-9]{1,3})x([0-9]{1,3})\\]([a-z]+?://){1}(.+?)\\[/media\\]#i", "<EMBED src=\\"$3$4\\" AUTOSTART=\\"false\\" WIDTH=\\"$1\\" HEIGHT=\\"$2\\"></EMBED>", $message);
	$message = preg_replace("#\\[media\\]([a-z]+?://){1}(.+?)\\[/media\\]#i", "<EMBED src=\\"$1$2\\" AUTOSTART=\\"false\\"></EMBED>", $message);
	$message = preg_replace("#\\[media=([a-z]+?://){1}(.+?)\\]#i", "<EMBED src=\\"$1$2\\" AUTOSTART=\\"false\\"></EMBED>", $message);
Now you'll have new tags.
[media]http://someurl/afile.mp3[/media]
[media=http://someurl/afile.mp3]
[media=320x240]http://someurl/afile.mp3[/media]

I might want to change more stuff to add a little button next to the hyperlink button, and a script to autocomplete urls without http:// or ftp://
Looks good Smile
this doesn't play wav Sad
For the button stuff:

Open:
Codebuttons.js

Search:
function insertHyperlink() {
	var url = prompt("Please enter the URL of the website.", "http://");
	if(url) {
		var urltitle = prompt("If you wish to, you may also insert a title to be shown instead of the URL.", "");
		if(urltitle) {
			doInsert("[url="+url+"]"+urltitle+"[/url]", "", false);
		} else {
			doInsert("[url]"+url+"[/url]", "", false);
		}
	} else {
		alert("Error!\\n\\nYou did not enter a URL for the website. Please try again.");
	}
}

After add:
function insertMedia() {
	var media = prompt("Please enter the URL of the media file.", "http://");
	if(media) {
		var mediasize = prompt("If you wish to, you may also insert a size for the Media.", "WIDTHxHEIGHT");
		if(mediasize) {
			doInsert("[media="+mediasize+"]"+media+"[/media]", "", false);
		} else {
			doInsert("[media]"+media+"[media]", "", false);
		}
	} else {
		alert("Error!\\n\\nYou did not enter a media file for the website. Please try again.");
	}
}

Search:
	} else if(myCode == "email") {
		insertEmail();

After add:
	} else if(myCode == "media") {
		insertMedia();

Goto:
ACP -> Templates -> Modify / Delete -> *Template Set Name* -> codebuttons

FIND IN TEMPLATE:
<img name="url" src="./images/codebuttons/url.gif" onclick="insertCode('url')" class="toolbar_normal" onMouseOver="toolbarHover('url')" onMouseOut="toolbarUnHover('url')" onMouseDown="toolbarMouseDown('url')" alt="Insert Hyperlink">

After Add:
<img name="media" src="./images/codebuttons/media.gif" onclick="insertCode('media')" class="toolbar_normal" onMouseOver="toolbarHover('media')" onMouseOut="toolbarUnHover('media')" onMouseDown="toolbarMouseDown('media')" alt="Insert Media">

Action:
Upload the atachment to "images/codebuttons"
Thx for doing this Da Dude Smile
EDIT: Maybe instead of
if(mediasize) {
doInsert("[media="+mediasize+"]"+media+"[/media]", "", false);
} else {
doInsert("[media]"+media+"[media]", "", false);
}
use this:
if(!mediasize || mediasize == "WIDTHxHEIGHT") {
doInsert("[media]"+media+"[/media]", "", false);
} else {
doInsert("[media="+mediasize+"]"+media+"[/media]", "", false);
}
because if people don't want to use dimensions, they may not remove "WIDTHxHEIGHT" and just skip it, but that would give [media=WIDTHxHEIGHT]file[/media] and thus the tag wont work.
but this plays only mp3?
well, I have only tested it with mp3, mpg, mpeg, avi, wav, wmv, mov and mid. Avi doesn't work with me in FF because I don't have a correct plugin. In IE they all work. If you're using FF make sure you have the correct plugins. And you must have the correct codecs if a file is encoded. The best way to use the tags is the [media=***x***]url[/media] way.
Smethead,

After I edit the functions_post.php I did not find: $message = preg_replace("#\\[email=(.*?)\\](.*?)\\[/email\\]#i", "<a href=\\"mailto:$1\\">$2</a>", $message);

Help

(2005-01-28, 03:17 PM)Smethead Wrote: [ -> ]EDIT: I found a better way than the previous one. Smile
Open functions_post.php and find
	$message = preg_replace("#\\[email=(.*?)\\](.*?)\\[/email\\]#i", "<a href=\\"mailto:$1\\">$2</a>", $message);
After, add:
	$message = preg_replace("#\\[media=([0-9]{1,3})x([0-9]{1,3})\\]([a-z]+?://){1}(.+?)\\[/media\\]#i", "<EMBED src=\\"$3$4\\" AUTOSTART=\\"false\\" WIDTH=\\"$1\\" HEIGHT=\\"$2\\"></EMBED>", $message);
	$message = preg_replace("#\\[media\\]([a-z]+?://){1}(.+?)\\[/media\\]#i", "<EMBED src=\\"$1$2\\" AUTOSTART=\\"false\\"></EMBED>", $message);
	$message = preg_replace("#\\[media=([a-z]+?://){1}(.+?)\\]#i", "<EMBED src=\\"$1$2\\" AUTOSTART=\\"false\\"></EMBED>", $message);
Now you'll have new tags.
[media]http://someurl/afile.mp3[/media]
[media=http://someurl/afile.mp3]
[media=320x240]http://someurl/afile.mp3[/media]

I might want to change more stuff to add a little button next to the hyperlink button, and a script to autocomplete urls without http:// or ftp://