mep_feature_time_rail_thumbnails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 581863f9c3305a8e58bab3fd847f0ca4749057ab
4
- data.tar.gz: 805a293d56f27f0331601cddb794444564212403
3
+ metadata.gz: 1cc824c0d71af3824d8c886ed0eaf9928198a624
4
+ data.tar.gz: 4f7ebec9024acc308bf697ae8fdaed8374432a4e
5
5
  SHA512:
6
- metadata.gz: e0ad1312a6e0028608934e253ca0e065fc72e7a36cdeaa0d93bc5f27be8885b6277919236ee7f8ccaa52f2c6cdade1df701d624c8d42e073fa88eb2491c92034
7
- data.tar.gz: cef2e3b4387e7696ab2a6e032ddb9a1221c2d8c69e4185ae33b013e0aa1a22b44cf956ca3dfdad0a6bc4e1b3e8065cbb37ed874089cc2c544dd9d01545c39ed4
6
+ metadata.gz: 389e28c0b11d19041f9cd5882ce003b84f884703691552975c6502cffa1a017aa2f1ed113bde7ea679958a92ec3ec6e5072b0c5ba3119aab153f5ac4afad2f63
7
+ data.tar.gz: fe2a926090528a01f56073f15f678fabf00de27d5041733b14fb12e2870eeecaa069d1da2c13d09c6972794bf153f8e987247418343c2b1fee103d11d549c58d
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # MediaElement.js Plugin for Preview Thumbnails
2
2
 
3
- Hover over the time rail on a [MediaElement.js](http://mediaelementjs.com/) player, and see video thumbnails.
3
+ Hover over the time rail on a [MediaElement.js](http://mediaelementjs.com/) player and see video thumbnails.
4
+
5
+ [See a video of this in action](http://jronallo.github.io/mep-feature-time-rail-thumbnails/)
4
6
 
5
7
  ## Use
6
8
 
@@ -8,7 +10,7 @@ To use this feature you will first need to create an image sprite and a metadata
8
10
 
9
11
  ### Create an Image Sprite
10
12
 
11
- The idea is to take a snapshot of your video every 5 seconds and then stitch the images together into a sprite. This means that only one image file needs to be requested from the server and switching between thumbnails can be very quick.
13
+ The idea is to take a snapshot of your video every N seconds and then stitch the images together into a sprite. This means that only one image file needs to be requested from the server and switching between thumbnails can be very quick.
12
14
 
13
15
  Here's one way you could create the image sprite using ffmpeg and montage (from ImageMagick):
14
16
 
@@ -46,8 +48,10 @@ http://example.com/video-name-sprite.jpg#xywh=0,100,150,100
46
48
  ```
47
49
 
48
50
  #### Current Sprite Limitations
49
- - All the images embedded in the sprite should have exactly the same dimensions. The styling for the thumbnail hover area is calculated based on the dimensions of the first URL in the WebVTT file.
50
- - Images should only be taken every 5 seconds. While this ought to be configurable in the future it currently is not.
51
+
52
+ All the images embedded in the sprite should have exactly the same dimensions. The styling for the thumbnail hover area is calculated based on the dimensions of the first URL in the WebVTT file.
53
+
54
+ The durations that each thumbnail ought to show should be consistent. The default is 5 seconds, though this is configurable when initializing the player.
51
55
 
52
56
  ### Markup
53
57
 
@@ -65,19 +69,26 @@ Add 'timerailsthumbnails' as the last feature when initializing the mediaelement
65
69
 
66
70
  ```javascript
67
71
  $('video').mediaelementplayer({
68
- features: ['playpause','progress','current','duration','tracks','volume', 'timerailthumbnails']
72
+ features: ['playpause','progress','current','duration','tracks','volume', 'timerailthumbnails'],
73
+ timeRailThumbnailsSeconds: 5
69
74
  });
70
75
  ```
71
76
 
77
+ Also, either use the default of 5 second intervals for each thumbnail or set `timeRailThumbnailsSeconds` to the appropriate value.
78
+
72
79
  ## Installation
73
80
 
74
81
  This JavaScript plugin is made available as both a Rails Engine gem for the asset pipeline (unreleased) and a bower package. Choose your poison.
75
82
 
83
+ ### vtt.js
84
+
85
+ This plugin relies on the [vtt.js](https://github.com/mozilla/vtt.js/tree/master) library for WebVTT parsing. You'll need to include this before including mep-feature-time-rail-thumbnails.js.
86
+
76
87
  ### Rails
77
88
 
78
89
  Include it in your Gemfile:
79
90
  ```ruby
80
- gem 'mep_feature_time_rail_thumbnails', git: 'git@github.com:jronallo/mep-feature-time-rail-thumbnails.git'
91
+ gem 'mep_feature_time_rail_thumbnails'
81
92
  ```
82
93
 
83
94
  Add it to your application.js:
@@ -94,10 +105,12 @@ bower i mep_feature_time_rail_thumbnails
94
105
 
95
106
  The file you want is at `bower_components/mep_feature_time_rail_thumbnails/vendor/assets/javascripts/mep-feature-time-rail-thumbnails.js`
96
107
 
108
+ The latest vtt.js is not currently available from bower.
109
+
97
110
  ## TODO
98
111
 
99
112
  - Make the interval of thumbnails configurable or really use the timestamps in the WebVTT file rather than relying on 5 second increments.
100
- - Allow to work over HTTP and HTTPS.
113
+ - Update bower.json dependencies and instructions when [this bug](https://github.com/mozilla/vtt.js/issues/311) is closed.
101
114
 
102
115
  ## Author
103
116
 
@@ -1,3 +1,3 @@
1
1
  module MepFeatureTimeRailThumbnails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -5,6 +5,17 @@
5
5
  if (!player.isVideo)
6
6
  return;
7
7
 
8
+ // This relies on mutation observers right now, so if those aren't available just
9
+ // abandon it.
10
+ if (!window.MutationObserver)
11
+ return;
12
+
13
+ // Check for presence of WebVTT
14
+ if (!WebVTT) {
15
+ console.log('mep-feature-time-rail-thumbnails.js requires vtt.js');
16
+ return;
17
+ }
18
+
8
19
  function getVttCues(url) {
9
20
  var vtt,
10
21
  parser = new WebVTT.Parser(window, WebVTT.StringDecoder()),
@@ -39,7 +50,9 @@
39
50
  }
40
51
 
41
52
  function setThumbnailImage(url) {
42
- $('.mejs-plugin-time-float-thumbnail').css('background-image','url(' + url.split('#')[0] + ')');
53
+ // Make sure the url is protocol/scheme relative
54
+ var protocol_relative_url = url.substr(url.indexOf('://')+1);
55
+ $('.mejs-plugin-time-float-thumbnail').css('background-image','url(' + protocol_relative_url.split('#')[0] + ')');
43
56
  }
44
57
 
45
58
  var
@@ -47,7 +60,14 @@
47
60
  element_to_observe = player.container.find('.mejs-time-float-current')[0],
48
61
  video_thumbnail_vtt_url,
49
62
  cues,
50
- preview_thumbnails_track = mediaContainer.find("track[kind='metadata'].time-rail-thumbnails");
63
+ preview_thumbnails_track = mediaContainer.find("track[kind='metadata'].time-rail-thumbnails"),
64
+ time_rail_thumbnails_seconds;
65
+
66
+ if (player.options.timeRailThumbnailsSeconds) {
67
+ time_rail_thumbnails_seconds = player.options.timeRailThumbnailsSeconds;
68
+ } else {
69
+ time_rail_thumbnails_seconds = 5;
70
+ }
51
71
 
52
72
  if (preview_thumbnails_track.length > 0) {
53
73
  video_thumbnail_vtt_url = preview_thumbnails_track.attr('src');
@@ -95,9 +115,7 @@
95
115
  if (seconds == 0) {
96
116
  cue = cues[0];
97
117
  } else {
98
- // FIXME: Change 5 to be configurable for the number of tiles across
99
- // or actually look up the time cues to see which cue to look into.
100
- var tile = Math.floor(seconds / 5);
118
+ var tile = Math.floor(seconds / time_rail_thumbnails_seconds);
101
119
  cue = cues[tile + 1];
102
120
  }
103
121
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mep_feature_time_rail_thumbnails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Ronallo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails