Permalink
Browse files

Video playback plugin architecture added. Minor cleanups re: thumbnai…

…ls & conversion.
  • Loading branch information...
bamnet committed Jul 16, 2009
1 parent 0adcaf5 commit 0b8af4ec4fc00142bc9db2eb7ba6e8c05da4fd12
@@ -21,17 +21,6 @@ def show
end
end
# GET /conversions/new
# GET /conversions/new.xml
def new
@conversion = Conversion.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @conversion }
end
end
# GET /conversions/1/edit
def edit
@conversion = Conversion.find(params[:id])
@@ -18,17 +18,6 @@ def index
end
end
# GET /thumbnails/1
# GET /thumbnails/1.xml
def show
@thumbnail = Thumbnail.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @thumbnail }
end
end
# GET /thumbnails/new
# GET /thumbnails/new.xml
def new
View
@@ -37,7 +37,7 @@ def populate_meta_data(path = nil)
def after_save
if !self.no_thumbs && self.thumbnails.empty? && !self.duration.blank?
[0, self.duration/2, self.duration-1].each do |time|
self.thumbnails.create(:video_id => id, :time => time)
self.thumbnails.create(:video_id => id, :time => time ,:status => "Requested")
end
end
end
@@ -46,15 +46,18 @@ def hw
return "#{self.width}x#{self.height}"
end
def best_mp4
def best(video_format = nil, video_codec = nil)
conditions = Array.new
conditions << '(id = :id OR parent_id = :id)'
if(!video_codec.blank?)
conditions << 'video_codec = :video_codec'
end
if(!video_format.blank?)
conditions << 'format = :video_format'
end
return Video.find(:first,
:conditions => ['(id = :id OR parent_id = :id) AND format = "MPEG-4" AND video_codec = "AVC" ',{ :id => self.id} ],
:order => 'width DESC, height DESC, video_bitrate DESC, video_frame_rate DESC, audio_sample_rate DESC')
end
def best_ogg
return Video.find(:first,
:conditions => ['(id = :id OR parent_id = :id) AND format = "OGG" AND video_codec = "Theora" ',{ :id => self.id} ],
:conditions => [conditions.join(' AND '),
{ :id => self.id, :video_format => video_format, :video_codec => video_codec} ],
:order => 'width DESC, height DESC, video_bitrate DESC, video_frame_rate DESC, audio_sample_rate DESC')
end
end
@@ -1,35 +0,0 @@
<h1>New conversion</h1>
<% form_for(@conversion) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :video_id %><br />
<%= f.text_field :video_id %>
</p>
<p>
<%= f.label :profile_id %><br />
<%= f.text_field :profile_id %>
</p>
<p>
<%= f.label :start_time %><br />
<%= f.datetime_select :start_time %>
</p>
<p>
<%= f.label :end_time %><br />
<%= f.datetime_select :end_time %>
</p>
<p>
<%= f.label :status %><br />
<%= f.text_field :status %>
</p>
<p>
<%= f.label :log %><br />
<%= f.text_area :log %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', conversions_path %>
@@ -1,13 +1,15 @@
<div id="thumbnail_grid">
<% thumbnails.each_with_index do |t, i| %>
<div class="thumbnail span-3 <% if (i > 0 and i.modulo(6) == 0 ) then %>last<% end %>">
<% if t.status != "complete" %>
<%= t.status %>
<% else %>
<%= image_tag t.image.url(:thumb), :alt => t.timecode %>
<% if !t.status.blank? %>
<div class="thumbnail span-3 <% if (i > 0 and i.modulo(6) == 0 ) then %>last<% end %>">
<% if t.status == "complete" %>
<%= image_tag t.image.url(:thumb), :alt => t.timecode %>
<% else %>
<%= t.status %>
<% end %>
<br /><span class="quiet"><%= t.timecode %></span>
</div>
<% end %>
<br /><span class="quiet"><%= t.timecode %></span>
</div>
<% end %>
<% if controls != false %>
<div id="new_thumb" class="thumbnail span-3 last">
@@ -4,6 +4,7 @@
<tr>
<th>Video</th>
<th>Timecode</th>
<th>Status</th>
<th>Thumb</th>
<th>Small</th>
<th>Full</th>
@@ -13,10 +14,10 @@
<tr>
<td><%=h thumbnail.video_id %></td>
<td><%=h thumbnail.timecode %></td>
<td><%=h thumbnail.status %></td>
<td><%= image_tag thumbnail.image.url(:thumb) %></td>
<td><%= link_to "View", thumbnail.image.url(:small) %></td>
<td><%= link_to "View", thumbnail.image.url %></td>
<td><%= link_to 'Show', video_thumbnail_path(thumbnail.video, thumbnail) %></td>
<td><%= link_to 'Destroy', video_thumbnail_path(thumbnail.video, thumbnail), :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
@@ -1,19 +0,0 @@
<p>
<b>Video:</b>
<%=link_to @thumbnail.video.name, @thumbnail.video %>
</p>
<p>
<b>Timecode:</b>
<%=h @thumbnail.timecode %>
</p>
<p>
<b>Status:</b>
<%=h @thumbnail.status %>
</p>
<%= image_tag @thumbnail.image.url %>
<br />
<%= link_to 'Back', video_thumbnails_path(@thumbnail.video) %>
@@ -0,0 +1,5 @@
<object id="flowplayer" width="<%= video.width %>" height="<%= video.height %>" data="/bonsai/players/flowplayer/flowplayer-3.1.1.swf" type="application/x-shockwave-flash">
<param name="movie" value="/bonsai/players/flowplayer/flowplayer-3.1.1.swf" />
<param name="allowfullscreen" value="true" />
<param name="flashvars" value='config={"clip":"<%= video.asset.url %>"}' />
</object>
@@ -0,0 +1,18 @@
<% best_ogg = @video.best('OGG', 'Theora') %>
<% best_mp4 = @video.best('MPEG-4', 'AVC') %>
<% if(!best_ogg.blank? && !best_mp4.blank?) %>
<%= render :partial => 'videos/playback/video_for_everyone',
:locals => {:best_mp4 => best_mp4, :best_ogg => best_ogg, :video => @video} %>
<% else %>
<% best_flv = @video.best('Flash Video', 'H.263') %>
<% best_mov = @video.best('QuickTime') %>
<% if !best_flv.blank? %>
<%= render :partial => 'videos/playback/flowplayer', :locals => {:video => best_flv} %>
<% elsif !best_ogg.blank? %>
<%= render :partial => 'videos/playback/video_ogg', :locals => {:video => best_ogg} %>
<% elsif !best_mp4.blank? %>
<%= render :partial => 'videos/playback/flowplayer', :locals => {:video => best_mp4} %>
<% elsif !best_mov.blank? %>
<%= render :partial => 'videos/playback/quicktime', :locals => {:video => best_mov} %>
<% end %>
<% end %>
@@ -0,0 +1,5 @@
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="<%= video.height + 16 %>" width="<%= video.width %>">
<param name="src" value="<%= video.asset.url %>">
<param name="type" value="video/quicktime" height="<%= video.height + 16 %>" width="<%= video.width %>">
<embed src="<%= video.asset.url %>" height="<%= video.height + 16 %>" width="<%= video.width%>" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/">
</object>
@@ -0,0 +1,26 @@
<!-- ÒVideo for EverybodyÓ by Kroc Camen <camendesign.com> cc-by -->
<video width="<%= best_mp4.width %>" height="<%= best_mp4.height %>" controls="controls">
<source src="<%= best_mp4.asset.url %>" type="video/mp4" />
<source src="<%= best_ogg.asset.url %>" type="video/ogg" />
<object id="flowplayer" width="<%= best_mp4.width %>" height="<%= best_mp4.height %>" data="/bonsai/players/flowplayer/flowplayer-3.1.1.swf" type="application/x-shockwave-flash">
<param name="movie" value="/bonsai/players/flowplayer/flowplayer-3.1.1.swf" />
<param name="allowfullscreen" value="true" />
<param name="flashvars" value='config={"clip":"<%= best_mp4.asset.url %>"}' />
<!--[if gt IE 6]>
<object width="<%= best_mp4.width %>" height="<%= best_mp4.height %>" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B">
<param name="src" value="<%= best_mp4.asset.url %>" />
<! [endif]-->
<!--[if gt IE 6]><!-->
<object width="<%= best_mp4.width %>" height="<%= best_mp4.height %>" type="video/quicktime" data="<%= best_mp4.asset.url %>">
<param name="src" value="<%= best_mp4.asset.url %>" />
<!--<![endif]-->
<p>
<strong>No video playback capabilities detected.</strong>
Why not try to download the file instead?<br />
<a href="<%= video.asset.url %>"><%= video.name %></a>
</p>
<!--[if gt IE 6]><!-->
</object><!--<![endif]-->
<!--[if gt IE 6]></object><![endif]-->
</object>
</video>
@@ -0,0 +1,3 @@
<video width="<%= video.width %>" height="<%= video.height %>" controls="controls">
<source src="<%= video.asset.url %>" type="video/ogg" />
</video>
@@ -75,6 +75,6 @@
<div class="span-16 last" id="playback">
<h3>Playback</h3>
<div>
<%#= render :partial => "videos/playback/video_for_everyone", :locals => { :video => @video } %>
<%= render :partial => "videos/playback/handler", :locals => { :video => @video } %>
</div>
</div>
Oops, something went wrong.

0 comments on commit 0b8af4e

Please sign in to comment.