News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Ohara YouTube Embed

Started by Suki, December 21, 2011, 03:04:59 PM

Previous topic - Next topic

Suki

Its gonna be tricky, theres a whole silly thing with browsers supporting only their preferred formats, besides I don't own any apple product so its going to be difficult to debug this.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

themavesite

Quote from: Suki on February 23, 2016, 11:29:34 AM
Its gonna be tricky, theres a whole silly thing with browsers supporting only their preferred formats, besides I don't own any apple product so its going to be difficult to debug this.
Does it work on Android for you?
If I can help in any way, please let me know.
I actually really like your mod, and it's the ONLY one with gifv support, mobile support would make this mod 100% complete for me  :D
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Suki

I s till haven't test it, my site is running SMF 2.1 and I have a totally different mod version for that SMF version only and I still haven't properly update it, onces I got it solved I will be able to test it on Android although since most people uses chrome it will have the same disadvantages every other chrome browser has.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

themavesite

Quote from: Suki on February 23, 2016, 01:43:45 PM
I s till haven't test it, my site is running SMF 2.1 and I have a totally different mod version for that SMF version only and I still haven't properly update it, onces I got it solved I will be able to test it on Android although since most people uses chrome it will have the same disadvantages every other chrome browser has.
Should I update to 2.1 then?
Also I found a small bug; when you embed a youtube video like https://www.youtube.com/watch?v=sZ_p0bkPJ5U&gl=BE the gl=BE gets pasted after the embedded video, you should just remove everything after the & probably.
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Suki

No, you shouldn't upgrade to 2.1 just for this.

I'm aware of that bug, unfortunately it is more than just "removing everything after the &" as not all urls follows that format, when I change the regex I gotta make sure it will work for the url formats I support.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

themavesite

Quote from: Suki on February 23, 2016, 04:05:40 PM
No, you shouldn't upgrade to 2.1 just for this.

I'm aware of that bug, unfortunately it is more than just "removing everything after the &" as not all urls follows that format, when I change the regex I gotta make sure it will work for the url formats I support.

Reporting a few more minor bugs:

https://www.youtube.com/watch?time_continue=3&v=3TZdIaNaTH0

Links with this also do not work.

https://youtu.be/Xm_dS-wEFvs

Same for youtu.be
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Ninja ZX-10RR

For the second one, add "https://youtu.be/" and "http://youtu.be/" into your censored words and replace them with "https://youtube.com/watch?v="
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

themavesite

^ Thank you for that temporary solution!

Suki I've also noticed that old youtube links aren't being embedded
Example: http://forums.themavesite.com/index.php?topic=30600.0

(with Aeva it used to be embedded)
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Suki

Don't use the censor feature as that will only increase the server burden.

The issue is related to special chars such as - and _ on the urls and not with the url format itself. Will release a new version to add support for those chars.

As for old youtube links, make sure they aren't surrounded by any BBC tags, this particular url is a standard one   supported by the mod already.

When an url doesn't get automatically embeded it almost always means there is another bbc tag on them, this mod automatically skips urls inside bbc tags.

Also, bear in mind that it will be almost impossible to caught every single youtube url out there, things like time elapse, time starting and any other special youtube params will most likely not be supported.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

themavesite

Quote from: Suki on February 25, 2016, 11:48:13 AM
Don't use the censor feature as that will only increase the server burden.

The issue is related to special chars such as - and _ on the urls and not with the url format itself. Will release a new version to add support for those chars.

As for old youtube links, make sure they aren't surrounded by any BBC tags, this particular url is a standard one   supported by the mod already.

When an url doesn't get automatically embeded it almost always means there is another bbc tag on them, this mod automatically skips urls inside bbc tags.

Also, bear in mind that it will be almost impossible to caught every single youtube url out there, things like time elapse, time starting and any other special youtube params will most likely not be supported.

Could you support [url=http://www.youtube.com/watch?v=0sTTGlqZDx0]http://www.youtube.com/watch?v=0sTTGlqZDx0[/url] the url BCC tag? As all my old youtube links have this :/
TMS Forums
Since 2008 and still going strong! Join today! http://forums.themavesite.com/index.php

Suki

Not really, at least not without some impact on performance.

SMF treats any link and automatically adds the url tags, theres nothing wrong with that, now, if a mod wants to prevent that then any auto embed url must be wrapped with another bb tag, precisely to prevent SMF's default behavior.  This is why this mod wraps all valid single urls with their respective BBC tags, this way if you uninstall this mod, all embedded urls will not be wrapped by url tags and another embed mod can then come and do their job just fine without worrying about url tags.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

420Connect.co.uk

@Suki

Would you mind reminding me of the tweak(s) to stop video links being touched in a simple portal shoutbox?
Ideally, all links posted in it would just display as "[link]"

I've got the latest version installed and get these results when I try to 'shout' these:

"https://www.youtube.com/watch?v=w3ugHP-yZXw" - doesn't appear to know I clicked 'shout'
"http://www.youtube.com/watch?v=w3ugHP-yZXw"  - doesn't appear to know I clicked 'shout'
"www.youtube.com/watch?v=w3ugHP-yZXw" - displays "[link]" <-- looking to achieve this for all.
"text here https://www.youtube.com/watch?v=w3ugHP-yZXw" - displays as: "text here
"
"text here www.youtube.com/watch?v=w3ugHP-yZXw" - displays as: "text here [link]"


Many thanks and congrats on your new role btw!  ;)
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

Suki

Its just a matter of adding this:

$context['ohara_disable'] = true; 

Before the call to your shoutbox,  but it depends on how you are adding your shoutbox, if its a php block or a pre-made one, if its a premade one then you will have to modify simpleportal code to add that code just before the shoutbox messages are being parsed via parse_bbc()
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

420Connect.co.uk

Quote from: Suki on March 04, 2016, 10:47:51 AM
Its just a matter of adding this:

$context['ohara_disable'] = true; 

Before the call to your shoutbox,  but it depends on how you are adding your shoutbox, if its a php block or a pre-made one, if its a premade one then you will have to modify simpleportal code to add that code just before the shoutbox messages are being parsed via parse_bbc()

Nice One Suki!  ;)

I knew it wasn't a big tweak!

...

*Leaves myself a little note for next time*

in Sources/Subs-Portal.php
Find:
Code (find) Select
$context['aeva_disable'] = true;

Code (replace) Select
$context['aeva_disable'] = true;

$context['ohara_disable'] = true;


O:)
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

captainspud

I'm having some issues with the mod-- it detects my YouTube URLs and tries to replace them, but only builds black boxes instead of video embeds. Screenshot attached.

Any idea what I did wrong? I'm on v.2.0.11 and downloaded the mod today.

Suki

Most likely a JS error, check your console log to see if there is any error, a link to a page/topic with a video on it might help too.

Unfortunately, theres little I can do about this kinf of errors since I don't control the way other mod authors add JavaScript code or which libraries they include.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

captainspud

1) No errors have popped up in the log since before I installed your mod.

2) I have three mods on my site-- a gallery mod that shouldn't affect posting, your mod, and a WYSIWYG editor mod. I thought the editor mod might be adding junk around the link, but when I look the post up in the DB there's nothing more than what shows up in the post editing box.

3) An example can be seen in the first reply in this thread:

http://www.captainspud.com/forum/index.php?topic=15.0 [nofollow]

His post is trying to embed https://youtu.be/GzBxEZOBTGg [nofollow], between
tags.

Thanks for taking a look at it. :)

Suki

By console log I mean the console from the dev tools you have in your screenshot.


It looks like you have a JS error:  "Uncaught TypeError: Cannot read property 'setTextMode' of undefined"  which points out to this line of code:

$(smfmod_editor).data("sceditor").setTextMode();

That error is preventing this mod's JS form running which is why you only see a black box.  Onces that error is gone your videos should play normally.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

captainspud

Ah, gotcha.

I did some digging for reports of that error, and found this thread. I made the change outlined in the first post, and my YouTube videos started snapping into place.

Thanks for pointing me in the right direction-- I never thought to check the JS error log. :)

AlexMnrs

#539
Quote from: captainspud on March 18, 2016, 07:58:34 PM
I'm having some issues with the mod-- it detects my YouTube URLs and tries to replace them, but only builds black boxes instead of video embeds. Screenshot attached.

Any idea what I did wrong? I'm on v.2.0.11 and downloaded the mod today.

I have the same issue as you. The weird thing is that regular members and visitors can see the videos without problem, but not me (administrator).





You get it fixed?

Edit. FIXED.


var $m = jQuery;
var _oh=function(){this.masterDiv=$m(".oharaEmbed");this.basedElement=this.masterDiv.parent();this.defaultWidth="undefined"!==typeof _ohWidth?_ohWidth:480;this.defaultHeight="undefined"!==typeof _ohHeight?_ohHeight:270;this.aspectRatio=this.defaultHeight/this.defaultWidth;this.main();this.responsive()};
_oh.prototype.main=function(){$this=this;$m(".youtube").each(function(){var b=this.id.replace("oh_",""),a=$this.getImage(b),c=$this.basedElement.height(),d=$this.basedElement.width();"undefined"!==typeof a&&$m(this).css({"background-image":"url("+a+")","background-size":"cover"});$m(this).append($m("<div/>",{"class":"youtube_play"}));$m(this).one("click",function(){var a="//www.youtube.com/embed/"+b+"?autoplay=1&autohide=1";$m(this).data("params")&&(a+="&"+$m(this).data("params"));a=$m("<iframe/>",{frameborder:"0",
src:a,width:d,height:c});$m(this).css({"background-image":"none"}).append(a);$m(this).children(".youtube_play").css({height:"0"});$this.responsive()})})};_oh.prototype.responsive=function(){$this=this;$m(window).resize(function(){var b=$this.basedElement.width(),a=b*$this.aspectRatio<=$this.defaultHeight?b*$this.aspectRatio:$this.defaultHeight,c=b<=$this.defaultWidth,d=c?b:$this.defaultWidth,e=c?a:$this.defaultHeight;$this.masterDiv.width(d).height(e);$m(".oharaEmbed > iframe").each(function(){$m(this).width(d).height(e)})}).resize()};
_oh.prototype.refresh=function(){$this=this;setTimeout(function(){$this.main()},3E3);setTimeout(function(){$this.responsive()},3E3)};_oh.prototype.getImage=function(b){var a="",c,d,e=["hqdefault","mqdefault","sddefault","maxresdefault"];c=0;for(d=e.length;c<d&&(a="//i.ytimg.com/vi/"+b+"/"+e[c]+".jpg",0==a.width);++c);0==a.width&&(a="//i.ytimg.com/vi/"+b+"/default.jpg");return a};(function(b){b(function(){var a=new _oh;b("input[name=preview]").on("click",function(){a.refresh()})})})(jQuery);


Either now I have new problem:


Advertisement: