WordPress YouTube playlist plugin

WordPress YouTube playlist plugin

Thursday, October 8th, 2009 in Mootools, PHP, Wordpress

Wordpress YouTube playlist plugin WP MyTube is the WordPress plugin implementation for YouTube MooTools player embed with attached playlist. Simply put, this plugin will allow you to easily insert YouTube videos into your WordPress blog posts based on username or video id only. The attached playlist will display the user videos giving you the possibility to add several videos and only one player in your blog posts. This is very useful, for example, if you are a publisher that wants to display his youtube videos into a blog post.

Videos are added to your posts when you either add them or on edit. No special other settings for it except the stylesheet if you want to change the looks. To add videos to you blog posts, when you add/edit a post you’ll notice a new “add media” icon in shape of a tv. Simply click it, fill in the necessary information and the plugin will add the custom code to your pages. Hit save and that’s it.

If you want to add more than one player into a single post, well, you can do that. The plugin allows any number of players to be displayed in a single post without problems.

Further more, you can style the player to have a default look and if you want a second player to have a different look, you can add custom CSS class to it by passing the class name when you insert a new player.

Installation

Simply unzip the plugin archive, copy wp_mytube folder into your plugins directory from your WordPress blog, activate the plugin and you’re good to go. No other special settings required.

Styling the player

Please remember that you’ll need to keep the classes from stylesheet, meaning you’re not suppose to change their names. You can style the base player in any way you want to. To style a player in a custom way, use a different css class and set the player and playlist css as descendants from that class. You can find a custom styled player at the bottom of the plugin stylesheet.

Another thing to take into account is that the Youtube video player will take the same width and height as div element having as class .MT_youtube_player

Adding videos

You can add videos to your blog posts by either specifying a valid YouTube username or by passing video ids. If you choose to pass it video ids, they must be entered separated by | (ie: someId|otherId|thirdId ). If you enter both username and video ids, only username videos will be displayed, never both. Basically, it’s either one or the other.

Except for username and video ids you can set the number of videos to be retrieved, what to display when page loads ( player or playlist ), retrieve only embeddable videos, some text messages and the custom css class if you want the player to have different styling.

Troubleshooting

If you are using prototype based scripts into your pages, there’s a high chance that either the MooTools script powering the plugin won’t work or your protoype scripts will start outputting errors and stop working. MooTools and prototype don’t belong together.
If you’re using jQuery based scripts in your pages and the plugin doesn’t work, try using jQuery.noConflict() but beware that this might lead to errors for your existing jQuery scripts that don’t support it.
If you’re using MooTools scripts and have trouble with the plugin, first of all make sure the installed scripts don’t use MooTools 1.1. The script powering the plugin is developed with MooTools 1.2.

Updates

January 15′th 2010

- possibility to add videos from YouTube playlist ( will be overridden if user is set and will override any video ids you set )

Demo

Here’s an example with videos retrieved from GoogleDevelopers.

Download plugin

Was this useful? Show your support.

digg WordPress YouTube playlist plugin

50 comments

  1. [...] should be the first review of WP MyTube since it came out just hours ago.  This free WordPress plugin gives you the ability to add YouTube [...]

  2. Dustin says:

    Very nice plugin. Awesome actually. Is there a way to add it to a template file using a php function rather than adding it to a post or page?

    Thanks for your help

  3. Chris says:

    Hi!

    I like this plugins but if i insert videos which have a “-” in the id they’ll not be displayed. and all following videos are also not displayed. What can i do.

    • Hi Chris,

      Thank you for pointing this issue to me. I wasn’t aware of it. Anyway, it got solved so please download the plugin again and update any codes you already have in your posts. By simply updating the plugin, things won’t work, so again, update the codes.
      The problem with hyphens in movies ids was that in order to display the individual videos, a search is performed based on the ids passed from your posts. When Youtube encountered a “-” character, it treated it as bool not and dropped whatever was after it. What I did was to wrap any ids having “-” in double quotes and with that it got solved. Try it now and let me know if you encounter any more bugs. Again, thank you for reporting this.

  4. Chris says:

    Hi Constantin!

    Thanks for your quick answer.

    But i can’t get it to work.
    - I downloaded the plugin again from this site
    - I deleted the old plugin folder completly
    - I uploaded the new one
    - I deleted the MyTube code from the page (it’s only one) and created it again with the small icon

    but nothing changed. The code is the same as before and videos with “-” and everything after it are still not displayed.

  5. Chris says:

    Hi! So first… i did a really bad hack that fits my needs, maybe you could implement it in a clean way later. I changed the url in the mootols script so that it fetches a playlist i created in youtube. So i can decide which videos should be displayed via my playlist.

    The code which is added (before i did this) was:

    [MyTube movies="bCxiC6SM5fw|dHxhbd3moMI|9MjQ1chmRFk|dj4nURf6zMw|zWAUdGA6J4s|GSZChSp8wiI|lDM8g-YWNVE|tvfXO5QFPbs|NgwYXwoPshc|U1-B9tvvyTc|1iYJA4cznOk|ncihUGjeWhc" list="30" displayOnLoad="2" onlyEmbeddable="1" loadingMessage="Loading, please wait..." togglerText="toggle playlist"]

    i got my hacked thing online at http://spacetoasters.de under “für beides”

    • :) had in mind that exact thing, just didn’t had the time to do it. It will be available though soon ( probably by the end of this week ). I can e-mail you when it’s done if you’re interested.
      Now, about the updated plugin. If, when you add a code in a post, the code displays the values enclosed in ” ( double quotes instead of ‘ – single quotes; ie: movies=”bCxiC…” instead of movies=’bCxiC…’ ), you got the old version of the plugin. Even if you downloaded it, your browser might get it from its cache so try to clear cache first and download the plugin again. If you use Firefox with webmaster toolbar, under Disable, the first option is Disable Cache. Let me know.

  6. John says:

    Hi,
    Is there any way of adding youtube tags to the playlist so I can get a more targeted list for users.
    Thanks

  7. I try but the original order tha I put de IDs is not the same displayed

    I put: 1|2|3|4|5

    Displayed: 4|5|1|3|2

    • That happens because when you pass those ids, the api actually performs a search based on them and returns results into the order established by the api. It would be possible to order the response but for best results, try using playlist ids generated on YouTube instead of passing ids.

  8. Chris says:

    Hi there!

    I am using WP Mytube on our new WordPress installation, but i can’t figure out, where i can find the settings. I just want to display the list and not the single video at start?

    Greatz

    Chris

    • Hi Chris,

      There’s no “global” settings page. When you click the little tv icon and the page for configuring a player displays, you have the option On page load, display:. Simply select playlist from there and that’s it. Let me know.

  9. Dale says:

    This plugin is exactly what I have been looking for! However, I cannot get it to work. I inserted the code with the plugin (tried several different times) but the player just comes up blank and the playlist link is a blank link. Any help would be greatly appreciated!
    http://buildpeakcompete.com/bpctv/

    • Hi Dale,

      Glad you like it, very happy to hear this. About your problem, this is happening because you also run jQuery scripts in your pages and the MooTools version from this script conflicts with jQuery scripts. What you can do is one of the two things:
      1. Use jQuery noConflict() for any jQuery scripts you’re running
      2. Download MooTools Core and overwrite the file inside wp_mytube ( path is wp_root/plugins/wp_mytube/scripts/mootools-1.2.3-core.js ) with the one you downloaded. Remember to name the new file same as the one you’re replacing or to change the file name inside the plugin file.
      3. Let me know if it works or if you need any help.

      • David Cohen says:

        Hi – I’m trying to get this to work (thanks for creating it!) here -> http://www.techstars.org/thefounders2010 – the player doesn’t show up, so i’ve downloaded the new 1.2.4 mootools core and replaced the file in /plugins/wp_mytube/scripts as instructed, but still no joy. any other ideas?

      • Geoff says:

        I am having the same problem.
        Inserted code: [MyTube movies='T2g0VlCqbQo|Av0CQ4MDgVI' list='' displayOnLoad='2' onlyEmbeddable='1' loadingMessage='Loading, please wait...' togglerText='toggle playlist']

        I have replaced the “scripts/mootools-1.2.3-core.js” with the more recent 1.2.4 version and renamed it to the 1.2.3 file as required.

        I also tried the noConflict JS and that did not work.

        I love the plugin and was excited to see it, but not having it work for me is a bummer :(

        See page at: http://dancelounge.com.au/uncategorized/temp/ password: mytubeplugin

        Can anybody offer a solution please?

        • You have JavaScript errors on that page related to both Cufon and MooTools Core. What exactly you downloaded from Moo Core? This doesn’t look like a serious issue so don’t worry, we’ll figure it out somehow :)

          • Geoff says:

            I managed to fix it!
            The error was due to a plugin called “JavaScript to Footer” which is used to load pages faster.
            I’ve disabled the plugin and it works fine now.
            Thanks for the prompt reply!

  10. obvyah says:

    hi Constantin!

    When I insert the playlist code into the post, It displays the playlist successfully.
    however, when I click any videos, It always plays the first video..
    but I can’t find the problem..

    thank you for your answering!

    Obvyah

  11. kien says:

    I got error:

    Warning: array_combine() [function.array-combine]: Both parameters should have at least 1 element in C:\xampp\htdocs\wp\wp-content\plugins\wp_mytube\wp_mytube.php on line 83

    Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\wp\wp-content\plugins\wp_mytube\wp_mytube.php on line 86

    Warning: array_key_exists() expects parameter 2 to be array, boolean given in C:\xampp\htdocs\wp\wp-content\plugins\wp_mytube\wp_mytube.php on line 95

    How to fix it?

  12. Kim says:

    I have seen this issue posted here and have tried a few tweaks, but not sure why I still cannot get it to work properly. I have multiple videos in the playlist, which displays properly, but only the first one plays when any of the videos are clicked.

    Movie cue is listed like this:

    I am using the application on two different sites, both do the same thing. I seem to remember that, at one point they did work correctly. I have not altered the scripts, so not sure what I need to do. Can you take a look?

    One of the pages where I have the player is here: http://www.mykelhawke.com/gallery#video

    Thank you for your help!

  13. Dmitry says:

    Hello, I`m using MyTube script without wordpress.
    There are only 2 options: user, or video “ID”-s.

    But plugin has ONE MORE OPTION – YouTube Playlist.

    Can you halp me? How can i generate ID-s from YouTube Playlist? Thanks!

    • You don’t generate them. Whenever you create a playlist in YouTube (under your user for example), that playlist has a unique ID. To output the contents of that YouTube playlist, pass the playlist ID to the plugin.

  14. Dmitry says:

    Sorry, i`m from Ukraine and my english is not so good :)
    Are you talking about mootools plugin, or about wordpress plugin?

    WordPress plugin has got 3 lines for options: 1 – user (or) 2 – playlist (or) ID, 3 – movies

    But here: http://www.php-help.ro/mootools-12-javascript-examples/youtube-player-embed-with-attached-playlist/

    I can see only 2 options:

    1)
    2)

    but there is no something like: .

    I am using mootools plugin outside the wordpress plugin.
    Could you please help me?

  15. Dmitry says:

    {‘list’:’50′,’user’:'metallicatv’}
    {‘movies’:'someId|someOtherId’}

    I forgot to uncomment the strings :)

  16. Dmitry says:

    but there is no something like: {‘list’:’50′,’playlist’:’MyPlaylistID’}

    • Got it now. I was talking about the WP plugin but it looks like you want to use it outside WP. What you can do is this: download the WP plugin, get the scripts from the script directory from inside the plugin and use those scripts in your implementation. You don’t need any php files or anything, just the js files that you need that you must replace into the stand-alone version. I must remember one of these days to update that script too, sorry about this.

  17. Dmitry says:

    Oh, thank You! ))
    It Works :)

  18. Dmitry says:

    No…… it does not works in IE!!!!! (((

  19. Dmitry says:

    It`s okay. Thank You for your work )

  20. Angela says:

    Hi there,

    Thanks for your awesome plugin! It works perfectly, until i get to 10 video’s or more.
    I only get it to upload 9 videos, en the other ones aren’t showing.

    Can you help me?

    Thanks,
    Angela

    • The videos are displayed by querying YouTube for the ids you pass to the script. There is a limitation to the number of ids you can query for that’s why it doesn’t display all videos. Sorry about this, it’s a limitation from YouTube not something from the script itself.

  21. Daniel says:

    Hi,

    is there a way to print the title of the videos above or below, instead of using the tooltip?

    thanks Daniel

  22. I’ve been trying WP MyYoutube for the last couple of days. I’m able to use the “user” argument successfully. However, when I use the playlist argument, my result is a black screen with no videos. My playlists are filled with videos that are not mine. Does it make any difference?

    This is the code: [MyTube playlist='PLB8FFCACF2FA0BC6B' list='12' displayOnLoad='1' onlyEmbeddable='1' loadingMessage='Loading, please wait...' togglerText='toggle playlist']

    And here’s where it is inserted: http://wcabral.com.br/videos

    Thank you

  23. Leandro Aispuru says:

    Hi! I installed the plugin but i do not know how to embed videos or playlist!
    Where can i find examples of the shortcode and its parameters?

    Thanks in advance!

    • When creating or editing new posts/page, you should have a little TV icon above the editor. Click it , fill the params and that’s it. Shortcode should look something like this:

      [MyTube user='my-user' list='5' displayOnLoad='2' onlyEmbeddable='1' loadingMessage='Loading, please wait...' togglerText='toggle playlist' customSettings='my-class']

Leave a comment