How to create a progress bar and status messages?


#1

Dear all,

Iam working on video gallery and i have created a file uploading
page(add.rhtml), list page which lists all uploaded video files.

In uploading, i have used ffmpeg tool to convert all movie files into
flash files and also i have used ffmpeg tool to take thumbnails. Could
anyone please suggest about the methods to create a progess bar for this
functionality.

As my form is not an ajaxified form, i need to know how to create a
progress bar and displaying the satus of progreess like,

  1. Uploading in Progress
  2. File uploaded sucessfully, conversion of movie file to flash file in
    progress
  3. Conversion of files done successfully, thumbnail generation in
    progress
  4. sucess.

So along with a progress bar it should display the above texts, in each
process. Please suggest me a way to do?

my add.rhtml

<%= flash.now[:notice] %>

<% form_for(:videos, :html => {:multipart => true}) do |f| %>

Caption <%= f.text_field 'caption' %><br/><br/>

Image <%=file_field("image","blob")%><br/><br/>

Description <%= f.text_area :description, :size => "25x3"%>



<%= f.select :category_id,
  Category.find( :all ).collect {|c| [ c.category_name, c.id ] }

%>

<%= submit_tag “uploadfile”, :url => {:action => ‘add’}, :class =>
‘submit’ %>

<%end %>

My controller(videos_controller)

def add
#----

if request.post? and params[:videos] and params[:image][:blob]
@video = Video.new(params[:videos])
video = params[:image][:blob]
if video == ''
   flash[:notice] = "Please browse a video file"
else
   video_name=params[:image][:blob].original_filename
   video_size = params[:image][:blob].size/1024
   @video.video_size = video_size
   videoname = video_name.split('.')[0]
   videoname_type = video_name.split('.')[1]
   if videoname_type == 'flv' or videoname_type == 'swf'
      @video.video = video_name
      if @video.save
         File.open(RAILS_ROOT + "/public/videos/" + video_name ,

“wb”) do |f|
f.write(video.read)
system “ffmpeg -itsoffset -4 -i
public/videos/#{video_name} -vcodec mjpeg -vframes 1 -an -f rawvideo -s
160x120 public/images/thumbs/#{videoname}.jpg”
end
end
if File.exists? RAILS_ROOT + “/public/videos/” + video_name
and
File.exists? RAILS_ROOT +
“/public/images/thumbs/#{videoname}.jpg”
redirect_to :action => ‘list’
end
else
videoname = video_name.split(’.’)[0]
@video.video = videoname+".flv"
if @video.save
File.open(RAILS_ROOT + “/public/videos/” + video_name ,
“wb”) do |f|
f.write(video.read)
flash[:notice] = “conversion of movie file to flash file
in progress”
if system “ffmpeg -i public/videos/#{video_name} -ar 44100
public/videos/#{videoname}.flv”
system “ffmpeg -itsoffset -4 -i
public/videos/#{videoname}.flv -vcodec mjpeg -vframes 1 -an -f rawvideo
-s 160x120 public/images/thumbs/#{videoname}.jpg”

        else

          flash[:notice] = "Video format is not supported"

        end
      end
      if File.exists? RAILS_ROOT + "/public/videos/" + video_name

and
File.exists? RAILS_ROOT +
“/public/images/thumbs/#{videoname}.jpg”
if File.delete(“public/videos/#{video_name}”)
redirect_to :action => ‘list’

      end
      else
         redirect_to :action => 'list'
      end
    end
  end

end
end
end

Thanks in advance

Regards,
Martin


#2

could anyone help me to solve tha above task, i need to create progress
bar for all functionality s together like uploading and ffmpeg
functions. So please anyone suggest me how to implement a new progress
bar with ajax concept.

regards,
Martin