concerto_remote_video 0.2.1 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15efa4d13a34c7343eafd0691136d5fa9310e4fc
4
- data.tar.gz: 0621f0b247dc44cd384c7e40fcdef69930ddebf0
3
+ metadata.gz: 0057c70e019b24d881176d1cee19c25b2cfbe15f
4
+ data.tar.gz: 427ad38f5490bf3d9bb97b56613c9b6a90c9d884
5
5
  SHA512:
6
- metadata.gz: bc2f1c0684781018568674a1f96c655f4f4c14141566c9291373e36d610c72f77f0cc882fa5952a01365503baae92ac8d6ef329147c06341d4aafbc7cd08c7f1
7
- data.tar.gz: 7ebe9b2078ef93bef66fa56481aae1e4a2aa14e888cda84e6f49ac7c3354f6f991e031f6cd0406ff2b100dce8a15928fc6e54c7a6a6c109996fd32e57cb6cb2a
6
+ metadata.gz: abf286284ce3481b42daac729849b5d71d41ab0274e2a72a97c558883c0a363a3bc7ddda0cb3e9bae14ef14c25d37f9e07cf123e435e838e777b10452d4cac83
7
+ data.tar.gz: 6a21256b3c5f55af89a5be869f82c0ecd643c92291e78485e3aa3e8ae218990e7ff32a9c685c3fdbacfd4613d211deaf283e8aa444ac1585822164f2b9919912
data/README.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # Concerto 2 Remote Video Plugin
2
2
  This plugin provides support to play remotely hosted videos, like YouTube videos, in Concerto 2.
3
3
 
4
- 1. Add to your Gemfile: ```gem 'concerto_remote_video'```
5
- 2. ```bundle install```
6
- 3. ```./script/rails generate concerto_remote_video:install install```
4
+ To install this plugin, go to the Plugin management page in concerto, select RubyGems as the source and "concerto_remote_video" as the gem name.
7
5
 
8
- The last step produces a lot of output, if it runs successfully, because it recompiles the frontend js files.
9
-
10
- ## Supported hosts:
6
+ ## Supported sources:
7
+ * HTTP - MP4 videos primarily (http://en.wikipedia.org/wiki/HTML5_video#Supported_video_formats)
11
8
  * YouTube
12
9
  * Vimeo
13
10
 
@@ -1,80 +1,110 @@
1
- // contents.js
1
+ var initializedRemoteVideoHandlers = false;
2
+ function initializeRemoteVideoHandlers() {
3
+ if (!initializedRemoteVideoHandlers) {
2
4
 
3
- // attach handler to video_id so when it loses focus we can look up some video details
4
- // not dry, but no middle man
5
- function attachHandlers() {
6
- $('input#remote_video_config_video_id').on('blur', getVideoInfo);
7
- $('select#remote_video_config_video_vendor').on('change', getVideoInfo);
5
+ function getVideoInfo() {
6
+ // need to know which vendor
7
+ // will place title, description, duration into 'div.remote-video-info'
8
8
 
9
- $('select#remote_video_config_video_vendor').on('change', updateTooltip);
9
+ var info = '<p>Video details could not be determined.</p>';
10
+ var vendor = $('select#remote_video_config_video_vendor').val();
11
+ var video_id = $('input#remote_video_config_video_id').val();
12
+ var info_el = $('.remote-video-info');
13
+ var preview_div = $('#preview_div');
14
+ $(preview_div).empty();
10
15
 
11
- function updateTooltip() {
12
- var vendor = $('select#remote_video_config_video_vendor').val();
13
- if (vendor == 'YouTube') {
14
- $('input#remote_video_config_video_id').attr("placeholder", "DGbqvYbPZBY");
15
- $('div#video_hint_id').html('Specify the video id or keywords');
16
- } else if (vendor == 'Vimeo') {
17
- $('input#remote_video_config_video_id').attr("placeholder", "4224811");
18
- $('div#video_hint_id').html('Specify the exact vimeo video id');
19
- }
20
- }
21
-
22
- function getVideoInfo() {
23
- // need to know which vendor
24
- // will place title, description, duration into 'div.remote-video-info'
25
-
26
- var info = '<p>Video details could not be determined.</p>';
27
- var vendor = $('select#remote_video_config_video_vendor').val();
28
- var video_id = $('input#remote_video_config_video_id').val();
29
- var info_el = $('.remote-video-info');
30
-
31
- if (info_el.length != 0) {
32
- // we found the summary box
33
- if (typeof vendor != 'undefined') {
34
- // we found the vendor selection, call appropriate api
35
- if (vendor == 'YouTube') {
36
- $(info_el).empty().html('<i class=\"ficon-spinner icon-spin\"></i> searching...');
37
- // todo: dont search if video_id is empty
38
- $.ajax({
39
- url: '//gdata.youtube.com/feeds/api/videos?q='+ encodeURIComponent(video_id) +'&v=2&max-results=1&format=5&alt=jsonc',
40
- dataType: 'jsonp',
41
- timeout: 4000,
42
- success: function (data) {
43
- if (parseInt(data['data']['totalItems']) > 0) {
44
- // we got something, repoint data to first item in results
45
- data = data['data']['items'];
46
- $(info_el).empty().html('<img src="' + data[0].thumbnail.hqDefault + '"/><h4>' + data[0].title + '</h4><i>' + data[0].duration + ' secs</i><br/><p>' + data[0].description + '</p>');
47
- } else {
16
+ if (info_el.length != 0) {
17
+ // we found the summary box
18
+ if (typeof vendor != 'undefined') {
19
+ // we found the vendor selection, call appropriate api
20
+ if (vendor == 'YouTube') {
21
+ $(info_el).empty().html('<i class=\"ficon-spinner icon-spin\"></i> searching...');
22
+ // todo: dont search if video_id is empty
23
+ $.ajax({
24
+ url: '//gdata.youtube.com/feeds/api/videos?q='+ encodeURIComponent(video_id) +'&v=2&max-results=1&format=5&alt=jsonc',
25
+ dataType: 'jsonp',
26
+ timeout: 4000,
27
+ success: function (data) {
28
+ if (parseInt(data['data']['totalItems']) > 0) {
29
+ // we got something, repoint data to first item in results
30
+ data = data['data']['items'];
31
+ $(info_el).empty().html('<img src="' + data[0].thumbnail.hqDefault + '"/><h4>' + data[0].title + '</h4><i>' + data[0].duration + ' secs</i><br/><p>' + data[0].description + '</p>');
32
+ previewVideo(data[0].id);
33
+ } else {
34
+ $(info_el).empty().html(info);
35
+ }
36
+ },
37
+ error: function (xoptions, textStatus) {
48
38
  $(info_el).empty().html(info);
49
39
  }
50
- },
51
- error: function (xoptions, textStatus) {
52
- $(info_el).empty().html(info);
53
- }
54
- });
55
- } else if (vendor == 'Vimeo') {
56
- $(info_el).empty().html('<i class=\"ficon-spinner icon-spin\"></i> searching...');
57
- $.ajax({
58
- url: '//vimeo.com/api/v2/video/' + encodeURIComponent(video_id) + '.json',
59
- dataType: 'jsonp',
60
- timeout: 4000,
61
- success: function (data) {
62
- if (data.length > 0) {
63
- // we got something
64
- $(info_el).empty().html('<img src="' + data[0].thumbnail_small + '"/><h4>' + data[0].title + '</h4><i>' + data[0].duration + ' secs</i><br/><p>' + data[0].description + '</p>');
65
- } else {
40
+ });
41
+ } else if (vendor == 'Vimeo') {
42
+ $(info_el).empty().html('<i class=\"ficon-spinner icon-spin\"></i> searching...');
43
+ $.ajax({
44
+ url: '//vimeo.com/api/v2/video/' + encodeURIComponent(video_id) + '.json',
45
+ dataType: 'jsonp',
46
+ timeout: 4000,
47
+ success: function (data) {
48
+ if (data.length > 0) {
49
+ // we got something
50
+ $(info_el).empty().html('<img src="' + data[0].thumbnail_small + '"/><h4>' + data[0].title + '</h4><i>' + data[0].duration + ' secs</i><br/><p>' + data[0].description + '</p>');
51
+ previewVideo();
52
+ } else {
53
+ $(info_el).empty().html(info);
54
+ }
55
+ },
56
+ error: function (xoptions, textStatus) {
66
57
  $(info_el).empty().html(info);
67
58
  }
68
- },
69
- error: function (xoptions, textStatus) {
70
- $(info_el).empty().html(info);
59
+ });
60
+ } else if (vendor == 'HTTPVideo') {
61
+ $(info_el).empty();
62
+ if (video_id != "")
63
+ {
64
+ previewVideo();
71
65
  }
72
- });
66
+ }
73
67
  }
74
68
  }
75
69
  }
70
+
71
+ function previewVideo(video_id) {
72
+ var url = $('input#remote_video_config_video_id').data('url');
73
+ if (url) {
74
+ if (video_id == null) {
75
+ video_id = $('input#remote_video_config_video_id').val();
76
+ }
77
+ $("#preview_div").load(url, { data: {
78
+ video_vendor: $('select#remote_video_config_video_vendor').val(),
79
+ video_id: video_id,
80
+ allow_flash: $('input#remote_video_config_allow_flash').val(),
81
+ duration: $('input#remote_video_duration').val(),
82
+ name: $('input#remote_video_name').val()
83
+ }, type: 'RemoteVideo' });
84
+ }
85
+ }
86
+
87
+ function updateTooltip() {
88
+ var vendor = $('select#remote_video_config_video_vendor').val();
89
+ if (vendor == 'YouTube') {
90
+ $('input#remote_video_config_video_id').attr("placeholder", "DGbqvYbPZBY");
91
+ $('div#video_id_hint').html('Specify the video id or keywords');
92
+ } else if (vendor == 'Vimeo') {
93
+ $('input#remote_video_config_video_id').attr("placeholder", "4224811");
94
+ $('div#video_id_hint').html('Specify the exact vimeo video id');
95
+ } else if (vendor == 'HTTPVideo') {
96
+ $('input#remote_video_config_video_id').attr("placeholder", "http://media.w3.org/2010/05/sintel/trailer.mp4");
97
+ $('div#video_id_hint').html('Specify the url of the video');
98
+ }
99
+ }
100
+
101
+ $('input#remote_video_config_video_id').on('blur', getVideoInfo);
102
+ $('select#remote_video_config_video_vendor').on('change', getVideoInfo);
103
+ $('select#remote_video_config_video_vendor').on('change', updateTooltip);
104
+
105
+ initializedRemoteVideoHandlers = true;
76
106
  }
77
107
  }
78
108
 
79
- $(document).ready(attachHandlers);
80
- $(document).on('page:change', attachHandlers);
109
+ $(document).ready(initializeRemoteVideoHandlers);
110
+ $(document).on('page:change', initializeRemoteVideoHandlers);
@@ -13,8 +13,9 @@ class RemoteVideo < Content
13
13
 
14
14
  DISPLAY_NAME = 'Video'
15
15
  VIDEO_VENDORS = {
16
- :YouTube => { :id => "YouTube", :url => "https://www.youtube.com/embed/" },
17
- :Vimeo => { :id => "Vimeo", :url => "https://player.vimeo.com/video/" }
16
+ :HTTPVideo => { :id => "HTTPVideo", :name => "Video URL", :url => ""},
17
+ :YouTube => { :id => "YouTube", :name => "YouTube", :url => "https://www.youtube.com/embed/" },
18
+ :Vimeo => { :id => "Vimeo", :name => "Vimeo", :url => "https://player.vimeo.com/video/" }
18
19
  }
19
20
 
20
21
  attr_accessor :config
@@ -116,6 +117,10 @@ class RemoteVideo < Content
116
117
  self.config['thumb_url'] = video_data['thumbnail_small']
117
118
  self.config['title'] = video_data['title']
118
119
  self.config['description'] = video_data['description']
120
+ elsif self.config['video_vendor'] == VIDEO_VENDORS[:HTTPVideo][:id]
121
+ self.config['thumb_url'] = ''
122
+ self.config['title'] = self.name
123
+ self.config['description'] = ''
119
124
  end
120
125
  end
121
126
 
@@ -141,26 +146,70 @@ class RemoteVideo < Content
141
146
  end
142
147
  end
143
148
 
149
+ def self.preview(data)
150
+ begin
151
+ o = RemoteVideo.new()
152
+ o.config['video_id'] = data[:video_id]
153
+ o.config['video_vendor'] = data[:video_vendor]
154
+ o.config['allow_flash'] = data[:allow_flash]
155
+ o.name = data[:name]
156
+ o.duration = data[:duration]
157
+
158
+ results = o.render_preview
159
+ rescue => e
160
+ results = "Unable to preview. #{e.message}"
161
+ end
162
+
163
+ return results
164
+ end
165
+
166
+ def preview
167
+ begin
168
+ results = render_preview
169
+ rescue => e
170
+ results = "Unable to preview. #{e.message}"
171
+ end
172
+
173
+ return results
174
+ end
175
+
144
176
  def render_details
145
177
  if self.config['video_vendor'] == VIDEO_VENDORS[:YouTube][:id]
146
178
  settings = {
147
- :autoplay => 1, # Autostart the video
179
+ :autoplay => 1, # Autostart the video
148
180
  :end => self.duration, # Stop it around the duration
149
- :controls => 0, # Don't show any controls
150
- :modestbranding => 1, # Use the less fancy branding
151
- :rel => 0, # Don't show related videos
152
- :showinfo => 0, # Don't show the video info
153
- :iv_load_policy => 3 # Don't show any of those in-video labels
181
+ :controls => 0, # Don't show any controls
182
+ :modestbranding => 1, # Use the less fancy branding
183
+ :rel => 0, # Don't show related videos
184
+ :showinfo => 0, # Don't show the video info
185
+ :iv_load_policy => 3 # Don't show any of those in-video labels
154
186
  }
155
187
  elsif self.config['video_vendor'] == VIDEO_VENDORS[:Vimeo][:id]
156
188
  settings = {
157
- :api => 1, # use Javascript API
189
+ :api => 1, # use Javascript API
158
190
  :player_id => 'playerv', #arbitrary id of iframe
159
191
  :byline => 0,
160
192
  :portrait => 0,
161
193
  :autoplay => 1
162
194
  }
195
+ elsif self.config['video_vendor'] == VIDEO_VENDORS[:HTTPVideo][:id]
196
+ settings = {
197
+ :autoplay => 1, # Autostart the video
198
+ :end => self.duration, # Stop it around the duration
199
+ :controls => 0, # Don't show any controls
200
+ }
163
201
  end
164
202
  {:path => player_url(settings)}
165
203
  end
204
+
205
+ def render_preview
206
+ if self.config['video_vendor'] == RemoteVideo::VIDEO_VENDORS[:YouTube][:id] || self.config['video_vendor'] == RemoteVideo::VIDEO_VENDORS[:Vimeo][:id]
207
+ player_settings = { :end => self.duration, :rel => 0, :theme => 'light', :iv_load_policy => 3 }
208
+ results = "<iframe id=\"player\" type=\"text/html\" width=\"100%\" src=\"#{self.player_url(player_settings)}\" frameborder=\"0\"></iframe>"
209
+ elsif self.config['video_vendor'] == RemoteVideo::VIDEO_VENDORS[:HTTPVideo][:id]
210
+ results = "<video preload controls width=\"100%\"><source src=\"#{self.config['video_id']}\" /></video>"
211
+ end
212
+
213
+ results
214
+ end
166
215
  end
@@ -7,16 +7,16 @@
7
7
  <%= form.fields_for :config do |config| %>
8
8
  <div class='span4'>
9
9
  <div class="clearfix">
10
- <%= config.label :video_vendor, 'Video Vendor' %>
10
+ <%= config.label :video_vendor, 'Video Source' %>
11
11
  <div class="input">
12
- <%= config.select :video_vendor, RemoteVideo::VIDEO_VENDORS.collect { |a,b| b[:id] } %>
12
+ <%= config.select :video_vendor, RemoteVideo::VIDEO_VENDORS.collect { |a,b| [b[:name], b[:id]] } %>
13
13
  </div>
14
14
  </div>
15
15
  <div class="clearfix">
16
16
  <%= config.label :video_id %>
17
17
  <div class="input">
18
- <%= config.text_field :video_id, :placeholder => "DGbqvYbPZBY", :class => "input-small" %>
19
- <div id="video_id_hint">Specify the video id or keywords</div>
18
+ <%= config.text_field :video_id, :placeholder => "http://media.w3.org/2010/05/sintel/trailer.mp4", :class => "input-xlarge", "data-url" => preview_contents_path %>
19
+ <div id="video_id_hint">Specify the url of the video</div>
20
20
  </div>
21
21
  </div>
22
22
  <div class="clearfix">
@@ -29,7 +29,7 @@
29
29
  <%= form.label :duration %>
30
30
  <div class="input">
31
31
  <%= form.number_field :duration, :class => "input-small" %><br/>
32
- (automatically set if ascertained from video source)
32
+ (auto-set if read from video source)
33
33
  </div>
34
34
  </div>
35
35
  </div>
@@ -1,7 +1,7 @@
1
1
  <%= stylesheet_link_tag "concerto_remote_video/application" %>
2
2
  <div class="auto-resizable-iframe">
3
- <div>
4
- <% player_settings = {:end => content.duration, :rel => 0, :theme => 'light', :iv_load_policy => 3} %>
5
- <iframe id="player" type="text/html" src="<%=raw content.player_url(player_settings) %>" frameborder="0"></iframe>
3
+ <div>
4
+ <%= content.preview.html_safe %>
5
+ </div>
6
6
  </div>
7
- </div>
7
+
@@ -1 +1,12 @@
1
- <div class="pop" style="background-image:url(<%= content.config['thumb_url'] %>); background-size: cover; width: 100%; height: 100%;" data-content="<%= content.config['description']%>" data-title="<%= content.config['title']%>"></div>
1
+ <% if content.config['thumb_url'].blank? %>
2
+ <div>
3
+ <h2 class="center">
4
+ <%= content.name %>
5
+ </h2>
6
+ <p>
7
+ <%= content.config['video_id'] %>
8
+ </p>
9
+ </div>
10
+ <% else %>
11
+ <div class="pop" style="background-image:url(<%= content.config['thumb_url'] %>); background-size: cover; width: 100%; height: 100%;" data-content="<%= content.config['description']%>" data-title="<%= content.config['title']%>"></div>
12
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module ConcertoRemoteVideo
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concerto_remote_video
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Michalski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails