Advertisement:

Author Topic: Ohara YouTube Embed  (Read 199288 times)

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #360 on: April 04, 2015, 04:36:29 PM »
@lurkalot  While testing the new version I came across a similar issue of yours. The videos just didn't play even though there was no js error or a jquery conflict. It seems the main funciton was been executed way before the dom was ready. Applying a jquery "on document ready" seems to fix this, can you please test it to see if this also fixes your issue?

Replace the entire  Themes/default/scripts/ohyoutube.js with this:

Code: [Select]
/*
 Copyright (c) 2015 Jessica Gonz├ílez
 @license http://www.mozilla.org/MPL/MPL-1.1.html
*/

function oh_main(){

$('.youtube').each(function() {

var videoID = this.id.replace('oh_',''),
imgsrc = oh_getImage(videoID),
imgHeight = $(this).height(),
imgWidth = $(this).width();

if (typeof imgsrc !== 'undefined'){
$(this).css({'background-image': 'url('+ imgsrc +')', 'background-size': 'cover'});
}

$(this).append($('<div/>', {'class': 'youtube_play'}));

$('#oh_'+videoID).on('click', function() {
var iframe_url = 'https://www.youtube.com/embed/' + videoID + '?autoplay=1&autohide=1';
if ($(this).data('params')) iframe_url+='&'+$(this).data('params');

// The height and width of the iFrame should be the same as parent
var iframe = $('<iframe/>', {'frameborder': '0', 'src': iframe_url, 'width': imgWidth, 'height': imgHeight })

// Replace the YouTube thumbnail with YouTube HTML5 Player
$(this).replaceWith(iframe);
});
});
};

function oh_getImage(youtubeID)
{
var imgsrc = '',
index, len,
imageTypes = ['hqdefault', 'mqdefault', 'sddefault', 'maxresdefault'];
for (index = 0, len = imageTypes.length; index < len; ++index) {
imgsrc = 'http://i.ytimg.com/vi/'+ youtubeID +'/'+ imageTypes[index] +'.jpg';

if (imgsrc.width !=0){
break;
}
}

// Still no image, show the default one
if (imgsrc.width ==0){
imgsrc = 'http://i.ytimg.com/vi/'+ youtubeID +'/default.jpg';
}

return imgsrc;
};

function oh_getUrl(sParam)
{
var sPageURL = window.location.search.substring(1);

// SimpleSEF or pretty urls?
if (sPageURL.indexOf(sParam) > -1) {
return true;
}

var sURLVariables = sPageURL.split(';');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return true;
}
}

return false;
}

function oh_refresh()
{
setTimeout(function(){oh_main()},3E3);
}

$(function(){
oh_main();

if (oh_getUrl('post'))
$('input[name=preview]').on('click',function(){
oh_refresh();
});
});
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline lurkalot

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 1,496
  • Gender: Male
  • Tinyportal Support
    • guitaristguild on Facebook
    • Tinyportal on GitHub
    • @GuitaristGuild on Twitter
    • Guitarist Guild
Re: Ohara YouTube Embed
« Reply #361 on: April 05, 2015, 03:08:56 PM »
Suki, sorry for not coming back to you on this sooner.  Like I mentioned earlier, I was going to rebuild the site, which I've now done, fresh files etc.  Still testing a few things out, but your mod worked fine as it was.  I tested it after installing each mod.

Today I noticed it's stopped working again.  ???

So thanks I'll give your edit a go and report back.


Offline Obcy

  • Semi-Newbie
  • *
  • Posts: 33
Re: Ohara YouTube Embed
« Reply #362 on: April 05, 2015, 03:11:03 PM »
420connect.info
If your problem is the same as mine.
Solution:
http://www.smf.pl/index.php/topic,12124.msg60188.html#msg60188

OharaYTEmbed.php
It should look something like this.
Code: [Select]
// Someone else might not like this!
if (empty($message) || !empty($context['ohara_disable']))
    return $message;
if (empty($context['current_topic']))
    return $message;
// The extremely long regex...

I am not the author

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #363 on: April 05, 2015, 03:22:42 PM »
Suki, sorry for not coming back to you on this sooner.  Like I mentioned earlier, I was going to rebuild the site, which I've now done, fresh files etc.  Still testing a few things out, but your mod worked fine as it was.  I tested it after installing each mod.

Today I noticed it's stopped working again.  ???

So thanks I'll give your edit a go and report back.



No worries, I was going to do a release but will wait until you are able to test this to see if that really fixed that issue or theres something else that needs to be fixed.

420connect.info
If your problem is the same as mine.
Solution:
http://www.smf.pl/index.php/topic,12124.msg60188.html#msg60188

OharaYTEmbed.php
It should look something like this.
Code: [Select]
// Someone else might not like this!
if (empty($message) || !empty($context['ohara_disable']))
    return $message;
if (empty($context['current_topic']))
    return $message;
// The extremely long regex...

I am not the author

I saw that fix but it doesn't really fix the issue, it just masquerades it, what you are doing is limiting the autoembed to the scope of $context['current_topic'] which is very limited.

There are other places where parse_bbc has legitimate uses, many mod authors do use it outside the scope of posting and topic display. You are basically cutting the whole tree just for a few rotten apples, thats not really a fix.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline lurkalot

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 1,496
  • Gender: Male
  • Tinyportal Support
    • guitaristguild on Facebook
    • Tinyportal on GitHub
    • @GuitaristGuild on Twitter
    • Guitarist Guild
Re: Ohara YouTube Embed
« Reply #364 on: April 05, 2015, 03:28:34 PM »

can you please test it to see if this also fixes your issue?


Ok done the edit but still no worky for me.  :'(

The thing I don't understand is why it's just suddenly stopped working again.

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #365 on: April 05, 2015, 03:35:50 PM »
OK, the produced div on the page you linked to still shows an ID without the oh_ prefix:

id="yIQGH4aQWI0"

Make sure that your Sources/OharaYTEmbed.php file has this exactly line of code:

$result = '<div class="youtube" id="oh_'. $videoID .'" style="width: '. (empty($modSettings['OYTE_video_width']) ? '420' : $modSettings['OYTE_video_width']) .'px; height: '. (empty($modSettings['OYTE_video_height']) ? '315' : $modSettings['OYTE_video_height']) .'px;"></div>';


Notice the   id="oh_'. $videoID .'"  part which have the oh_ prefix

Your file should look exactly like this one:  https://github.com/MissAllSunday/OharaYouTubeEmbed/blob/1.2/Sources/OharaYTEmbed.php
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline lurkalot

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 1,496
  • Gender: Male
  • Tinyportal Support
    • guitaristguild on Facebook
    • Tinyportal on GitHub
    • @GuitaristGuild on Twitter
    • Guitarist Guild
Re: Ohara YouTube Embed
« Reply #366 on: April 05, 2015, 04:26:23 PM »
OK, the produced div on the page you linked to still shows an ID without the oh_ prefix:

id="yIQGH4aQWI0"

Make sure that your Sources/OharaYTEmbed.php file has this exactly line of code:

$result = '<div class="youtube" id="oh_'. $videoID .'" style="width: '. (empty($modSettings['OYTE_video_width']) ? '420' : $modSettings['OYTE_video_width']) .'px; height: '. (empty($modSettings['OYTE_video_height']) ? '315' : $modSettings['OYTE_video_height']) .'px;"></div>';


Notice the   id="oh_'. $videoID .'"  part which have the oh_ prefix

Your file should look exactly like this one:  https://github.com/MissAllSunday/OharaYouTubeEmbed/blob/1.2/Sources/OharaYTEmbed.php

Yep it was missing that part.  Actually, Just downloaded your mod again and checked it, and it's also missing from that file.

Edit:  Added the missing code and it's working again.  ;)

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #367 on: April 06, 2015, 11:14:37 AM »
OK, the produced div on the page you linked to still shows an ID without the oh_ prefix:

id="yIQGH4aQWI0"

Make sure that your Sources/OharaYTEmbed.php file has this exactly line of code:

$result = '<div class="youtube" id="oh_'. $videoID .'" style="width: '. (empty($modSettings['OYTE_video_width']) ? '420' : $modSettings['OYTE_video_width']) .'px; height: '. (empty($modSettings['OYTE_video_height']) ? '315' : $modSettings['OYTE_video_height']) .'px;"></div>';


Notice the   id="oh_'. $videoID .'"  part which have the oh_ prefix

Your file should look exactly like this one:  https://github.com/MissAllSunday/OharaYouTubeEmbed/blob/1.2/Sources/OharaYTEmbed.php

Yep it was missing that part.  Actually, Just downloaded your mod again and checked it, and it's also missing from that file.

Edit:  Added the missing code and it's working again.  ;)

Thats because the current download doesn't have that code or any of the js code either, you are basically testing the new version which will have that code by default.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline lurkalot

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 1,496
  • Gender: Male
  • Tinyportal Support
    • guitaristguild on Facebook
    • Tinyportal on GitHub
    • @GuitaristGuild on Twitter
    • Guitarist Guild
Re: Ohara YouTube Embed
« Reply #368 on: April 06, 2015, 04:41:46 PM »

Thats because the current download doesn't have that code or any of the js code either, you are basically testing the new version which will have that code by default.

Yes I did think that might be the case, after I posted.  lol.  But what I can say for sure is it's working nicely now, Thank you.

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #369 on: April 07, 2015, 02:43:44 PM »
Cool, will release a new version shortly.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline SDMiller

  • Semi-Newbie
  • *
  • Posts: 62
Re: Ohara YouTube Embed
« Reply #370 on: April 12, 2015, 12:14:52 AM »
Hi. I have had ohara youtube embed mod for quite some time... and use it rarely... and it used to work.

Just noticed it quit working... so I updated it (mine was out of date apparently, in my package list it was a green dot indicating it was up to date.. which is why I didn't know it wasn't.).

I updated by first uninstalling and deleting the old one... then reinstalling and activating the new version.

Still doesn't work. I just get a black box where a youtube video should be in a post.

Any help?


smf 2.0.9

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #371 on: April 12, 2015, 10:08:40 AM »
Do you have a link where I can see an example?  did you tried doing the edits I mentioned before?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline SDMiller

  • Semi-Newbie
  • *
  • Posts: 62
Re: Ohara YouTube Embed
« Reply #372 on: April 12, 2015, 06:08:41 PM »
Do you have a link where I can see an example?  did you tried doing the edits I mentioned before?

It's data looks like this:
Code: [Select]
[youtube]http://youtu.be/BOGOMIzl7Nk[/youtube]

Tight!

[url=https://youtu.be/BOGOMIzl7Nk]Link[/url], in case that video doesn't play.

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #373 on: April 12, 2015, 08:16:06 PM »
I really need a link to a post with a youtube video.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline SDMiller

  • Semi-Newbie
  • *
  • Posts: 62
Re: Ohara YouTube Embed
« Reply #374 on: April 14, 2015, 09:21:18 PM »
I really need a link to a post with a youtube video.

Oops. My bad. I meant to include that.

Here it is: http://mahjong.us.com/forum/index.php?topic=342.msg477;topicseen#new

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #375 on: April 15, 2015, 12:47:11 PM »
Try the solution IU gave a couple of messages ago.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline wahlmat

  • Newbie
  • *
  • Posts: 6
Re: Ohara YouTube Embed
« Reply #376 on: April 16, 2015, 08:26:45 PM »
Hi! I just set up my SMF forum and one of the first things I tried to do was add a youtube button. It got successfully added, however I have one problem I'm experiencing. When I post a video, there is no "play-button" on the video, or any other controllers. Just a thumbnail, you can click on the thumbnail to start the video however. This is what mine looks like:


This is something like what I expected it to look like:


I really apologize if this issue has been answered earlier in the thread and I didn't see it!

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #377 on: April 17, 2015, 08:52:41 AM »
A link where I can see this?

Most likely you do not have the oharaEmbed.css css file in whatever theme you are using, that file needs to be located at:

/Themes/your_theme/css/oharaEmbed.css

where your_theme is the actual name of the theme you are using.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline wahlmat

  • Newbie
  • *
  • Posts: 6
Re: Ohara YouTube Embed
« Reply #378 on: April 17, 2015, 10:33:19 AM »
A link where I can see this?

Most likely you do not have the oharaEmbed.css css file in whatever theme you are using, that file needs to be located at:

/Themes/your_theme/css/oharaEmbed.css

where your_theme is the actual name of the theme you are using.
Link to my forum is here: hxxp:forum.energydrinkdiscussions.com/index.php?topic=6.0 [nonactive]
I've now at least managed to get a "play" button to show up, however not the usual one. I did extract the file you specified above to my current theme (the core one?). I did also extract the other file from scripts/languages that weren't imported.

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,558
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ohara YouTube Embed
« Reply #379 on: April 17, 2015, 10:35:38 AM »
Quote
The topic or board you are looking for appears to be either missing or off limits to you.
Please login below or register an account with Energy Drink Discussions.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.