Reputation: 782
I have a website with a textarea that prompts users to input a URL from a youtube video. Once the user saves the page (thereby saving the embed code) I would like to implement an iframe on the page so that users can see the video they embedded.
at present the code that i have looks like this, where video_URL is the textarea where the user defines the URL:
= f.text_area :video_URL, :placeholder => "Please place the URL code from your YouTube or Vimeo here.", :rows => 1
%iframe{:height => 390, :width => 480, :frameborder => "0", :src => "view?step=micro_pitch/@project.micro_pitch"}
Any help would be greatly appreciated! Thank you so much!
Upvotes: 3
Views: 7808
Reputation: 937
I am not sure I got you correct, But you will be in need of player like flash player or something to render your video in the browser.
you may want to look these for reference.
Easiest way to embed flash videos in Rails - must be cross browser compatible
If you are not looking for this, can you be more specific
Upvotes: 1
Reputation: 9835
2 ways, the new and the old:
Save the id of the video in @video_id
-1. the new with iframe:
iframe{:allowscriptaccess => "always", :allowFullScreen => "true", :frameborder => "0", :height => "430", :src => "http://www.youtube.com/embed/#{@video_id}", :title => "YouTube video player", :width => "640"}
-2. The old with embed:
%object{:height => "0", :width => "0"}
%param{:name => "movie", :value => "http://www.youtube.com/v/#{@video_id}?fs=1&hl=en_US&rel=0"}
%param{:name => "allowFullScreen", :value => "true"}
%param{:name => "allowscriptaccess", :value => "always"}
%embed{:allowfullscreen => "true", :allowscriptaccess => "always", :height => "390", :src => "http://www.youtube.com/v/#{@video_id}?fs=1&hl=en_US&rel=0", :type => "application/x-shockwave-flash", :width => "640"}
Upvotes: 8