MyBB Community Forums

Full Version: Help - New YouTube Support
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I have recently updated my forum's embedded YouTube code, so that it matches the newly released video player than YouTube is now using (which allows me to access full screen and HD quality controls).

Here is the old YouTube code (in video_youtube_embed):
<object type="application/x-shockwave-flash" class="video_embed" style="width: 450px; height: 366px;" data="http://www.youtube.com/v/{$id}"><param name="movie" value="http://www.youtube.com/v/{$id}" /></objec

And here is the newer, better code:
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/{$id}" frameborder="0" allowfullscreen></iframe>

Here is one problem I am running into when using the New Player: When a user tries to embed a YouTube video that has disallowed remote embedding, it only shows the following error:
[attachment=22790]

The error does not link to a YouTube page, so the video is effectively useless (my users would have no idea what video it was supposed to display).

The old code works differently, however. It would display something like this:

[attachment=22791]

The old way is much more useful, because it links to the YouTube page to view the video directly.

Does anyone know how I can fix this so that when a video is not embeddable, it will simply link to the Youtube video page? I know the old version works just find like this, but I need the newer version to act the same way.

Thanks!
For anyone interested:

I made a temporary fix that simply provides a link to the original YouTube page, just in case the video does not load properly. Here is what it looks like:
[attachment=22804]

Here is the code if you would like to add this yourself:
<table border="0">
<tr>
<td valign="top">
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/{$id}" frameborder="0" allowfullscreen></iframe>
</td>
<td valign="top">
<a href="http://www.youtube.com/watch?v={$id}" target="_blank"><img src="/images/youtube.png" valign="top"></a>
</td>
</table>

I found the YouTube icon on IconFinder:
http://www.iconfinder.com/search/?q=youtube

I hope this helps some people, but I would definitely love the see the official MyCode be updated properly.