Module: Embedded Youtube Videos
Nerull
Joined: 2010-08-24
Posts: 10 |
Posted: Tue, 2010-08-24 06:29 |
I wanted to have videos in a gallery, but don't really have the server for direct hosting. This is my first gallery module, and I wrote it in one night. It's very, very alpha, but it works well enough for my needs. I found that when you access an items page, gallery will try to call the controller in modules/gallery/controller rather than the module's directory, so in order to get this working you will need to create a symlink from modules/gallery/controller/embeds.php to modules/embed/controller/embeds.php I also had to replace the Item model, which is not ideal since it won't track changes the gallery item model, but I couldn't think of a better way to accomplish this. More abstraction in the Item code would help to solve this problem, but that's a bit beyond what I set out to do. The module adds an entry to the 'Add' menu, and takes Youtube video IDs - the 11-character string after v= in youtube URLs. The video ID for http://www.youtube.com/watch?v=MQCNuv2QxQY is MQCNuv2QxQY, for example. This was developed against the latest code in git, and will probably not work with rc2 due to the JSON changes. [old code removed] |
|
Posts: 10
I've been working on rewriting this to remove the need to replace any models, and add support for more video sites, but every idea I try hits a roadblock.
At the moment I've got the basics working, except thumbnails. To show up in albums, embedded videos go in the items table like everything else, but with a different type. By switching the type after saving, I've got past validation and saving on the item model, but I can't find way around thumbnail URLs without trying a completely different approach.
The fix is to simply add a default type to the thumb_url and thumb_path functions, but I don't want to replace the entire item controller just to do this.
Does anyone have any ideas?
Latest codebase is at http://github.com/bowlesjd/gallery3-contrib/tree/master/modules/embed_videos/
Posts: 10
Solved. I happened to look at the exif module and realized I could use a theme helper to conditionally insert code into the photo view. I now store embedded videos as a regular photo, all gallery code sees it no differently, and no Gallery code is replaced. When the photo view is loaded, the current Item is checked for a matching Embedded_Video model, and if found, a jQuery script is inserted to replace the photo with the video embed code.
I have also written it so as to support video sites other than youtube, and decode full URLs rather than just the video ID. I have not yet implemented any other sites, but it shouldn't require any API changes. I'll put a demo up in a few minutes. I think this is ready to be pulled into gallery_contrib.
Posts: 10
http://img.wockets.org/index.php/John/Video-Tests
Posts: 7994
Nice! Great work, Nerull. Should I pull this into the main gallery3-contrib repository now?
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git
Posts: 27300
Nerull,
Let me know if you need a hand creating a codex page for documentaion of you module.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 10
Yeah, it's ready to be pulled, I think.
Posts: 6
Nerull, are you thinking of including support for Vimeo?
Thanks
Posts: 10
Vimeo shouldn't be a problem. I'll look into it.
Posts: 10
Added Vimeo support, sent pull request.
Posts: 7994
Pulled!
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git
Posts: 6
Thanks Nerull! It looks like when I embed both youtube and vimeo now, I just get the first image from the video. Gallery treats it as an image and just enlarges it with lightbox when I click it.
Posts: 10
Could you post the html of the image page? I just tested it on a fresh install and it works here.
Posts: 27300
Since there was no grab for documentation I am going to do it.
I have downloaded and installed the module. Every time I try to add a video using the example I get
[img]http://gallery.menalto.com/files/invalid_URL.png[/img]
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 424
@ Floridave...you're only supposed to add the text after the v=
"The module adds an entry to the 'Add' menu, and takes Youtube video IDs - the 11-character string after v= in youtube URLs. The video ID for http://www.youtube.com/watch?v=MQCNuv2QxQY is MQCNuv2QxQY, for example."
Posts: 27300
I did try that as well. Still the same error; invalid URL.
[img]http://gallery.menalto.com/files/youtubeID.png[/img]
A suggestions would be to not call it a video URL but some thing else then since it is not a URL.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 65
I was able to reproduce this problem briefly last night on a clean install of the latest GIT code and the latest embed_videos code. It would appear from the code that the intent is now to specify the full URL (i.e. youtube.com or vimeo.com).
After a couple of attempts to embed, I started to see if I could debug the php code. When I got my debug hooks in place, I reran the embed code and it worked. So, my guess is that it has something to do with the initial install or embedvideo database table setup. I didn't have time to get any further. That said, once I got one video to embed I could not get the problem to occur again.
@anselm13, the only way I could reproduce the problem you experienced was to deactivate the module. The images/thumbnails persist from the embedded youtube video but the hooks in place to replace with the embed video code is no longer active (so G3 handles it). Seems like valid behavior to me...
I'll let you know if I can pinpoint the cause of the invalid url issue.
Posts: 6
I isolated the problem to the xmp module (http://kott.fm/tomek/plugins-extensions/module-xmp/). When xmp is enabled when I embed a video, the photo is not replaced with the video. When xmp is disabled when I embed a video, it works.
Incidentally, I also have an issue right after the embed where the window remains and things appear to have hung. I cancel out the window and then refresh the browser and the video appears. So everything works, just get this issue and that behavior appears on a clean install with no other additional modules enabled.
Posts: 10
I am hoping you can help me. I am running Gallery 3.0 RC2 and everything is working OK now. I decided to do Video's and when trying this module I cannot get it to work.
When I go to add a video, I put in the information CORRECTLY however every time I click add I get a pop up and the button cannot be clicked.
I added a screen shot to show what I am talking about. When this pop up shows, when I put my cursor over the "Add embeded videos on x" I get the 4 arrow cursor and the button IS NOT clickable.
Any ideas?
Posts: 6
I get that too if I only enter the youtube video ID in the Video URL field. If I add the full youtube URL, then the embedded video gets added (though I have to press cancel and refresh the browser).
Posts: 10
The module definitely needs some better error handling, however using it with RC2 is unlikely to work, due to the JSON changes. The module was developed against the Git version.
Posts: 6
I no longer have the issues now that I've upgraded to the g3 git version. Still have issue with xmp incompatibility, though disabling it during the embed and then re-enabling afterword works.
Posts: 27300
I am still unable to add a video form youtube with this ID/URL:
MQCNuv2QxQY
or this one:
[img]http://gallery.menalto.com/files/youtubeID.png[/img]
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 424
Dave..try the entire url.
I tried this, as rlparadise pointed out, and it worked.
Posts: 27300
I have tried:
http://www.youtube.com/watch?v=MQCNuv2QxQY
www.youtube.com/watch?v=MQCNuv2QxQY
youtube.com/watch?v=MQCNuv2QxQY
MQCNuv2QxQY
and many other combos Still get invalid.url error.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 25
I still can not get it to work
Posts: 2
I'm going to chime in with a "me too" here as I've not seen any additional commentary on either changes to this module or possible fixes.
I'm getting the exact same error as Dave and have tried all variations on a YouTube embed URL with different files, and have always gotten the "invalid URL" error. I even tried a completely blank install with the latest experimental versions of everything (newly created database, embedded video as first thing I tried to add, etc.) and still error.
Is there an undocumented dependency, a SQL trick to remove and re-install the database tables needed, anything someone has found to make this thing work?
I'm only using Gallery for a small, .htaccess protected site for family but someone was featured in a recent news story and it would be nice to embed the video.
Thanks!
_____________________________________________
gertie. not a dev. good at breaking things. sometimes clever enough to fix them.
Posts: 1
Is there any resolution to this, I get the same issue below, please help.
Posts: 7
I was experiencing this as well. Changing embed_videos_theme.php to put embed_video_js.html in the footer instead of the header fixed it. In a default G3.0.1 install with embed_videos added from git, the script is put in the header before jQuery is loaded, I think. I'm not 100% sure on the internals, but Firefox error console was showing a "$" is not defined error, which went away once the script was placed in the footer.
Posts: 29
fatcatfan, I am getting the same error in Firefox, but I am not sure how to change the embed_videos_theme.php to put the embed_video_js.html in footer instead of the header. Can you give me a little more details so I can fix this error. Thank you.
Posts: 29
Nevermind. I got it. Changed "static function head($theme)" to "static function footer($theme)". Thank you.
Posts: 30
Guys, Thank you.. I also was able to change the:
"static function head($theme)" to "static function footer($theme)" in /helpers folder file: embed_videos_theme in the embed_videos module.
1. Is there a way to remove that video icon that gets attached to the Generated Thumbnail.
2. Is it possible to change the Thumbnail Image:
a. with my own image that I would grab from video,
b. add a slider in the video, to point and create a snapshot at that specific moment.
Posts: 30
What is the difference between "Video URL" and "Internet Access" on the Menu? Do we need to fill in both?
Posts: 10
To the best of my knowledge, the "Video URL" is the actual URL of the video (the "embed URL"). The "Internet Address" is internal to Gallery - simply how you'd like the embedded video page to look in YOUR URL. For example: http://www.example.com/MyVideoAlbum/MyVideo/ - "MyVideo" would be the "Internet Address" in the previous example.
Posts: 10
For what it's worth, I was finally able to get this module working with Vimeo. I'm by no means a programmer, developer, or anything like that - so take this with a grain of salt. I downloaded what I think was the latest version of this module from GitHub. Initially, I was getting the "Invalid URL" message referenced above. Taking a quick look at the relevant code, I modified line 80 of /controllers/embedded_videos.php to this:
if(preg_match("/(\d+)/",$url,$matches)) {
Which seems to work with Vimeo videos. The previous code was apparently returning more than just the video ID (/video/video_id_number). The regex above, I think, will just return any numbers in the URL, which in the case if Vimeo, I think would be limited to the video ID. So, I'm now able to embed my Vimeo videos - the proper dimensions are applied, the title, description, and a thumbnail are all generated.
One potential problem I'm having now - as a "Vimeo Plus" user - I'd like to set my videos to "Hide my videos from vimeo.com" and limit the embedding of videos to my domain only. Changing this setting appears to effect the "Simple API"'s ability to pull information about the video though. Line 83 of the aforementioned file: $sxml = simplexml_load_file("http://vimeo.com/api/v2/video/$video_id.xml"); - returns an empty XML file when the video permissions are set to private on Vimeo. I suspect the solution is a bit complex, and involves OAuth and the "Advanced" Vimeo API.
Anyway, I'm happy for now. I've got my HD videos embedded in my gallery, so that's a start.
Posts: 1
To dreamernyc and everyone else that has been trying to figure out how to do away with the Film Strip icon or to replace it with one of your own...
I haven't found where in the code it is creating the thumbnail with the film strip, but the film strip icon comes from the embed_videos/images/embed_video_icon.png. Simply pull the file into a program like Photoshop and turn it into a pure transparent image. Or, if you want it to look different, modify it and save it.
I tried renaming the file to solve this, but the script is looking for this file. So, the only way around it that I've found is to give it a file with that name but containing the image you want.
No offense to the creator of this wonderful module (I'm on godaddy so I don't have any other option than videos hosted elsewhere), but I just didn't like the film strip icon pasted right over my video thumbnail.
Dream, using the same approach I took with the film strip icon, to change the thumbnail pulled for the video... you could provide it with an image of the same name. Though I haven't tried it you would most likely need to make sure it's the same dimensions in size. Though when I click the edit photo option after adding the video, it looks like it gives me the option to specify the thumbnail image...
Anyways, great job on the module. I've been loving it!
Posts: 14
I got it working after some trial and error. See the attached image. Thanks all!