MediaElement should support overwriting the YouTube player as demo'd here:
http://mediaelementjs.com/examples/?name=youtube
This is discussed in more detail here:
http://johndyer.name/html5-video-wrapper-for-youtube-and-vimeo-api-media...
Right now it seems we need to use the Media: YouTube module with Media to get a YouTube player which is fine, but I'm looking to develop a consistent player whether a local file is being played or a remote YouTube video - ME can do this, but it doesn't seem the ME Drupal Module is ready for this. It looks like the <video> tags need to wrap a <source> tag with the relevant YouTube URL. Right now, the module produces a <video> with src="" attribute which seems to be breaking with external URLs like YouTube.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | youtube_source-1802388-7273138.patch | 1.02 KB | brockfanning |
Comments
Comment #1
chrisrcooper commentedI've hacked around this with a temporary solution that only applies to YouTube and only applies to Video:
In mediaelement.module, original:
to:
This just checks for "youtube" in the source, and if it's found, moves the "src" attribute to a
<source>tag within the<video>tag which ME understands correctly and will wrap itself around the YouTube video. Tested in FFX/Webkit/iPhone/Android for local media + YouTube. There's a far better solution somewhere for someone that understands ME and the Media module better.Comment #2
jsmm commentedSince I get a blank screen and a download link when adding a youtube url to media, I assume Mediaelement cannot stream youtube videos, is this correct or do have I missed some configuration step?
Comment #3
brockfanning commentedAfter adding a Link field and using the theme function override posted by chrisrcooper, it does play Youtube videos. All you have to do is paste the URL of the Youtube video into the link field, and set the link field's display to Media Element Video.
Since the code in #1 doesn't alter the normal behavior of the module, I think it makes sense as an added feature. I suppose the other option is to revamp the architecture of the module and make the Youtube functionality into a plugin type of thing. But I like the simplicity and out-of-the-box-ness of this module, so would be more inclined to see it added as a bonus feature that just works. I'll upload chrisrcooper's code as a patch.
Comment #4
brockfanning commentedHere's a patch using the code in #1. The only change was to look for "youtube.com/" instead of "youtube", just on the off-chance a local video file has the word "youtube" in it.
Comment #5
diwant commentedI tried this patch and it worked for me. Thanks all!
Comment #6
mickfuzzz commentedWorks for me too.
It's good to have a solution that works for all files and embeds.
Comment #6.0
mickfuzzz commentedAdded code wrappers
Comment #7
mailfox commented#1 Works for me
Comment #8
ErwinS commentedAs i do not use Vimeo vids yet, it works fine for me!
Comment #9
martin.l commentedWorked for me as well. Why can this not be committed to -dev?
Comment #10
matt bUsing the Link field as per #3, I was getting the error
Notice: Undefined index: description in mediaelement_field_formatter_view() (line 111 of ......./sites/all/modules/mediaelement/mediaelement.module).Line 111 is
$display['settings']['description'] = $item['description'];which doesn't exist if you are using the Link module.I've change this line to
And no longer get the error.
Comment #11
matt bI notice that I cannot go fullscreen when playing a YouTube video through MediaElement, but can if playing an uploaded video? You can play fullscreen on the MediaElement YouTube API example.
Comment #12
mastoll commentedNot working.
I followed #3's path:
"All you have to do is paste the URL of the Youtube video into the link field, and set the link field's display to Media Element Video."
I get a the black box (presumably the player) with a link that takes you to the YouTube page itself.
Equally frustrating, if I use a file field, I cannot upload a YouTube video. I receive the error, "Unable to handle the provided embed string or URL."
I realize these sound like different issues, but I'm wondering if in fact they are related. I am using the Media module. Do I need a YouTube module too? Is there a switch I need to set somewhere that makes MediaElement pay attention to YouTube URLs?
Comment #13
brockfanning commented@mastoll: Probably a dumb question, but did you apply the patch in #4?
Comment #14
mastoll commented@brockfanning:
I did not have Media:YouTube installed before.
Now, I have installed versions Mediaelement 7.x-1.2+2-dev, Media YouTube 7.x-2.0-rc4+14-dev, and Media 2.0-alpha3+79-dev with patch from https://drupal.org/node/2120307:
- without patch from #4, using a file field/media selector widget, MediaElement field formatter: a black box the size of the video displays with a white-text link in it to the YouTube page.
- with the patch from #4, all else the same: the video displays in the left 70% of the player box and the full-screen toggle doesn't work; it's like a player within a player but the inner player doesn't have the controls
- with patch from #4, all else the same AND the patch from https://drupal.org/node/1119570: the outer player disappears s.t. the overall dimensions of the player box equal the inner player i.e. it's too small, but the controls are there and they all work including the full-screen toggle AND thy are standard YouTube controls, not themed as Mediaelement would have them.
- removed patch from #4, keeping patch from node/1119570: no visible changes, in fact I cannot change the size of the player in Manage Display. But I do get massive Undefined Index errors in the media_youtube\themes\media_youtube.theme.inc.
Comment #15
adam_bearI fixed Youtube and a few other things...
https://github.com/ablank/imediaelement.module
Comment #16
mtoscano commentedI am using adam_bear version available at https://www.drupal.org/node/1802388#comment-9768483 and it is working great. Ideally can become new recommended version after 3 years without a new release.
Comment #17
robbielink commentedadam_bear version looks good but wondering if I have to edit all posts using current version of mediaelement to use this improved version.
Comment #18
adam_bearGlad y'all like it :)
The field display for each content type (Article, Basic Page, etc.) will need to be changed, but posts don't need to be converted individually. There is more detailed information on how to implement @http://ablank.github.io/imediaelement.module/.
Comment #19
prineshazar commented@brockfanning thanks! #4 worked for me. Mediaelement version 7.x-1.2.
I also wanted both youtube links to work, the share link and the normal URI in the address bar when viewing a youtube video. The motivation behind this was to make things a little easier for my client, as they would often forget to use the 'share' link.
After aplying patch #4, i added code below:
In mediaelement.module
This takes into account query param v, so you can add a youtbe link like: https://www.youtube.com/watch?v=t5tbOSyyxTY rather than https://youtu.be/t5tbOSyyxTY .
Comment #20
jnettikTesting the current version of the plugin and the module, YouTube videos play fine. Closing.