YouTube forum code

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/65477?pagenum=1
04 November 2025, 21:41

Topic


lucapan
YouTube forum code
29 August 2007, 11:05


I wrote a little mod to use a brand new youtube forum code, like:

[youtube]http://www.youtube.com/watch?v=gJmX1z1NY2c[/youtube]
Here is the code:
http://www.lucapanella.com/downloads/SnitzYouTubeForumCodeMod.zip
<

 

Replies ...


JJenson
29 August 2007, 11:12


That would be great but your text file isn't showing me the whole code? bigsmile
But I like the idea.<
Podge
29 August 2007, 12:27


Marcel did a mod for this ages ago.

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=60387

This is the updated function I'm using for the new YouTube code. It actually works for all three types of YouTube code.
Code:
function EmbedTubeVideoT(YTPermalink, width, height, autostart) {   
if(YTPermalink == null || YTPermalink == "illegal"){
//Nope, we can't. document.writeln(" error: illegal use of video tag! ");
}else{
//Add the code to the document. genCode = YTPermalink.replace(new RegExp(/http\:\/\/www\.youtube\.com\/\?v\=/g), "");
genCode = genCode.replace(new RegExp(/http\:\/\/www\.youtube\.com\/watch\?v\=/g), "");
genCode = genCode.replace(new RegExp(/http\:\/\/www\.youtube\.com\/v\//g), "");
//document.writeln("gencode-"+genCode);
document.writeln('<object width="' + width + '" height="' + height + '"><param name="movie" value="http://www.youtube.com/v/' + genCode + '"><param name="wmode" value="transparent" /></param>');
document.writeln('<embed src="http://www.youtube.com/v/' + genCode + '" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed></object>');
document.writeln('<br><center>Hosted by <a href ="' + YTPermalink + '" target="_blank">YouTube</a></center>');
}
}
<
lucapan
29 August 2007, 14:13


Originally posted by Podge
Marcel did a mod for this ages ago.

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=60387

Marcel's mod is powerfull! [^]
My mod is simpler, it is for youtube videos only and doesn't involve javascripts. I did't want to embed other type of videos, so i made my own.
I thought to post my mod to contribute in this great community. If you like it, use it. Otherwise use Marcel's one. wink <
lucapan
29 August 2007, 14:15


Originally posted by JJenson
That would be great but your text file isn't showing me the whole code? bigsmile

It shows only the piece of code to modify... is it not enough? smile Maybe i missed something?? blackeye<
JJenson
29 August 2007, 14:31


this is all I see.
I wrote this mod for Snitz Forum to use a simple forum code like: [youtube]gJmX1z1NY2c[/youtube] to embed a youtube video in the forum. Modify "inc_func_common.asp" adding the following function at the end of the file, before the<
AnonJr
29 August 2007, 14:40


JJenson, do a "View Source" or Right-click on the link and "Save Target As..." - his web server is processing the page instead of displaying it as a .txt file. Doing a "View Source" showed this:

Code:
I wrote this mod for Snitz Forum to use a simple forum code like:

[youtube]gJmX1z1NY2c[/youtube]
to embed a youtube video in the forum.
Modify "inc_func_common.asp" adding the following function at the end of the file, before the <script> section:

____________________________________

<%
Function ReplaceYouTubeTags(fString)
Dim oTag, cTag
Dim roTag1, rcTag1, roTag2, rcTag2
Dim oTagPos, cTagPos
Dim nTagPos
Dim counter1, counter2
Dim strCodeText
Dim Tagcount
Dim strTempString, strResultString
TagCount = 1
Dim CodeTags(1,2,3)
Dim strArray, strArray2

CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""425"" height=""353""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = """></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = """ type=""application/x-shockwave-flash"" wmode=""transparent"" width=""425"" height=""353""></embed></object>"

strResultString = ""
strTempString = fString

for counter1 = 1 to TagCount

oTag = CodeTags(counter1,1,1)
roTag1 = CodeTags(counter1,1,2)
roTag2 = CodeTags(counter1,1,3)
cTag = CodeTags(counter1,2,1)
rcTag1 = CodeTags(counter1,2,2)
rcTag2 = CodeTags(counter1,2,3)
oTagPos = InStr(1, strTempString, oTag, 1)
cTagPos = InStr(1, strTempString, cTag, 1)

if (oTagpos > 0) and (cTagPos > 0) then
strArray = Split(strTempString, oTag, -1, 1)
for counter2 = 0 to Ubound(strArray)
if (Instr(1, strArray(counter2), cTag) > 0) then
strArray2 = split(strArray(counter2), cTag, -1, 1)
strCodeText = trim(strArray2(0))
strCodeText = replace(strCodeText, """", " ") ' ## filter out "
'## Added to exclude Javascript and other potentially hazardous characters
strCodeText = replace(strCodeText, "&", " ", 1, -1, 1) ' ## filter out &
strCodeText = replace(strCodeText, "#", " ", 1, -1, 1) ' ## filter out #
strCodeText = replace(strCodeText, ";", " ", 1, -1, 1) ' ## filter out ;
strCodeText = replace(strCodeText, "+", " ", 1, -1, 1) ' ## filter out +
strCodeText = replace(strCodeText, "(", " ", 1, -1, 1) ' ## filter out (
strCodeText = replace(strCodeText, ")", " ", 1, -1, 1) ' ## filter out )
strCodeText = replace(strCodeText, "[", " ", 1, -1, 1) ' ## filter out [
strCodeText = replace(strCodeText, "]", " ", 1, -1, 1) ' ## filter out ] strCodeText = replace(strCodeText, "=", " ", 1, -1, 1) ' ## filter out =
strCodeText = replace(strCodeText, "*", " ", 1, -1, 1) ' ## filter out *
strCodeText = replace(strCodeText, "'", " ", 1, -1, 1) ' ## filter out '
strCodeText = replace(strCodeText, vbTab, " ", 1, -1, 1) ' ## filter out Tabs
strCodeText = replace(strCodeText, "view-source", " ", 1, -1, 1) ' ## filter out view-source
strCodeText = replace(strCodeText, "javascript", " ", 1, -1, 1) ' ## filter out javascript
strCodeText = replace(strCodeText, "jscript", " ", 1, -1, 1) ' ## filter out jscript
strCodeText = replace(strCodeText, "vbscript", " ", 1, -1, 1) ' ## filter out vbscript
strCodeText = replace(strCodeText, "mailto", " ", 1, -1, 1) ' ## filter out mailto
'## End Added
strCodeText = replace(strCodeText, "<", " ") ' ## filter out <
strCodeText = replace(strCodeText, ">", " ") ' ## filter out >
strCodeText = replace(strCodeText, "<br />", vbNewLine)
strResultString = strResultString & roTag1 & strCodeText & rcTag1 & roTag2 & strCodeText & rcTag2 & strArray2(1)
else
strResultString = strResultString & strArray(counter2)
end if
next

strTempString = strResultString
strResultString = ""
end if
next

ReplaceYouTubeTags = strTempString
end function
%>
____________________________________

At line 239 change:

____________________________________

if strAllowForumCode = "1" then
fString = extratags(fString)
end if
____________________________________

to
____________________________________

if strAllowForumCode = "1" then
fString = extratags(fString)
fString = ReplaceYouTubeTags(fString)
end if
____________________________________

Now you can use the brand new forum code!
If you want, you can modify "pop_forum_code.asp",
adding the following code before if (strIMGInPosts = "1"), at line 158.
____________________________________

Response.Write "<p><b>YouTube:</b> Enclose the video hash code with [youtube] and [/youtube] .  <i>Example:</i> Here is a video: <b>[youtube]</b>gJmX1z1NY2c<b>[/youtube]</b></p>" & vbNewLine
____________________________________

Ciao! Luca Panella

29-Aug-2007
<
JJenson
29 August 2007, 14:48


Ahh didn't even think about the view source. At work and paying attention to my jobs here sort of I just want to stop working today. tongue I am having one of those weeks.<
Podge
29 August 2007, 18:00


Its because of the <script> tag.<
leatherlips
29 August 2007, 21:44


I just tried this on my forum and it works great! It would be nice to have a YouTube button to automatically add the YouTube tags...<
lucapan
30 August 2007, 04:32


Originally posted by Podge
Its because of the <script> tag.

Right. I put the text file in a zip archive, so there is no problem about that.<
lucapan
30 August 2007, 05:03


Originally posted by leatherlips
It would be nice to have a YouTube button to automatically add the YouTube tags...

Done! There's a new link in the first post! wink<
leatherlips
30 August 2007, 15:37


Looking good! Thanks for adding the button. I have one more request... blush
Is it possible to allow members to insert the entire YouTube URL? It seems this mod requires members to only insert the section of the URL that appears after the equal sign (=). I'm afraid this will confuse some members. They'll simply insert the entire URL which will not work. Or is it possible to have this MOD automatically strip out everything in the URL expect for the unique code?<
AnonJr
30 August 2007, 15:51


I know Marcel was working on something like that... I'm not sure if he finished. I think the code he was playing with is over at oxle.com though, as he was planning to post it here to when he was done.... but this is mostly speculation on my part as I am over-tired and under-caffinated.<
leatherlips
30 August 2007, 16:32


Hmmm... Doing some more testing, it seems that the YouTube button will not work on a Mac using Safari. All of the other buttons do work. Any ideas?<
phy1729
30 August 2007, 17:04


Could you give a link to where it's implemented?<
leatherlips
30 August 2007, 19:45


I got it to work with Safari. I did have the YouTube function at the very bottom of inc_code.js. I put it in a different spot higher up, after the strike function, and it worked. I also changed it a little bit to make the directions more clear for the users. Here is what I did:

Code:
//YouTube MOD below

function youtube() {
var text = getText();
if (helpstat){
alert("YouTube tag inserts a video hosted by YouTube into the post.\n\nExample: [youtube]gJmX1z1NY2c[/youtube]\n\nDo NOT insert the entire YouTube link. ONLY insert the code in the URL that appears after the equals sign (=).\n\nExample: DO NOT enter http://www.youtube.com/watch?v=aWZ8xlc2-0s. Instead look for what comes after the = sign, which in this case would be aWZ8xlc2-0s.");
} else if (basic) {
AddTxt="[youtube]" + text + "[/youtube]";
AddText(AddTxt);
} else {
if (text) {
txt=prompt("Only insert the section of the URL that appears after the equals sign (=).",text);
} else {
txt=prompt("Enter the YouTube identification code for your video.","Only insert the section of the URL that appears after the equals sign (=).");
}
if(txt!=null) {
AddTxt="[youtube]"+txt+"[/youtube]";
AddText(AddTxt);
}
}
}

//YouTube Mod above
<
MarcelG
31 August 2007, 04:32


Originally posted by AnonJr
I know Marcel was working on something like that... I'm not sure if he finished.
Yep, I'm still working on it. The current *yet unreleased* code allows posting videos by means of the entire YouTube code, YouTube permaurl and DailyMotion code inbetween de [video][/video] brackets.
Still trying to find the time to release it as a mod, however the code is all online already: http://oxle.com/source.asp?page=inc_func_common.asp (demo/demo)<
lucapan
31 August 2007, 05:24


Is it possible to allow members to insert the entire YouTube URL?

I agree it would be fine (and simpler for users). I will try to do that as soon as possibile (maybe in the weekend).
Thanks for the support.
<
Webbo
31 August 2007, 19:05


Well, so far so good and working well

I must agree though if the full URL could be added it would make it a lot more user friendly<
lucapan
01 September 2007, 10:13


Originally posted by Webbo

I must agree though if the full URL could be added it would make it a lot more user friendly

Done! See the first post (there is only one zip file now).
Bye.<
modifichicci
01 September 2007, 10:50


Very nice! I have installed first version and it's ok, with the second version, what happens with links like
http://it.youtube.com/watch?v=SWp4LXmm8-0 ?<
leatherlips
01 September 2007, 13:51


Perfect! Now it looks like you can either insert only the unique YouTube code or the entire URL! Thank you!
With regards to modifichicci:

I tried your link and it worked just fine!<
modifichicci
01 September 2007, 14:02


Thanks.. I will apply changes<
Berrie
02 September 2007, 07:31


Originally posted by lucapan


Done! See the first post (there is only one zip file now).
Bye.

What is different in the code compared to version 1? Version 1 with only the hash code is already running at my site.

Very nice MOD!kisses<
leatherlips
02 September 2007, 09:00


The newer version allows you to enter the entire YouTube URL. If you already installed version 1, then just replace what goes in to inc_func_common.asp.<
Berrie
02 September 2007, 09:43


Thanks mate!wink<
RArch
02 September 2007, 12:07


Thanks from me too smile
Anybody running the Themes mod (like SHN forum) will need to edit each theme asp file (eg. theme_default.asp, theme_desert_like.asp etc.) and add this line.
strIconEditorYouTube = "icon_editor_youtube.gif|46|22

And also copy the icon_editor_youtube.gif file to each theme image folder. <
skellyx
09 September 2007, 06:18


Luca it is splendid and it works very well
Esempio di una cosa semplice da installare e che funziona bene ( sorry for italian language)Bravissimo Luca e grazie. <
thelodger
26 October 2007, 08:02


Sorry to sound totally dumb, can someone tell me where in inc_func_common.asp the script section starts? so I know where to add the mod? cheers.<
thelodger
26 October 2007, 10:21


Oh I found it all is great other than the button doesnt work, I get a javascript error.<
Mavrik
24 November 2007, 23:25


Hi lucapan,

I just wanted to share my thanks for this mod. We've added it to our Community works great.<
machinehack
17 January 2008, 19:44


Very sweet. I just added it to my forum. http://www.machinehack.com/forum<
leatherlips
16 May 2009, 17:39


I have had this MOD on my forum for a long time now and have just noticed something. When a youtube video is posted, the "back to top" icon does not show. What is being left out that is causing it to do that?
leatherlips
16 May 2009, 17:45


Hmmm. Nevermind. It seems to have nothing to do with this MOD. blush
It looks like the "back to top" icon does not show on the original topic. It only appears on replies. I looked here at Snitz and it seems to work the same way. That must be by design.
HuwR
16 May 2009, 18:13


yes, it is by design since the topic is generally at the top, unless of course you have an enormous logo smile
KC
06 August 2010, 00:16


Sweet, nice mod. Works perfect for my 3.4
It also goes along nicely next to my custom direct to server forum pic hosting mod.
CarlosLopez
03 October 2010, 23:20


Hello I need a expert who can do this job in my web site, I will pay good please help me in this.
contact info removed - ruirib
AnonJr
04 October 2010, 14:57


Carlos, if you're asking for help with http://shoppasofino.com/forum/, you need to add the "Powered By Snitz" information (either the image or the text - we don't care which as long as one of them is there) back to the bottom of your forum before you'll get any help.
If you're asking for help with http://www.pasofinotv.com/index.php/foro-de-caballos-colombiano, you'll need to ask the folks at VBulletin as that's what is running that site.
IWishToLearn
02 September 2011, 14:56


I followed the instructions in the mod and I get this error on forum load. I have not installed any other mods, this is a brand new forum.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

Error Type:
Microsoft JScript compilation (0x800A03EA)
Syntax error
/yd/inc_func_common.asp, line 1624

Browser Type:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.1) Gecko/20100101 Firefox/6.0.1

Page:
GET /yd/default.asp

Time:
Friday, September 02, 2011, 12:02:28 PM

Line 1624 of the Forum Code is the start of the youtube code beginning with the <%
Carefree
02 September 2011, 20:20


If you followed the instructions, that error wouldn't occur. Post a link to a copy of your "inc_func_common.asp" file in .txt format for us to see.
IWishToLearn
03 September 2011, 14:06


I will fully admit to being a coding NOOB. Will post asap, am at work at the moment. :)
IWishToLearn
03 September 2011, 15:29


Changed my mind, I'm now trying to get the onlinevideos mod to work instead. I have a help request sent in on that thread. http://forum.snitz.com/Forum/topic.asp?TOPIC_ID=66633
leatherlips
23 January 2012, 11:36


I have had this mod for years. Works great. I would like to be able to add the option to have the video go to full screen. I can't seem to get it to work. Here is what I've tried:

Code:

   CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""490"" height=""300""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = """></param><param name=""wmode"" value=""transparent""></param><param name=""allowfullscreen"" value=""true""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = """ type=""application/x-shockwave-flash"" wmode=""transparent"" width=""490"" height=""300""></embed></object>"
I added the part in red. I'm not adding it to the right spot. Where should I insert it?
bobby131313
25 January 2012, 09:23


Youtube parameters...
http://code.google.com/apis/youtube/player_parameters.html

They go in the last line you posted, heres mine...
Code:
	CodeTags(1,2,3) = "&showinfo=0&hd=1&border=1&color1=000066&color2=000066&iv_load_policy=3&fs=1"" type=""application/x-shockwave-flash"" .....</embed></object>"

Here's what that looks like...
http://www.coincommunity.com/forum/topic.asp?TOPIC_ID=108935

I'm still playing with it a little. Trying to strip extra YouTube crap in the url that breaks it. Like if you go to a channel first, then click a video and paste the url it doesn't work. For example, go here...
http://www.youtube.com/playlist?list=UU8Pksdbj37CdE00kmE7Z1dw&feature=plcp

Then click on a video and try to use that url.
leatherlips
25 January 2012, 16:24


I tried your video on the link you posted. I see the full screen button but when I click on it nothing happens. I'm using the Safari browser on a mac (leopard). Does it work for you?
MaGraham
31 January 2012, 11:46


I'm going to keep checking back here to see when you figure this out. I've been wanting this! :)

Also, I have a secure website and even though I put the s after the http in the YouTube link, I am still getting the security warning. Someone said I needed to put something in the htaccess file. Does anyone know anything about this, or exactly what would eliminate the security warning?


bobby131313
31 January 2012, 11:53


Does it work for you?

Actually, it was in FF, but now it's not.
MaGraham
02 February 2012, 00:39


Copying and pasting this post here from another post since I asked the question above.
Some of it will be repetitive with the first post here. SORRY! Hope that's okay! :)




I am Sooooo excited!! I just now figured this out! I did the YouTube Video Mod by lucapan so that
our members only have to enter the [youtube][/youtube] in a post to share a YouTube video.

Example: [youtube]https://www.youtube.com/watch?v=riqxOjd4alw[/youtube]
Like I said in my initial post here, we kept getting the security warning with the YouTube videos. So,
I had checked and rechecked and rechecked posts to see if someone had forgotten to add the s after the
http in the YouTube link they were using but I was not finding one single YouTube video that didn't
already have the s in the link.

And then it just now dawned on me; all of the actual "codes" to make the videos work aren't in the
actual posts but rather in the Snitz Files! Soooo just now, I went into each of the files that had been
modified with the YouTube Video Mod and I entered the s in the appropriate places. And, guess
what? It's working PERFECT now!!!!! We are no longer getting the security warning!!!

Ohhhhh PRAISE GOD from Whom all blessings flow!!!!!!

Yeah, I'm HAPPY!!!!! bigsmile
Thank you so much for your precious time with this!!!

Here is his (lucapan) code for the YouTube Video Mod.
YouTube Video Mod Download in zip format

Oh, I was extremely detailed in this post for a reason. I don't think this mod is listed anywhere on the Snitz site. This download is from this member's site. So, I just thought perhaps this post might be of help to someone doing
a search for an EASY means of posting a YouTube video on their website! :)



This solved my problem!

ruirib
02 February 2012, 12:28


Does it work for you?

Actually, it was in FF, but now it's not. There is a version that deals with this in a much more flexible way. I think it was started by Marcel and balexandre rounded it up. It includes javascript functions that allow all the flexibility you want in a much simpler way. It allows you, for example, to handle the new shortened links with an easy addition and it has the added benefit of allowing videos from other sources, as flickr and photobucket.
webewitch
28 April 2012, 10:25


I've added the full screen button and changed to the standard dimensions :

Code:
CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = "&fs=1""></param><param name=""allowFullScreen"" value=""true""></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = "&fs=1"" type=""application/x-shockwave-flash""allowfullscreen=""true"" wmode=""transparent"" width=""640"" height=""390""></embed></object>"
webewitch
30 April 2012, 14:07


I've changed the code a wee bit to the now standard size of 640x390 and added the fullscreen button:

Code:

CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = "&fs=1""></param><param name=""allowFullScreen"" value=""true""></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = "&fs=1"" type=""application/x-shockwave-flash""allowfullscreen=""true"" wmode=""transparent"" width=""640"" height=""390""></embed></object>"

One slight problem I have is that while most of the videos work on my iPhone a few don't . e.g. this one;

[youtube]http://www.youtube.com/watch?v=o-WZU1X--IM[/youtube]
Can't figure out what's so different about it. It shows fine on my website
MaGraham
02 May 2012, 05:18


Originally posted by webewitch
I've changed the code a wee bit to the now standard size of 640x390 and added the fullscreen button:

Code:

CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = "&fs=1""></param><param name=""allowFullScreen"" value=""true""></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = "&fs=1"" type=""application/x-shockwave-flash""allowfullscreen=""true"" wmode=""transparent"" width=""640"" height=""390""></embed></object>"

One slight problem I have is that while most of the videos work on my iPhone a few don't . e.g. this one;

[youtube]http://www.youtube.com/watch?v=o-WZU1X--IM[/youtube]
Can't figure out what's so different about it. It shows fine on my website



YEA!! It works! Now we can do FULL SCREEN YouTube videos!!


THANK YOU!!!






MaGraham
02 May 2012, 05:22



Can you do a simple add-on so we can do a YouTube playlist by by using the [youtube][/youtube]?



Astralis
07 February 2014, 03:34


Is there an updated code for YouTube's IFRAME option, which is the standard option. It should be a piece of cake to code if no one has tried it yet.
Maxime
07 February 2014, 05:26


I do not know if there is a code. But I use the mod fashion media that is on www.snitzbitz.com or there youtube, dailymotion, vemo and many others will see.
MaGraham
07 February 2014, 08:06


Originally posted by Astralis
Is there an updated code for YouTube's IFRAME option, which is the standard option. It should be a piece of cake to code if no one has tried it yet.

This is the only Snitz post with any sort of YouTube code in it I believe, Astralis.
Carefree
07 February 2014, 12:08


Here's a stand-alone forum player I made in about 20 minutes for YouTube using their iframe API, so it's not difficult to code. This one keeps the option to limit the video play (under "preview") to 6 seconds or to play the entire video (under "watch").
"tubeframe.asp"

Code:

<%
'###############################################################################
'##
'## Snitz Forums 2000 v3.4.07
'##
'###############################################################################
'##
'## Copyright © 2000-14 Michael Anderson, Pierre Gorissen,
'## Huw Reddick and Richard Kinser
'##
'## This program is free. You can redistribute and/or modify it under the
'## terms of the GNU General Public License as published by the Free Software
'## Foundation; either version 2 or (at your option) any later version. '##
'## All copyright notices regarding Snitz Forums 2000 must remain intact in
'## the scripts and in the HTML output. The "powered by" text/logo with a
'## link back to http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet. '##
'## This program is distributed in the hope that it will be useful but
'## WITHOUT ANY WARRANTY; without even an implied warranty of MERCHANTABILITY
'## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
'## for more details. '##
'## You should have received a copy of the GNU General Public License along
'## with this program; If not, write to:
'##
'## Free Software Foundation, Inc. '## 59 Temple Place, Suite 330
'## Boston, MA 02111-1307
'##
'## Support can be obtained from our support forums at:
'##
'## http://forum.snitz.com
'##
'## Correspondence and marketing questions can be sent to:
'##
'## manderson@snitz.com
'##
'###############################################################################
%>
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_header.asp"-->
<%
Response.Write " <table border=""0"" width=""100%"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td width=""33%"" align=""left"" nowrap><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" " & getCurrentIcon(strIconFolderOpen,"","align=""absmiddle""") & " <a href=""default.asp"">All Forums</a><br />" & vbNewLine & _
" " & getCurrentIcon(strIconBar,"","align=""absmiddle""") & getCurrentIcon(strIconFolderOpenTopic,"","align=""absmiddle""") & " YouTube Frame Player<br /></font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" <br />" & vbNewLine
If Request("VideoID")="" Then
Call AnyForm
WriteFooter
Response.End
Else
strVideoID=Request("VideoID")
If left(strVideoID,13)="http://youtu." Then
strVideoID=mid(strVideoID,17)
End If
For i = len(strVideoID) to 1 step -1
If mid(strVideoID,i,5)="watch" Then
strVideoID=mid(strVideoID,i+8,len(strVideoID)-9)
Exit For
End If
Next
For j = 1 to len(strVideoID)
If mid(strVideoID,j,1)="&" Then
strVideoID=left(strVideoID,j-1)
Exit For
End If
Next
%>
<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div id="player"></div>
<%
If Request("submit")="Preview" Then
%>
<script>
// 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads. var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '<%=strVideoID%>',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready. function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes. // The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop. var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
</script>
<%
Else
%>
<script>
// 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads. var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '<%=strVideoID%>',
events: {
'onReady': onPlayerReady
}
});
}
// 4. The API will call this function when the video player is ready. function onPlayerReady(event) {
event.target.playVideo();
}
</script>
<%
End If
WriteFooter
Response.End
End If
Sub AnyForm
Response.Write "<form action=""tubeframe.asp"" method=""post"">" & vbNewLine & _
" <table align=""center"" width=""75%"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse:collapse;"" border=""0"" bgColor=""transparent"">" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""100%"" bgColor=""" & strTableBorderColor & """>" & vbNewLine & _
" <table align=""center"" width=""100%"" cellpadding=""4"" cellspacing=""1"" style=""border-collapse:collapse;"" border=""1"">" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""center"" width=""100%"" bgColor=""" & strHeadCellColor & """ colspan=""2"">" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """ color=""" & strHeadFontColor & """><b>YouTube IFrame Player</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr valign=""middle"">" & vbNewLine & _
" <td align=""right"" width=""50%"" bgColor=""" & strForumCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strForumFontColor & """><b>YouTube Video ID (or entire URL): </b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" <td align=""left"" width=""50%"" bgColor=""" & strForumCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strForumFontColor & """>" & vbNewLine & _
" <input type=""text"" style=""width:95%; color:maroon; font-strength:bold;"" maxlength=""50"" name=""VideoID"" value=""" & Request("VideoID") & """ />" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <tr valign=""top"">" & vbNewLine & _
" <td colspan=""2"" width=""100%"" align=""center"" bgColor=""transparent"">" & vbNewLine & _
" <button type=""image"" name=""submit"" value=""Watch"" style=""border:none; background:transparent;""><img src=""" & strImageURL & "Watch.png"" alt=""Watch"" height=""35"" width=""70"" />   <button type=""image"" name=""submit"" value=""Preview"" style=""border:none; background:transparent;""><img src=""" & strImageURL & "Preview.png"" alt=""Preview"" height=""35"" width=""70"" />" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
"</form>" & vbNewLine
End Sub
%>

Here are two images for your image folder:

watch.png [IMG]http://i61.tinypic.com/nlacxx.png[/IMG] preview.png [IMG]http://i57.tinypic.com/2wbxp3o.png[/IMG]
Astralis
10 February 2014, 02:28


Carefree, any everyone, thank you!
This requires people to recognize the ID in the URL.
Do you think there's another way to discover the ID when the user inputs the entire URL?
For example, consider all these variations of the same video ID:

http://youtu.be/MhNDKZmxRLM?t=21s
http://youtu.be/MhNDKZmxRLM
http://youtube.com/watch?v=MhNDKZmxRLM
http://www.youtube.com/watch?v=MhNDKZmxRLM
http://fr.youtube.com/watch?v=MhNDKZmxRLM&list=RDzLWni7-2NXw
http://youtube.com/watch?v=MhNDKZmxRLM&ob=av3e
http://www.youtube.com/watch?v=MhNDKZmxRLM&feature=player_embedded
Carefree
10 February 2014, 03:36


No, it doesn't. It works either way, by video ID or by the entire URL.
Carefree
10 February 2014, 03:38


http://youtu.be/MhNDKZmxRLM?t=21s
http://youtu.be/MhNDKZmxRLM

Since these are not really "youtube" addresses but come from a different site altogether, I didn't try to support them. But I could change it to recognize them, as well. OK. Done. See above for code.
Astralis
10 February 2014, 03:41


Yeah, that is YouTube's official short address version.
Astralis
10 February 2014, 04:02


This is brilliant! Thank you and great work!
Carefree
10 February 2014, 04:44


You're welcome.
MaGraham
10 February 2014, 10:56




How does this work in members' posts, Carefree?

Will it also work for the YouTube playlists?

Astralis
10 February 2014, 12:24


I don't think CareFree intended this to work in the posts. I was planning to take his work and then integrate it myself.
Carefree
10 February 2014, 22:30


It plays playlists, just fine; but no, it wasn't intended to work in posts. I wrote it to show the API function was supported.
MaGraham
19 February 2014, 12:11



With YouTube making some changes, this mod now works for Playlists.
Here's an example of the only thing members have to place in their post.

[youtube]0xwzItqYmII&list=PL8BD9E2C28109A6DE&feature=share&index=1[/youtube]

YEA! cool

MaGraham
19 February 2014, 12:17



Here's an example of what a member has to place in a post for just a regular YouTube video.

[youtube]XYBehBWgGPY[/youtube]

Of course placing the complete URL in-between the YouTube codes work, too.

Sure do appreciate you guys who do coding!
spreadpoems
19 February 2014, 12:27


MaGraham,
Here's an example of what a member has to place in a post for just a regular YouTube video.
[youtube]XYBehBWgGPY[/youtube]

What mods or code do you need to install to get this to work?
MaGraham
19 February 2014, 12:37


Spreadpoems, the link to the mod is in the first post on page one of this thread. Here's the link from that post where you can download the mod.
http://www.lucapanella.com/downloads/SnitzYouTubeForumCodeMod.zip

Also, look at the top of page three here and you can see what needs to be added to allow videos to play in full screen mode.
Good luck!
spreadpoems
19 February 2014, 13:00


Thanks but that link doesn't work :-(
MaGraham
20 February 2014, 08:26



Oh no! I never thought to check the link!
Let me see if I can find my copy.

MaGraham
20 February 2014, 10:41



I found my copy. Now let me see if I can place all of this in a post, spreadpoems.
Here's the YouTube button graphic lucapan supplied:



Here are the instructions that the author, lucapan, shared:
[code]
Code:

I wrote this mod for Snitz Forum to use a simple forum code like:

[youtube]http://www.youtube.com/watch?v=gJmX1z1NY2c[/youtube]
to embed a youtube video in the forum.
____________________________________


Modify "inc_func_common.asp" adding the following function at the end of the file, before the <script> section:



<%
Function ReplaceYouTubeTags(fString)
Dim oTag, cTag
Dim roTag1, rcTag1, roTag2, rcTag2
Dim oTagPos, cTagPos
Dim nTagPos
Dim counter1, counter2, counter3
Dim strCodeText
Dim Tagcount
Dim strTempString, strResultString
TagCount = 1
Dim CodeTags(1,2,3)
Dim strArray, strArray2, strArray3, strArray4

CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""425"" height=""353""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = """></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = """ type=""application/x-shockwave-flash"" wmode=""transparent"" width=""425"" height=""353""></embed></object>"

strResultString = ""
strTempString = fString

for counter1 = 1 to TagCount

oTag = CodeTags(counter1,1,1)
roTag1 = CodeTags(counter1,1,2)
roTag2 = CodeTags(counter1,1,3)
cTag = CodeTags(counter1,2,1)
rcTag1 = CodeTags(counter1,2,2)
rcTag2 = CodeTags(counter1,2,3)
oTagPos = InStr(1, strTempString, oTag, 1)
cTagPos = InStr(1, strTempString, cTag, 1)

if (oTagpos > 0) and (cTagPos > 0) then
strArray = Split(strTempString, oTag, -1, 1)
for counter2 = 0 to Ubound(strArray)
if (Instr(1, strArray(counter2), cTag) > 0) then
strArray2 = split(strArray(counter2), cTag, -1, 1)
strCodeText = trim(strArray2(0))
if (LCase(Left(strCodeText,2))="<a") then
strArray3 = split(strCodeText, ">", -1, 1)
if (UBound(strArray3)>0) then
strCodeText = Left(strArray3(1), Len(strArray3(1))-3)
strArray3 = split(strCodeText, "?", -1, 1)
if (UBound(strArray3)>0) then
strCodeText = strArray3(1)
strArray3 = split(strCodeText, "&", -1, 1)
for counter3 = 0 to UBound(strArray3)
strArray4 = split(strArray3(counter3), "=", -1, 1)
if (UBound(strArray4)=1)AND(LCase(strArray4(0))="v") then
strCodeText = strArray4(1)
exit for
end if
next
end if
end if
end if
strResultString = strResultString & roTag1 & strCodeText & rcTag1 & roTag2 & strCodeText & rcTag2 & strArray2(1)
else
strResultString = strResultString & strArray(counter2)
end if
next
strTempString = strResultString
strResultString = ""
end if
next
ReplaceYouTubeTags = strTempString
end function
%>
____________________________________

At line 239 change:

if strAllowForumCode = "1" then
fString = extratags(fString)
end if
____________________________________

to
____________________________________

if strAllowForumCode = "1" then
fString = extratags(fString)
fString = ReplaceYouTubeTags(fString)
end if
____________________________________

Now you can use the brand new forum code!
____________________________________


If you want, you can modify "pop_forum_code.asp",
adding the following code before if (strIMGInPosts = "1"), at line 158.

Response.Write "<p><b>YouTube:</b> Place the letter 's' after the http in the video URL (example https://www). Next, enclose the video URL with [youtube] and [/youtube] .  <i>Example:</i> Here is a video: <b>[youtube]</b>http://www.youtube.com/watch?v=gJmX1z1NY2c<b>[/youtube]</b></p>" & vbNewLine
____________________________________

If you want a YouTube button, copy "icon_editor_youtube.gif" in your image folder
(if you have not an image folder, use the root folder of the forum).
____________________________________


Modify "inc_code.js" adding at the end:


function youtube() {
var text = getText();
if (helpstat){
alert("YouTube tag inserts a video hosted by YouTube into the post, but you will need to add the letter 's' after the http in your link.\n\nExample: [youtube]https://www.youtube.com/watch?v=gJmX1z1NY2c[/youtube]");
} else if (basic) {
AddTxt="[youtube]" + text + "[/youtube]";
AddText(AddTxt);
} else {
txt=prompt("YouTube video URL","");
if(txt!=null) {
AddTxt="[youtube]"+txt+"[/youtube]";
AddText(AddTxt);
}
}
}
____________________________________

Modify "inc_iconfiles.asp" adding (where you want):


Const strIconEditorYouTube = "icon_editor_youtube.gif|46|22"
____________________________________

Modify "inc_post_buttons.asp" adding after line 66, just before 'if lcase(strIcons) = "1" and strShowSmiliesTable = "0"':


Response.Write "<a href=""Javascript:youtube();"" tabindex=""-1"">" & getCurrentIcon(strIconEditorYouTube,"Insert YouTube","align=""top""") & "</a>" & vbNewLine
____________________________________

Ciao! Luca Panella
http://www.lucapanella.com

Sep 01 2007


Here are the instructions "webewitch" shared to allow full screen:

[code]
Code:

Snitz Member "webewitch" shared this below to allow full screen on YouTube video:

I've changed the code a wee bit to the now standard size of 640x390 and added the fullscreen button:

CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = "&fs=1""></param><param name=""allowFullScreen"" value=""true""></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = "&fs=1"" type=""application/x-shockwave-flash""allowfullscreen=""true"" wmode=""transparent"" width=""640"" height=""390""></embed></object>"


One slight problem I have is that while most of the videos work on my iPhone a few don't . e.g. this one;

[youtube]http://www.youtube.com/watch?v=o-WZU1X--IM[/youtube]





Since my site is secure, I added a "s" after each http in the "full screen" codes just above.
Good luck with it, spreadpoems.

spreadpoems
20 February 2014, 14:27


MaGraham, thank you it works!
MaGraham
20 February 2014, 14:54



Wonderful! I'm excited for you! smile
It's such a simple, yet marvelous, mod I'm truly surprised it wasn't added to the Snitz Mods on the snitzbitz.com site.
Well, at least it's here now to stay! bigsmile
MaGraham
01 June 2015, 06:29


Some of my members are using Youtube links like these:
https://youtu.be/YRAx0wi6A90

And, those won't play with this Youtube mod. Does anyone know of a means of adding some additional codes to make these play?
Carefree
01 June 2015, 07:34


This is untested, but you could try replacing the bit of code in "inc_func_common.asp" with something like this:

Note the bits in red. If you're running a secure forum, you'll have to switch the values in the replace and change the http to https twice in the second routine.
Also note the two bits in purple. If members post more than one video per topic (including replies), you need to change each 1 to 0. Otherwise, you'll get a mess of videos starting simultaneously.
Code:

Function ReplaceYouTubeTags(fString)		
fString=Replace(fString, "youtu.be/", "www.youtube.com/v/")
fString=Replace(fString, "watch?v=", "v/")
fString=Replace(fString, "https:", "http:") For intFI = 1 to Len(fString)
If Mid(fString,intFI,9)="[youtube]" Then
intFJ=intFI+9
End If
If Mid(fString,intFI,10)="[/youtube]" Then
intFK=intFI
strMovLK = Mid(fString,intFJ,intFK-intFJ)
Exit For
End If
Next
Dim oTag, cTag
Dim roTag1, rcTag1, roTag2, rcTag2
Dim oTagPos, cTagPos
Dim nTagPos
Dim counter1, counter2, counter3
Dim strCodeText
Dim Tagcount
Dim strTempString, strResultString
TagCount = 1
Dim CodeTags(1,2,3)
Dim strArray, strArray2, strArray3, strArray4
CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
If Instr(strMovLK,"http") = 0 Then
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value=""http://www.youtube.com/v/"
Else
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value="""
End If
CodeTags(1,2,2) = "?autoplay=1"" /><param allowfullscreen=""true"" /><param wmode=""transparent"" />"
If Instr(strMovLK,"http") = 0 Then
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
Else
CodeTags(1,1,3) = "<embed src="""
End If
CodeTags(1,2,3) = "?autoplay=1"" type=""application/x-shockwave-flash"" allowfullscreen=""true"" wmode=""transparent"" width=""640"" height=""390""></embed></object>"
strResultString = ""
strTempString = fString
For counter1 = 1 To TagCount
oTag = CodeTags(counter1,1,1)
roTag1 = CodeTags(counter1,1,2)
roTag2 = CodeTags(counter1,1,3)
cTag = CodeTags(counter1,2,1)
rcTag1 = CodeTags(counter1,2,2)
rcTag2 = CodeTags(counter1,2,3)
oTagPos= InStr(1, strTempString, oTag, 1)
cTagPos= InStr(1, strTempString, cTag, 1)
If (oTagpos > 0) And (cTagPos > 0) Then
strArray = Split(strTempString, oTag, -1, 1)
For counter2 = 0 To UBound(strArray)
If (InStr(1, strArray(counter2), cTag) > 0) Then
strArray2 = Split(strArray(counter2), cTag, -1, 1)
strCodeText = Trim(strArray2(0))
If (LCase(Left(strCodeText,2))="<a") Then
strArray3 = Split(strCodeText, ">", -1, 1)
If (UBound(strArray3)>0) Then
strCodeText = Left(strArray3(1), Len(strArray3(1))-3)
strArray3 = Split(strCodeText, "?", -1, 1)
If (UBound(strArray3)>0) Then
strCodeText = strArray3(1)
strArray3 = Split(strCodeText, "&", -1, 1)
For counter3 = 0 To UBound(strArray3)
strArray4 = Split(strArray3(counter3), "=", -1, 1)
If (UBound(strArray4)=1) And (LCase(strArray4(0))="v") Then
strCodeText = strArray4(1)
Exit For
End If
Next
End If
End If
End If
strResultString = strResultString & roTag1 & strCodeText & rcTag1 & roTag2 & strCodeText & rcTag2 & strArray2(1)
Else
strResultString = strResultString & strArray(counter2)
End If
Next
strTempString = strResultString
strResultString = ""
End If
Next
ReplaceYouTubeTags = strTempString
End Function


NOTE: As of Jan 2015, Google (YouTube) is killing off the <object> method of playing YT videos in web pages. They want everyone to use IFrames instead. So if you want to continue displaying YT videos, we'll have to write some security code to preclude anything other than legitimate YT videos in an embedded IFrame.
MaGraham
01 June 2015, 11:27


Thank you, Carefree, but that wouldn't allow any of the Youtube videos to play.

Carefree
01 June 2015, 13:12


Post a link to your "inc_func_common.asp" in .txt format. It should work as written.
bobby131313
01 June 2015, 14:57


I used the bad word filter.
Change https://youtu.be/ to http://www.youtube.com/watch?v=
MaGraham
01 June 2015, 16:09


That sounds clever, Bobby. cool
Check your email, Carefree.
bobby131313
01 June 2015, 16:26


I'm a purdy fart smeller. smile
MaGraham
01 June 2015, 18:05



Originally posted by bobby131313
I'm a purdy fart smeller. smile

GROAN! lol


Carefree's coding worked perfect. Both type of links play the videos now. The problem was that my site is on a secure server so that had to be corrected.
Thank you so much, Carefree! I really appreciate you!
volkerc
15 August 2016, 04:49


It seems that this is no longer supported, they are switching from flash to html5. What needs to be modified to still post the videos?
Webbo
19 April 2017, 15:35


Ive been using the following for some time now but since Google (Youtube) changed to using iframes there is always a little nag telling users that the Youtube API has been depreciated, ala https://developers.google.com/youtube/flash_api_reference


Originally posted by Carefree
This is untested, but you could try replacing the bit of code in "inc_func_common.asp" with something like this:

Note the bits in red. If you're running a secure forum, you'll have to switch the values in the replace and change the http to https twice in the second routine.
Also note the two bits in purple. If members post more than one video per topic (including replies), you need to change each 1 to 0. Otherwise, you'll get a mess of videos starting simultaneously.
Code:

Function ReplaceYouTubeTags(fString)		
fString=Replace(fString, "youtu.be/", "www.youtube.com/v/")
fString=Replace(fString, "watch?v=", "v/")
fString=Replace(fString, "https:", "http:") For intFI = 1 to Len(fString)
If Mid(fString,intFI,9)="[youtube]" Then
intFJ=intFI+9
End If
If Mid(fString,intFI,10)="[/youtube]" Then
intFK=intFI
strMovLK = Mid(fString,intFJ,intFK-intFJ)
Exit For
End If
Next
Dim oTag, cTag
Dim roTag1, rcTag1, roTag2, rcTag2
Dim oTagPos, cTagPos
Dim nTagPos
Dim counter1, counter2, counter3
Dim strCodeText
Dim Tagcount
Dim strTempString, strResultString
TagCount = 1
Dim CodeTags(1,2,3)
Dim strArray, strArray2, strArray3, strArray4
CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
If Instr(strMovLK,"http") = 0 Then
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value=""http://www.youtube.com/v/"
Else
CodeTags(1,1,2) = "<object width=""640"" height=""390""><param name=""movie"" value="""
End If
CodeTags(1,2,2) = "?autoplay=1"" /><param allowfullscreen=""true"" /><param wmode=""transparent"" />"
If Instr(strMovLK,"http") = 0 Then
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
Else
CodeTags(1,1,3) = "<embed src="""
End If
CodeTags(1,2,3) = "?autoplay=1"" type=""application/x-shockwave-flash"" allowfullscreen=""true"" wmode=""transparent"" width=""640"" height=""390""></embed></object>"
strResultString = ""
strTempString = fString
For counter1 = 1 To TagCount
oTag = CodeTags(counter1,1,1)
roTag1 = CodeTags(counter1,1,2)
roTag2 = CodeTags(counter1,1,3)
cTag = CodeTags(counter1,2,1)
rcTag1 = CodeTags(counter1,2,2)
rcTag2 = CodeTags(counter1,2,3)
oTagPos= InStr(1, strTempString, oTag, 1)
cTagPos= InStr(1, strTempString, cTag, 1)
If (oTagpos > 0) And (cTagPos > 0) Then
strArray = Split(strTempString, oTag, -1, 1)
For counter2 = 0 To UBound(strArray)
If (InStr(1, strArray(counter2), cTag) > 0) Then
strArray2 = Split(strArray(counter2), cTag, -1, 1)
strCodeText = Trim(strArray2(0))
If (LCase(Left(strCodeText,2))="<a") Then
strArray3 = Split(strCodeText, ">", -1, 1)
If (UBound(strArray3)>0) Then
strCodeText = Left(strArray3(1), Len(strArray3(1))-3)
strArray3 = Split(strCodeText, "?", -1, 1)
If (UBound(strArray3)>0) Then
strCodeText = strArray3(1)
strArray3 = Split(strCodeText, "&", -1, 1)
For counter3 = 0 To UBound(strArray3)
strArray4 = Split(strArray3(counter3), "=", -1, 1)
If (UBound(strArray4)=1) And (LCase(strArray4(0))="v") Then
strCodeText = strArray4(1)
Exit For
End If
Next
End If
End If
End If
strResultString = strResultString & roTag1 & strCodeText & rcTag1 & roTag2 & strCodeText & rcTag2 & strArray2(1)
Else
strResultString = strResultString & strArray(counter2)
End If
Next
strTempString = strResultString
strResultString = ""
End If
Next
ReplaceYouTubeTags = strTempString
End Function


NOTE: As of Jan 2015, Google (YouTube) is killing off the <object> method of playing YT videos in web pages. They want everyone to use IFrames instead. So if you want to continue displaying YT videos, we'll have to write some security code to preclude anything other than legitimate YT videos in an embedded IFrame.


Is it possible to update this ?
HuwR
20 April 2017, 06:46


it would be fairly trivial to change the tag replacement to use iframes, however almost certainly any current videos would stop working as the urls required for iframes are different smile
Webbo
20 April 2017, 16:40


That in itself would cause a few problems
HuwR
21 April 2017, 02:31


IIRC the url for the iframe source is like https://www.youtube.com/embed/XXXXXXX
MaGraham
27 April 2017, 14:00



These codes below (for YouTube and Vimeo) work on my site using the [iframe][/iframe] codes, and they allow full screen.
[iframe]https://www.youtube.com/embed/r5L6QlAH3L4?color=ffffff" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen[/iframe]
[iframe]https://player.vimeo.com/video/214844648?color=ffffff" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen[/iframe]
If those codes, and possibly more for other video sites, could be incorporated into the video mods, oh how wonderful that would be! Just sayin'. cool
emviem
15 August 2017, 05:00


Hi guys. I also use lucapan's codes for displaying youtube videos and I'm thankful for that. Recently I noticed the modification for enabling fullscreen. I did it but I see that although it is successful in firefox, the fullscreen button is still greyed out / disabled in google chrome for embedded videos in our snitz forum. I don't know the result in other browsers. I read that this might be related to the html5/flash issue but my trials including installing the latest version of flash and using an extension to force the browser to opt for flash didn't change the result. So, do you know if this is a specific glitch about the chrome and is there a solution for that?
Originally posted by MaGraham

These codes below (for YouTube and Vimeo) work on my site using the [iframe][/iframe] codes, and they allow full screen.
[iframe]https://www.youtube.com/embed/r5L6QlAH3L4?color=ffffff" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen[/iframe]
[iframe]https://player.vimeo.com/video/214844648?color=ffffff" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen[/iframe]
If those codes, and possibly more for other video sites, could be incorporated into the video mods, oh how wonderful that would be! Just sayin'. cool
Hi MaGraham, I tried those "iframe" codes in my forum but they didn't work. Do you use a specific mod with which those codes work? As far as I can see, the "OnlineVideos MOD" in the snitzbit site is the only (?) mod for dislaying online videos in a snitz forum including from youtube, vimeo, etc. Is this the mod that you run the iframe codes with? I also tried the standalone youtube display codes ("tubeframe.asp") by Carefree but I couldn't make it work at all either with iframe codes or with [youtube] type codes. Maybe I should have cleared the lucapan's youtube codes first?
MaGraham
19 August 2017, 14:50


I am using Carefree's Modular on my site, emviem. It has the option to allow iframes for each member or I can choose specific members. I've only allowed iframes for myself, so those codes will only work in posts/replies I make. That's the reason I said it would be great if the iframe codes could be incorporated into the video mods.
HuwR
20 August 2017, 02:25


emviem, can you provide an example that doesn't work

this embedded video works in IE/Firefox and chrome using a very basic iframe setup

https://www.reddick.co.uk/Mvc/Topic/Posts/1085?pagenum=1&archived=0&terms=video
emviem
22 August 2017, 12:31


Originally posted by HuwR
emviem, can you provide an example that doesn't work

this embedded video works in IE/Firefox and chrome using a very basic iframe setup

https://www.reddick.co.uk/Mvc/Topic/Posts/1085?pagenum=1&archived=0&terms=video
An example would be the youtube embeds in this page: https://goo.gl/5EAqYC In my computer, they run smoothly with fullscreen enabled in firefox but not in chrome, which I mostly prefer.

Webbo
22 August 2017, 17:08


Chrome should be banned, it's the Devil's work and has a mind of it's own
bobby131313
22 August 2017, 18:05


Oh if I had to pick one to be banned it would be IE.
HuwR
23 August 2017, 01:38


Originally posted by emviem An example would be the youtube embeds in this page: https://goo.gl/5EAqYC In my computer, they run smoothly with fullscreen enabled in firefox but not in chrome, which I mostly prefer.



Ok, the issue with them not displaying fullscreen in chrome is because your videos are displaying in object/embed tags which chrome no longer supports because it uses flash. you need to replace the code you have so that it uses iframes instead.
It is probably in the inc_code.asp file (IIRC) could you post a txt copy of yours and I will take a look
emviem
23 August 2017, 06:36


Originally posted by emviem An example would be the youtube embeds in this page: https://goo.gl/5EAqYC In my computer, they run smoothly with fullscreen enabled in firefox but not in chrome, which I mostly prefer.

Ok, the issue with them not displaying fullscreen in chrome is because your videos are displaying in object/embed tags which chrome no longer supports because it uses flash. you need to replace the code you have so that it uses iframes instead.
It is probably in the inc_code.asp file (IIRC) could you post a txt copy of yours and I will take a look
I will, HuwR, thanks. And which tags should I use to paste codes here (to show codes inside a code box)? I checked some help/FAQ pages here but couldn't locate the information about that.
And should I also post my "inc_func_common.asp" file, in which lucapan's youtube codes are contained?
HuwR
23 August 2017, 07:58


you can use code tags here [code][/code]

And yes please post the inc_func_common if that was channged
emviem
23 August 2017, 11:14


HuwR, I tried to post the codes between the code tags you mentioned but they didn't seem to work. Codes (file contents) just showed up as message text. And some of the code was lacking. I had to delete the post.
HuwR
23 August 2017, 13:21


you can email me the files to [removed]
© 2000-2021 Snitz™ Communications