1

我正在尝试在我的应用程序中嵌入视频,并为此使用 gem panda '1.6.0'。我遵循 pandastream 与 rails 指南集成并具有以下代码:

  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 %>

我还在 application.js 文件中包含了熊猫上传器的 js。我可以看到我的文件上传器,但是当我实际浏览并选择一个文件时,它实际上并没有被加载 - 进度条中也没有显示任何进度。

  1. 为什么视频上传不了?
  2. create 操作在教程中提到了 params[:video] 但上传视频的“新”表单中没有参数 - 它如何识别这一点?

请帮忙!提前致谢...

4

0 回答 0