Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » YouTubeGallery and 2.4.2

Discuss all other Modules here.

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

Page: 1 2 3 4 5 6
Go to End
Author Topic: 5999 Views
  • martbarr
    Avatar
    Community Member
    46 Posts

    YouTubeGallery and 2.4.2 Link to this post

    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

  • martbarr
    Avatar
    Community Member
    46 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

    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;
       }

  • davidm2010
    Avatar
    Community Member
    107 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

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

  • LisaB
    Avatar
    Community Member
    28 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

    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:

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

    Many thanks

  • Jeramie
    Avatar
    Community Member
    34 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

    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
  • davidm2010
    Avatar
    Community Member
    107 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

    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

  • Jeramie
    Avatar
    Community Member
    34 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

    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.
    http://code.google.com/apis/youtube/developers_guide_protocol.html

    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:
    http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

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

    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.

  • davidm2010
    Avatar
    Community Member
    107 Posts

    Re: YouTubeGallery and 2.4.2 Link to this post

    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.

    5999 Views
Page: 1 2 3 4 5 6
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.