rbVimeo release
No Comments Yet so far
Leave a comment
Today I have released the first version of the rbVimeo gem. This is a ruby wrapper for the Vimeo API. To install the gem, run the following command:
sudo gem install rbvimeo
To demonstrate this library, I have created a simple rails app that takes a video’s id and displays that video on the page.
index.html.erb:
<%- form_remote_tag :url => { :action => 'search' },
:update => 'video',
:before => %(Element.show(spinner)),
:success => %(Element.hide(spinner)) do -%>
<%= image_tag 'spinner.gif', :id => 'spinner',
:style => 'display: none'%>
<label for="video_id">Video ID:</label>
<%= text_field_tag 'video_id' %>
<%= submit_tag 'Search' %>
<% end %>
<div id="video"></div>
The index takes the Vimeo video’s id and pushes it to the controller action for search.
vimeo_controller.rb:
class VimeoController < ApplicationController
def search
vimeo = RBVIMEO::Vimeo.new("api_key", "api_secret")
render :partial => "video.html.erb",
:locals => {:video => vimeo.video(params[:video_id])}
end
end
This then sends the video object into the video partial which embeds it into the video div from the index.
_video.html.erb:
<%= video.embed(video.width, video.height) %>
Here is a video that shows the final application
Leave a Comment
No Comments Yet so far
Leave a comment
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>