Uchenna
Uchenna

Reputation: 4089

youtube-g and rails3

I am new to using youtube-g gem and i would like to embed a youtube video rapper that plays videos on my rails app hosted from youtube. pls does anyone know a youtube-g tutorial or another gem with a simpler readme and documentation that can help. So also a quick tutorial help as an answer would be great

Upvotes: 1

Views: 431

Answers (1)

Chris Barretto
Chris Barretto

Reputation: 9529

The 'youtube-g' gem was actually replaced by the 'youtube_it' gem located here: https://github.com/kylejginavan/youtube_it

If all you want to do is a regular embed of a youtube video, you can just use this wrapper (HAML syntax):

%iframe{:title => "YouTube video player", :class => "youtube-player", :type => "text/html", :width => "425", :height => "349",:src => @your_model_name.video_link, :frameborder => "0", :allowFullScreen => true, :id => 'my_video_player' }

If you want to dynamically pull videos from your youTube channel you need to create a client and pull the stream like so:

client = YouTubeIt::Client.new( :username => 'your_user_name', :password => 'you_password', :dev_key => 'your_api_key')
results = client.videos_by(:user => 'your_user_display_name')

That will give you a VideoSearch Object. If you wanted to iterate through all of those video objects:

results.videos

That will return an array of Video objects where you have access to all of these attributes listed here: http://rubydoc.info/gems/youtube_it/1.4.1/YouTubeIt/Model/Video This includes the YouTube url. If you wanted to use the player and and url on your page, you can just do some regEx to extract the video_id and build it yourself. Hope this helps.

Upvotes: 1

Related Questions