Hello, my name is Aaron Winborn. I am a developer for Advomatic, the author of Drupal Multimedia, and a contributor and a co-maintainer of several Drupal modules, including the Media suite of modules.
Today, I will demonstrate a new feature of the Media: YouTube module: browsing and searching videos directly from YouTube, in the media browser itself. So first, let’s set up our environment.
We are assuming that you already know how to install Drupal. If not, you can find information at Drupal.org.
So right now we are at the modules administration page. We are interested in the modules under the Media package. You will need to install and enable the File Entity module (version 7.x-2.x), and the same version of the Media module.
We will not enable the included Media Field module; it is there for legacy purposes, and has been deprecated in favor of core’s File Field.
The Media Internet Sources module, included with the Media module, is a dependency of the Media: YouTube module, so we will enable that.
Next will be the Media: YouTube module, also version 7.x-2.x.
Finally, we will install the WYSIWYG module.
Let’s start by configuring WYSIWYG. We do that by going to Configuration > Content Authoring > WYSIWYG profiles. Note that I have also installed and enabled the Admin Menu module and the Admin Menu Toolbar module, which gives us the fancy drop-down menus for administration that you see here.
Now in order to use WYSIWYG, you need to have also installed a third-party WYSIWYG library, such as CKEditor or TinyMCE. You need to follow the instructions with the WYSIWYG module to install that, although it is quite simple actually. You just download and unpack the file into the sites/all/libraries folder. You can see that I am using CKEditor here.
The WYSIWYG module allows us to set up profiles for the various text formats on our site; in this demo, we will edit the Filtered HTML format.
Open up the buttons and plug-ins field set next. Then check the Media Browser check box. That will add the media browser button to our WYSIWYG editor, which we will see soon.
In order to use that however, we need to configure the filter in question. In fact, I believe that if we do not do this step 1st, we will get an error message, complete with a link to the format configuration page.
On this page, we need to check the box next to “Convert Media tags to markup”. That is the answer to the number 1 support question that we get in the Media queue, which is, “Why is there bracketed goobly gook instead of my images?”
So now, as we will see, everything should be working now. So let’s test it.
Here on the create article page, we see a fancy button on the body text area! Let’s click it.
And there we go.
These are thumbnails being pulled directly from YouTube. How about that?
And there is even a ghetto pager, or at least previous/next links.
And you can also search YouTube directly from our browser.
So now we will select a video and submit it. Add a title and save the node. And there we go.
And that’s it really. Well, almost.
There are some more settings, specifically here to control which tabs show up for WYSIWYG. Note that at the time of this demonstration, you will not have this functionality unless you install the patch over at node 1434118.
To complete the demo, we will also do the same for fields. Let’s add a field to hold YouTube videos. We will call it Media, and it will be a file field with a Media file selector widget.
Here, let’s reorder it as well for the demo.
We leave everything at their default settings.
Hold on, I forgot that we need to allow the YouTube URI scheme. And the video file type.
So now we will create a new article, and select the media.
And here we have all the tabs available to our browser, including the new and improved YouTube tab.
And also, let us look at another new feature of the media module: My files!
This has been a long-awaited feature for the Media module as well.
Now here comes the 2nd most asked question in the support queue: “How come there is a link to my file, rather than the file itself?”
Let’s just fix that now.
Now we are in the file type administration page, where we can configure the display for each of our file types. Note that we can also add fields to our files, although we are not going to do that in this demo.
We will jump to the video display...
No, we want to make sure that our large formatter is set up properly for YouTube. And it is, so let’s set up that as the formatter for our Media file field.
And there it is, as a generic file, which is simply a link to the file stream itself. We will change that to rendered file. And then we set the view mode to large.
While we are in there, we can do the same for our teasers. We will just set that to the preview view mode, which by default will display a thumbnail.
Whoops, I forgot to save it. Let’s just do that again.
I sometimes hear a complaint that jQuery Media can't be used for both audio and video on the same site, because it makes the player too large.
This is not true at all. Although it does currently require some finagling.
I plan to reconfigure the module soon to make it easier to pull in the proper configurations for audio and video. Meanwhile, here's a quick hack.
1. Enable the FileField module and create types for your audio and video clips.
2. Enable the jQuery Media module, and configure it for your custom video node type. We won't turn it on for the custom audio type, because we'll be calling it manually, coming right up.
3. Make sure you have a media player installed in the file directory and configured properly at /admin/settings/jquery_media (or /admin/settings/jq if you're using the jQ module). I suggest JW FLV Media Player for now, as Drupal's Media Player doesn't yet support audio. Just stick it in the site's root directory to work automatically, or put it wherever you want and configure jQuery Media with the proper folder.
4. In your theme's template.php, create the following function, replacing 'custom_audio_type' with your site's custom audio content type.
Here's a two-step formula for simple inline video, assuming you have jQuery Media installed on your site, doing both of these configuration steps from Administration > Site configuration > jQuery Media (at /admin/settings/jquery_media):
Open the Node types field set and check the node type for which you wish inline video.
Open the Classes field set, and enter .node .content a in the Media class text field. (You can separate classes by comma if you want to keep existing class invocations.)
Then just add a link to a video inline to your content. Doesn't matter if it was uploaded with the node or through FTP. (The second step assumes you're using the Garland theme, or another theme that uses that CSS class designation. You might need to check the node in FireBug if you're not sure.)
Notes: This method is easy, though admittedly a bit heavy-handed. The down-side is it will be invoked regardless of whether the node actually contains a video link (fortunately it's a lightweight jQuery plugin). If you want more fine-tuned control, you can skip the first step, use a PHP filter, and just invoke it manually from in your node, using jq_add('jquery_media') (assuming you have the jQ module enabled; jquery_media_add(); otherwise). (I don't actually recommend that, because of all the security issues involved. Just stick with the first method.)
The cool thing is this will work with pretty much any media player, including the upcoming Media Player for Drupal!
If you haven't already, make sure to check out Sean Effel's latest Filefield + jQuery Media screencast! As was his earlier Feed API + Emfield video tutorial, this is a joy to watch: he does things in thirteen minutes that took developers hours or more to do even a few short months ago, and that's with a running commentary! By the end of the video, you will have learned a simple way to upload a video (using the light-weight File Field module) and have it properly displayed without any messy configurations or external libraries. Plus, as the recipe uses the jQuery Media plug-in wrapper module, the display will be cross-browser compliant and accessible.
Next on my plate for jQuery Media is to have it be easily added to nodes on an individual basis, so that a media clip could be linked inline and automatically turned into an embedded display. Additionally, I would like to make it an option for Views as well, perhaps as an additional setting. (Although even without that, my upcoming book Drupal Multimedia, to be published in September, goes into some detail about how this can already be done, to create powerful video and audio playlists.)
He shows you step-by-step how to take a video feed from Blip.TV (or any other provider supported by Embedded Media Field) and aggregate it on your own site, videos, thumbnails, and all, automatically turning the remote videos into nodes on your site, ready for theming, comments, and anything else you want.