ruby on rails - Paperclip Video Upload -


i'm trying enable video upload in post. can't display video. video gets uploaded, can confirm while manage right click on video area , download it. problem how view correctly.

migration:

class addattachmentvideotoposts < activerecord::migration   def self.up     change_table :posts |t|       t.attachment :video     end   end    def self.down     drop_attached_file :posts, :video   end end  def change     create_table :videos |t|         t.string :video_file_name         t.string :video_content_type         t.integer :video_file_size         t.datetime :video_updated_at          t.timestamps     end end 

post model

class post < activerecord::base     default_scope :order => 'created_at desc'     attr_accessible :content, :title, :photo, :photo_delete, :video, :video_delete, :dependent => :destroy     has_attached_file :photo, :styles => {  :thumb => "600x600#", :medium => "300x300#", :small => "160x160#"}     has_attached_file :video     validates_uniqueness_of :title     validates_presence_of :title, :content     has_destroyable_file :photo, :video end 

video part in post _form

<div class="visible-md visible-lg">   <%= f.file_field :video, :style => "float: left;" %>   <%= f.check_box :video_delete, :style => "float: left;" %> &nbsp;delete video   </div><br /> <div class="visible-xs">   <%= f.file_field :video, :style => "center" %>   <%= f.check_box :video_delete, :style => "center" %> &nbsp;delete video </div><br /> 

video part in post show

<% if @post.video? %> <h1 class="center"> <%= @post.title %> </h1><br /> <%= video_path @post.video.url %>        <% end %> 

i have tried video_tag don't work , when try with:

<iframe width="490" height="275" src="<%= video_path @post.video.url %>" frameborder="0" allowfullscreen autoplay="true">             </iframe> 

i player won't play. appreciate if through , maybe me come solution work. thanks!

you should use video tag, not iframe (only video tag has autoplay options). check here formats supported browser: http://caniuse.com/#search=video

if want crossbrowser solution, try videojs - http://www.videojs.com/ here can rails plugin - https://github.com/seanbehan/videojs_rails


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -