I am trying to embed a video in my app and am using the gem panda '1.6.0' for this. I followed the pandastream integrate with rails guide and have the following code:
controllers:
-------------
class BoothVideosController < ApplicationController
before_filter :init_booth_video
def show
@original_video = @video.panda_video
@h264_encoding = @original_video.encodings["h264"]
render :template => 'booth_video/booth_video', :layout =>
'sponsored_group_manage_sub_menu'
end
def new
@video = BoothVideo.new
render :layout => 'sponsored_group_manage_sub_menu'
end
def create
@video = BoothVideo.create!(params[:video])
redirect_to :action => :show, :id => @video.id
end
def init_booth_video
@group = Group.find(params[:group_id])
@video=@group.booth_video
end
end
class PandaController < ApplicationController
def authorize_upload
payload = JSON.parse(params['payload'])
upload = Panda.post('/videos/upload.json', {
file_name: payload['filename'],
file_size: payload['filesize'],
profiles: "h264",
})
render :json => {:upload_url => upload['location']}
end
end
model:
------
class BoothVideo < ActiveRecord::Base
belongs_to :group
validates_presence_of :panda_video_id
def panda_video
@panda_video ||= Panda::Video.find(panda_video_id)
end
end
View
-----
<% content_for(:page_title, "Create a New Booth Video") -%>
<% form_for(:booth_video,:url => group_booth_video_path, :html => {:id =>
"new_booth_video", :multipart => true}) do |f| %>
<h5>New Booth Video</h5>
<fieldset>
<input type="hidden" name="panda_video_id"/>
<label for="title">Title</label><br />
<%= f.text_field :title, :size => 32, :placeholder => "Title for the new booth
video" %><br /><br />
<div class='progress'>
<span id="progress-bar" class='bar'></span>
</div>
<div id="browse">Choose file</div>
<%=f.submit "Upload video" %>
<% end %>
I have also included the js for panda uploader in my application.js file. I am able to see my file uploader but when I actually browse and select a file, it does not actually get loaded - also no progress is indicated in the progress bar.
- Why is the video not getting uploaded?
- The create action mentions params[:video] in the tutorial but there is no param in the 'new' form for the uploaded video-how will it recognize this?
Please help! Thanks in advance...