Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

YouTubeGallery and 2.4.2


Go to End
Reply


41 Posts   6693 Views

Avatar
martbarr

Community Member, 53 Posts

21 October 2010 at 7:05am

Edited: 21/10/2010 7:05am

Hi

Is this working?
I've downloaded the latest daily build.
A few careful var_dumps show me data coming coming in including the html describing the videos I've asked for, but then all I see is "no videos returned" (or whatever the message is).
(xml handling is perhaps out of date?)

Do I need to start putting together something of my own, or should this module work?
(or are there better ways of doing a silverstripe youtube gallery?)

Thanks
Martin

Avatar
martbarr

Community Member, 53 Posts

22 October 2010 at 9:50am

Edited: 22/10/2010 9:50am

Ok - if anyone is wanting youtube gallery in 2.4, the google api has changed (now late October 2010).

Replace the extractVideoInfo($video) with this code and it will work in 2.4.2

/**
    * Gets information from one <entry> tag from the feed
    */
   function extractVideoInfo($video) {
      $data = array();
      $mediaentry = $video->children('http://search.yahoo.com/mrss/');
      $attrs = ($mediaentry[0]->children('media', true));

      $data['Author'] = Convert::raw2xml((string)$video->author->name);
      $data['Title'] = Convert::raw2xml((string)$video->title); // Title of the video
      $data['HTML'] = trim((string)$video->content);
      $data['Description'] = Convert::raw2xml((string)$mediaentry->group->description);
    $yt = $mediaentry->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$length = $attrs['seconds'];
      $data['RuntimeMin'] = floor( $length/60);
      $data['Runtime'] = sprintf ("%dm%2ds",$data['RuntimeMin'], $length - ($data['RuntimeMin']*60));

      $attrs = $mediaentry->group->player->attributes();
      $data['PlayerURL'] = Convert::raw2xml((string)$attrs['url']);       
      
$attrs = $mediaentry->group->thumbnail[0]->attributes();
$thumbnail = Convert::raw2xml((string)$attrs['url']);

$data['SmallThumbnail'] = new ArrayData(array(
         'URL' => $thumbnail,
         'Width' => 100,
         'Height' => 80
      ));
      return $data;
   }

Avatar
davidm2010

Community Member, 107 Posts

11 November 2010 at 1:40am

Edited: 11/11/2010 8:22am

Code works, seems like the pop up function doesn't work.

Avatar
LisaB

Community Member, 28 Posts

15 December 2010 at 5:53am

Edited: 15/12/2010 5:55am

Hi everyone, thanks for the update I now almost have my YouTube Gallery up and running again thanks to this thread. I am having problems with the popup too though. I have got the popup working, but it contains the whole youtube page rather than just the video. The gallery page source shows something like this for each video:

<a params="lightwindow_width=,lightwindow_height=,lightwindow_loading_animation=false,
lightwindow_type=external" href="http://www.youtube.com/watch?v=VIDEOID&amp;feature=youtube_gdata_player"
class="lightwindow">

All the other video info is being extracted and displayed fine on the gallery page, but I guess the PlayerURL link may not be quite right, and it doesn't look like any dimensions are being picked up from the video information. I did think that a PlayerURL link of the form:

http://www.youtube.com/v/VIDEOID

might work better, but beyond that I'm stumped. Can anyone help?

Many thanks

Avatar
Jeramie

Community Member, 34 Posts

21 December 2010 at 9:25am

Looks like in editing the YouTubeService.php file to include the updated api, there are no longer any values defined for $PlayerWidth and $PlayerHeight and the YouTubeGallery.SS files calls them and receives no answer. Thus, you do not have a defined valued in the firebug console or source.

Can I ask why this was updated? If I use the original api on SS 2.4.3 it works for me and I then just have to comment out some of the duplicate js calls

The YouTube module is calling the prototype.js file a second time and causing an issue. I circumvented this by

Adding these lines into the init() function of YouTubeGallery.php after line 116:

         Requirements::block("sapphire/javascript/prototype_improvements.js");
         Requirements::block("sapphire/thirdparty/prototype/prototype.js");
         Requirements::block("sapphire/thirdparty/behaviour/behaviour.js");

This allows the module to work both with the lightwindow and without. It also gives me a smaller lightwindow.

I then Changed the original YouTubeService.php video player dimensions and have a working module that plays just the video.

Attached Files
Avatar
davidm2010

Community Member, 107 Posts

25 January 2011 at 12:12pm

Edited: 25/01/2011 12:13pm

Jeramie,

Works perfect. Just curious as why you didn't modify YouTubeGallery.php? Anyway, if you do, then the Youtube module with the files you have is compatible with 2.4.

Thank you very much for fixing the code.
DM

Avatar
Jeramie

Community Member, 34 Posts

26 January 2011 at 11:19am

Edited: 28/01/2011 4:49am

I am using the files I attached without modding the YouTubeGallery.php on a 2.4.4 install and am having no problems.

By changing the YouTubeService.php file to include the above code, you are no longer connecting to the YouTube API via REST interface.
[url]http://code.google.com/apis/youtube/developers_guide_protocol.html[/url]

In doing this you are now subject to the YouTube block in showing videos in an iframe. Which in turn means your videos may not display in the light window in all browsers. They would like you to use this method instead:
[url]http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html[/url]

The announcement about this block is posted here:
[url]http://www.google.com/support/forum/p/youtube/thread?tid=24c33415a81346d7&hl=en[/url]
[url]http://groups.google.com/group/youtube-api/browse_thread/thread/2d2236731672a098[/url]

By maintaining the original code and using the YouTube API via REST interface , you are not subject to the no frames block from youtube.

The only issue I did run into was the Thumbnail size. So I changed the YouTubeService.php to look like this

$data['SmallThumbnail'] = new ArrayData(array(
         'URL' => Convert::raw2xml((string)$thumbnailObjs[0]['url']),
         //'Width' => (int)$thumbnailObjs[0]['width'],
         //'Height' => (int)$thumbnailObjs[0]['height'],
         'Width' => 100,
    'Height' => 80,

Hope this helps anyone else that comes across this topic.

Avatar
davidm2010

Community Member, 107 Posts

30 January 2011 at 4:15am

Yes, removed the changes, made the update to YouTubeService.php, works fine. So other than updating YouTubeService.php, everything works as you have it packaged.

Thanks again.

Go to Top