html5_video_plugin.rb
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Html5VideoPlugin < Noosfero::Plugin
def self.plugin_name
"HTML5 Video"
end
def stylesheet?
true
end
def js_files
['video-channel.js']
end
def self.plugin_description
_("A plugin to enable the video suport, with auto conversion for the web.")
end
def content_types
[Html5VideoPlugin::VideoChannel]
end
def view_page_layout(controller, page)
if FilePresenter.for(page).is_a? FilePresenter::Video and controller.params[:display] == 'iframe'
'html5_video_plugin_iframe'
end
end
def uploaded_file_after_create_callback(uploaded_file)
full_filename = uploaded_file.full_filename
file_presenter = FilePresenter.for(uploaded_file)
if file_presenter.is_a? FilePresenter::Video
job = Html5VideoPlugin::CreateVideoPreviewJob.new
job.file_type = uploaded_file.class.name
job.file_id = uploaded_file.id
job.full_filename = full_filename
Delayed::Job.enqueue job, priority: 10
[
[:OGV, :tiny, 11],
[:WEBM, :tiny, 12],
[:OGV, :nice, 13],
[:WEBM, :nice, 14],
].each do |format, size, priority|
job = Html5VideoPlugin::CreateVideoForWebJob.new
job.file_type = uploaded_file.class.name
job.file_id = uploaded_file.id
job.full_filename = full_filename
job.format = format
job.size = size
Delayed::Job.enqueue job, priority: priority
end
end
end
end