Author |
Topic |
MaGraham
Senior Member
USA
1297 Posts |
Posted - 01 June 2015 : 06:29:55
|
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?
|
"Do all the good you can, by all the means you can, in all the ways you can, at all the times you can, to all the people you can, as long as ever you can." - John Wesley |
Edited by - MaGraham on 01 June 2015 06:30:24 |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 01 June 2015 : 07:34:46
|
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.
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. |
Edited by - Carefree on 01 June 2015 22:24:40 |
|
|
MaGraham
Senior Member
USA
1297 Posts |
Posted - 01 June 2015 : 11:27:42
|
Thank you, Carefree, but that wouldn't allow any of the Youtube videos to play.
|
"Do all the good you can, by all the means you can, in all the ways you can, at all the times you can, to all the people you can, as long as ever you can." - John Wesley |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 01 June 2015 : 13:12:47
|
Post a link to your "inc_func_common.asp" in .txt format. It should work as written. |
|
|
bobby131313
Senior Member
USA
1163 Posts |
|
MaGraham
Senior Member
USA
1297 Posts |
Posted - 01 June 2015 : 16:09:07
|
That sounds clever, Bobby.
Check your email, Carefree.
|
"Do all the good you can, by all the means you can, in all the ways you can, at all the times you can, to all the people you can, as long as ever you can." - John Wesley |
|
|
bobby131313
Senior Member
USA
1163 Posts |
|
MaGraham
Senior Member
USA
1297 Posts |
Posted - 01 June 2015 : 18:05:54
|
quote: Originally posted by bobby131313
I'm a purdy fart smeller.
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!
|
"Do all the good you can, by all the means you can, in all the ways you can, at all the times you can, to all the people you can, as long as ever you can." - John Wesley |
|
|
volkerc
Junior Member
Germany
156 Posts |
Posted - 15 August 2016 : 04:49:31
|
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
Average Member
United Kingdom
982 Posts |
Posted - 19 April 2017 : 15:35:23
|
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
quote: 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.
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
Forum Admin
United Kingdom
20584 Posts |
Posted - 20 April 2017 : 06:46:06
|
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 |
MVC .net dev/test site | MVC .net running on Raspberry Pi |
|
|
Webbo
Average Member
United Kingdom
982 Posts |
Posted - 20 April 2017 : 16:40:19
|
That in itself would cause a few problems |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
|
MaGraham
Senior Member
USA
1297 Posts |
Posted - 27 April 2017 : 14:00:38
|
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'.
|
"Do all the good you can, by all the means you can, in all the ways you can, at all the times you can, to all the people you can, as long as ever you can." - John Wesley |
Edited by - MaGraham on 27 April 2017 14:10:42 |
|
|
emviem
Starting Member
Turkey
7 Posts |
Posted - 15 August 2017 : 05:00:07
|
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?
quote: 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'.
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? |
Edited by - emviem on 15 August 2017 05:02:48 |
|
|
Topic |
|
|
|