lib/framey/view_helpers.rb in framey-1.0.0 vs lib/framey/view_helpers.rb in framey-1.0.1
- old
+ new
@@ -1,16 +1,28 @@
module Framey
module ViewHelpers
+
+ # This method renders the Framey video recorder from within an ActionView in your Rails app.
+ #
+ # Example Usage (assuming ERB):
+ # <%= javascript_include_tag "swfobject" %>
+ # <%= render_recorder({
+ # :id => "[some id]" # the id of the flash embed object (optional, random by default)
+ # :max_time => 60, # maximum allowed video length in seconds (optional, defaults to 30)
+ # :session_data => { # custom parameters to be passed along to your app later (optional)
+ # :user_id => <%= @user.id %> # you may, for example, want to relate this recording to a specific user in your system
+ # }
+ # }) %>
def render_recorder(opts={})
api_key = Framey.api_key
timestamp, signature = Framey::Api.sign
session_data = (opts[:session_data]||{}).map { |k,v| "#{k.to_s}=#{v.to_s}" }.join(",")
run_env = Framey.run_env
max_time = opts[:max_time] || 30
divid = "frameyRecorderContainer_#{(rand*999999999).to_i}"
- objid = "the#{divid}"
+ objid = opts[:id] || "the#{divid}"
raw <<END_RECORDER
<div id="#{divid}"></div>
<script type="text/javascript">
var flashvars = {
@@ -32,15 +44,27 @@
swfobject.embedSWF("#{Framey.api_host}/recorder.swf", "#{divid}", "340", "340", "8", "", flashvars, params, attributes);
</script>
END_RECORDER
end
+
+ # This method renders the Framey video player from within an ActionView in your Rails app.
+ #
+ # Example Usage (assuming ERB):
+ # <%= javascript_include_tag "swfobject" %>
+ # <%= render_player({
+ # :video_url => "[video url]", # the video url received in the callback (required)
+ # :thumbnail_url => "[thumbnail url]", # the thumbnail url received in the callback (required)
+ # :progress_bar_color => "0x123456", # the desired color for the progress bar (optional, defaults to black)
+ # :volume_bar_color => "0x123456", # the desired color for the volume bar (optional, defaults to black)
+ # :id => "[some id]" # the id of the flash embed object (optional, random by default)
+ # }) %>
def render_player(opts={})
video_url = opts[:video_url] || "#{Framey.api_host}/videos/#{opts[:video_name]}/source.flv"
thumbnail_url = opts[:thumbnail_url] || "#{Framey.api_host}/videos/#{opts[:video_name]}/thumbnail.jpg"
divid = "frameyPlayerContainer_#{(rand*999999999).to_i}"
- objid = "the#{divid}"
+ objid = opts[:id] || "the#{divid}"
progress_bar_color = "#{opts[:progress_bar_color]}"
volume_bar_color = "#{opts[:volume_bar_color]}"
raw <<END_PLAYER
\ No newline at end of file