mediaelement_rails 0.8.1 → 0.8.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: 2d8652013a3c249f1593fb65ab96035cfceb3e54
4
- data.tar.gz: 0bf5e23f187444085871307754b558c73cac7350
3
+ metadata.gz: 03557a90121aa44f9904fcc832fe2027989b9cf7
4
+ data.tar.gz: 743ebb30779763a668409c690e0f46137b1d79b7
5
5
  SHA512:
6
- metadata.gz: 54839803d65a5e955b1964e0289c07d8a080400a088d103cae7a952ece979e94875bcfea9834768f8f2f5f16882b675bb48188f3d9af8bc36422d978b5ff91c3
7
- data.tar.gz: 36f1ea8770f9d9adeb2a52a1292a837179dbdcea1623f5b84c56aa4cc56f523192b6023d0f7bd079dc19f04c5402edea0ad1073fb63723e666ae6563000dab40
6
+ metadata.gz: e45fd72044f9284c56aab327722ae2d406f915e9e638bab42f60efd0c889416429d6af77d01d7ef58398f7e6597d6178153ce507d47a09bb0aa8d00efba4ce01
7
+ data.tar.gz: a361e1cffd51ca1e6ddd9f5f21e194d54778d5c5ca62c3196f030ab65b52843d0375d27db3a13ed5c291772793e88420d5c5fb4708f105dc5ab626ef6ab6bd18
@@ -1,5 +1,9 @@
1
1
  ## Changelog
2
2
 
3
+ ### v0.8.2 (2015-08-07)
4
+
5
+ - Updated MediaElement.js to 2.18.0
6
+
3
7
  ### v0.8.1
4
8
 
5
9
  - Updated MediaElement.js to 2.14.4 (danlopez191)
@@ -16,7 +16,7 @@
16
16
  var mejs = mejs || {};
17
17
 
18
18
  // version number
19
- mejs.version = '2.16.4';
19
+ mejs.version = '2.18.0';
20
20
 
21
21
 
22
22
  // player number (for missing, same id attr)
@@ -28,7 +28,7 @@ mejs.plugins = {
28
28
  {version: [3,0], types: ['video/mp4','video/m4v','video/mov','video/wmv','audio/wma','audio/m4a','audio/mp3','audio/wav','audio/mpeg']}
29
29
  ],
30
30
  flash: [
31
- {version: [9,0,124], types: ['video/mp4','video/m4v','video/mov','video/flv','video/rtmp','video/x-flv','audio/flv','audio/x-flv','audio/mp3','audio/m4a','audio/mpeg', 'video/youtube', 'video/x-youtube', 'application/x-mpegURL']}
31
+ {version: [9,0,124], types: ['video/mp4','video/m4v','video/mov','video/flv','video/rtmp','video/x-flv','audio/flv','audio/x-flv','audio/mp3','audio/m4a','audio/mpeg', 'video/youtube', 'video/x-youtube', 'video/dailymotion', 'video/x-dailymotion', 'application/x-mpegURL']}
32
32
  //,{version: [12,0], types: ['video/webm']} // for future reference (hopefully!)
33
33
  ],
34
34
  youtube: [
@@ -100,25 +100,111 @@ mejs.Utility = {
100
100
  // send the best path back
101
101
  return codePath;
102
102
  },
103
- secondsToTimeCode: function(time, forceHours, showFrameCount, fps) {
104
- //add framecount
105
- if (typeof showFrameCount == 'undefined') {
106
- showFrameCount=false;
107
- } else if(typeof fps == 'undefined') {
103
+ /*
104
+ * Calculate the time format to use. We have a default format set in the
105
+ * options but it can be imcomplete. We ajust it according to the media
106
+ * duration.
107
+ *
108
+ * We support format like 'hh:mm:ss:ff'.
109
+ */
110
+ calculateTimeFormat: function(time, options, fps) {
111
+ if (time < 0) {
112
+ time = 0;
113
+ }
114
+
115
+ if(typeof fps == 'undefined') {
108
116
  fps = 25;
109
117
  }
110
-
111
- var hours = Math.floor(time / 3600) % 24,
118
+
119
+ var format = options.timeFormat,
120
+ firstChar = format[0],
121
+ firstTwoPlaces = (format[1] == format[0]),
122
+ separatorIndex = firstTwoPlaces? 2: 1,
123
+ separator = ':',
124
+ hours = Math.floor(time / 3600) % 24,
112
125
  minutes = Math.floor(time / 60) % 60,
113
126
  seconds = Math.floor(time % 60),
114
127
  frames = Math.floor(((time % 1)*fps).toFixed(3)),
115
- result =
116
- ( (forceHours || hours > 0) ? (hours < 10 ? '0' + hours : hours) + ':' : '')
117
- + (minutes < 10 ? '0' + minutes : minutes) + ':'
118
- + (seconds < 10 ? '0' + seconds : seconds)
119
- + ((showFrameCount) ? ':' + (frames < 10 ? '0' + frames : frames) : '');
120
-
121
- return result;
128
+ lis = [
129
+ [frames, 'f'],
130
+ [seconds, 's'],
131
+ [minutes, 'm'],
132
+ [hours, 'h']
133
+ ];
134
+
135
+ // Try to get the separator from the format
136
+ if (format.length < separatorIndex) {
137
+ separator = format[separatorIndex];
138
+ }
139
+
140
+ var required = false;
141
+
142
+ for (var i=0, len=lis.length; i < len; i++) {
143
+ if (format.indexOf(lis[i][1]) !== -1) {
144
+ required=true;
145
+ }
146
+ else if (required) {
147
+ var hasNextValue = false;
148
+ for (var j=i; j < len; j++) {
149
+ if (lis[j][0] > 0) {
150
+ hasNextValue = true;
151
+ break;
152
+ }
153
+ }
154
+
155
+ if (! hasNextValue) {
156
+ break;
157
+ }
158
+
159
+ if (!firstTwoPlaces) {
160
+ format = firstChar + format;
161
+ }
162
+ format = lis[i][1] + separator + format;
163
+ if (firstTwoPlaces) {
164
+ format = lis[i][1] + format;
165
+ }
166
+ firstChar = lis[i][1];
167
+ }
168
+ }
169
+ options.currentTimeFormat = format;
170
+ },
171
+ /*
172
+ * Prefix the given number by zero if it is lower than 10.
173
+ */
174
+ twoDigitsString: function(n) {
175
+ if (n < 10) {
176
+ return '0' + n;
177
+ }
178
+ return String(n);
179
+ },
180
+ secondsToTimeCode: function(time, options) {
181
+ if (time < 0) {
182
+ time = 0;
183
+ }
184
+
185
+ var fps = options.framesPerSecond;
186
+ if(typeof fps === 'undefined') {
187
+ fps = 25;
188
+ }
189
+
190
+ var format = options.currentTimeFormat,
191
+ hours = Math.floor(time / 3600) % 24,
192
+ minutes = Math.floor(time / 60) % 60,
193
+ seconds = Math.floor(time % 60),
194
+ frames = Math.floor(((time % 1)*fps).toFixed(3));
195
+ lis = [
196
+ [frames, 'f'],
197
+ [seconds, 's'],
198
+ [minutes, 'm'],
199
+ [hours, 'h']
200
+ ];
201
+
202
+ var res = format;
203
+ for (i=0,len=lis.length; i < len; i++) {
204
+ res = res.replace(lis[i][1]+lis[i][1], this.twoDigitsString(lis[i][0]));
205
+ res = res.replace(lis[i][1], lis[i][0]);
206
+ }
207
+ return res;
122
208
  },
123
209
 
124
210
  timeCodeToSeconds: function(hh_mm_ss_ff, forceHours, showFrameCount, fps){
@@ -630,7 +716,7 @@ mejs.PluginMediaElement.prototype = {
630
716
  media = url[i];
631
717
  if (this.canPlayType(media.type)) {
632
718
  this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(media.src));
633
- this.src = mejs.Utility.absolutizeUrl(url);
719
+ this.src = mejs.Utility.absolutizeUrl(media.src);
634
720
  break;
635
721
  }
636
722
  }
@@ -670,7 +756,7 @@ mejs.PluginMediaElement.prototype = {
670
756
  this.pluginApi.unMute();
671
757
  }
672
758
  this.muted = muted;
673
- this.dispatchEvent('volumechange');
759
+ this.dispatchEvent({type:'volumechange'});
674
760
  } else {
675
761
  this.pluginApi.setMuted(muted);
676
762
  }
@@ -729,15 +815,14 @@ mejs.PluginMediaElement.prototype = {
729
815
  }
730
816
  return false;
731
817
  },
732
- dispatchEvent: function (eventName) {
818
+ dispatchEvent: function (event) {
733
819
  var i,
734
820
  args,
735
- callbacks = this.events[eventName];
821
+ callbacks = this.events[event.type];
736
822
 
737
823
  if (callbacks) {
738
- args = Array.prototype.slice.call(arguments, 1);
739
824
  for (i = 0; i < callbacks.length; i++) {
740
- callbacks[i].apply(this, args);
825
+ callbacks[i].apply(this, event);
741
826
  }
742
827
  }
743
828
  },
@@ -845,7 +930,7 @@ mejs.MediaPluginBridge = {
845
930
  length: 1
846
931
  };
847
932
 
848
- pluginMediaElement.dispatchEvent(e.type, e);
933
+ pluginMediaElement.dispatchEvent(e);
849
934
  }
850
935
  };
851
936
 
@@ -874,6 +959,8 @@ mejs.MediaElementDefaults = {
874
959
  flashName: 'flashmediaelement.swf',
875
960
  // streamer for RTMP streaming
876
961
  flashStreamer: '',
962
+ // set to 'always' for CDN version
963
+ flashScriptAccess: 'sameDomain',
877
964
  // turns on the smoothing filter in Flash
878
965
  enablePluginSmoothing: false,
879
966
  // enabled pseudo-streaming (seek) on .mp4 files
@@ -1106,7 +1193,7 @@ mejs.HtmlMediaElementShim = {
1106
1193
  // test for plugin playback types
1107
1194
  for (l=0; l<pluginInfo.types.length; l++) {
1108
1195
  // find plugin that can play the type
1109
- if (type == pluginInfo.types[l]) {
1196
+ if (type.toLowerCase() == pluginInfo.types[l].toLowerCase()) {
1110
1197
  result.method = pluginName;
1111
1198
  result.url = mediaFiles[i].url;
1112
1199
  return result;
@@ -1133,8 +1220,6 @@ mejs.HtmlMediaElementShim = {
1133
1220
  },
1134
1221
 
1135
1222
  formatType: function(url, type) {
1136
- var ext;
1137
-
1138
1223
  // if no type is supplied, fake it with the extension
1139
1224
  if (url && !type) {
1140
1225
  return this.getTypeFromFile(url);
@@ -1153,34 +1238,46 @@ mejs.HtmlMediaElementShim = {
1153
1238
 
1154
1239
  getTypeFromFile: function(url) {
1155
1240
  url = url.split('?')[0];
1156
- var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
1157
- return (/(mp4|m4v|ogg|ogv|m3u8|webm|webmv|flv|wmv|mpeg|mov)/gi.test(ext) ? 'video' : 'audio') + '/' + this.getTypeFromExtension(ext);
1241
+ var
1242
+ ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase(),
1243
+ av = /(mp4|m4v|ogg|ogv|m3u8|webm|webmv|flv|wmv|mpeg|mov)/gi.test(ext) ? 'video/' : 'audio/';
1244
+ return this.getTypeFromExtension(ext, av);
1158
1245
  },
1159
1246
 
1160
- getTypeFromExtension: function(ext) {
1247
+ getTypeFromExtension: function(ext, av) {
1248
+ av = av || '';
1161
1249
 
1162
1250
  switch (ext) {
1163
1251
  case 'mp4':
1164
1252
  case 'm4v':
1165
1253
  case 'm4a':
1166
- return 'mp4';
1254
+ case 'f4v':
1255
+ case 'f4a':
1256
+ return av + 'mp4';
1257
+ case 'flv':
1258
+ return av + 'x-flv';
1167
1259
  case 'webm':
1168
1260
  case 'webma':
1169
1261
  case 'webmv':
1170
- return 'webm';
1262
+ return av + 'webm';
1171
1263
  case 'ogg':
1172
1264
  case 'oga':
1173
1265
  case 'ogv':
1174
- return 'ogg';
1266
+ return av + 'ogg';
1267
+ case 'm3u8':
1268
+ return 'application/x-mpegurl';
1269
+ case 'ts':
1270
+ return av + 'mp2t';
1175
1271
  default:
1176
- return ext;
1272
+ return av + ext;
1177
1273
  }
1178
1274
  },
1179
1275
 
1180
1276
  createErrorMessage: function(playback, options, poster) {
1181
1277
  var
1182
1278
  htmlMediaElement = playback.htmlMediaElement,
1183
- errorContainer = document.createElement('div');
1279
+ errorContainer = document.createElement('div'),
1280
+ errorContent = options.customError;
1184
1281
 
1185
1282
  errorContainer.className = 'me-cannotplay';
1186
1283
 
@@ -1189,13 +1286,17 @@ mejs.HtmlMediaElementShim = {
1189
1286
  errorContainer.style.height = htmlMediaElement.height + 'px';
1190
1287
  } catch (e) {}
1191
1288
 
1192
- if (options.customError) {
1193
- errorContainer.innerHTML = options.customError;
1194
- } else {
1195
- errorContainer.innerHTML = (poster !== '') ?
1196
- '<a href="' + playback.url + '"><img src="' + poster + '" width="100%" height="100%" /></a>' :
1197
- '<a href="' + playback.url + '"><span>' + mejs.i18n.t('Download File') + '</span></a>';
1198
- }
1289
+ if (!errorContent) {
1290
+ errorContent = '<a href="' + playback.url + '">';
1291
+
1292
+ if (poster !== '') {
1293
+ errorContent += '<img src="' + poster + '" width="100%" height="100%" alt="" />';
1294
+ }
1295
+
1296
+ errorContent += '<span>' + mejs.i18n.t('Download File') + '</span></a>';
1297
+ }
1298
+
1299
+ errorContainer.innerHTML = errorContent;
1199
1300
 
1200
1301
  htmlMediaElement.parentNode.insertBefore(errorContainer, htmlMediaElement);
1201
1302
  htmlMediaElement.style.display = 'none';
@@ -1221,14 +1322,16 @@ mejs.HtmlMediaElementShim = {
1221
1322
  // copy attributes from html media element to plugin media element
1222
1323
  for (var i = 0; i < htmlMediaElement.attributes.length; i++) {
1223
1324
  var attribute = htmlMediaElement.attributes[i];
1224
- if (attribute.specified == true) {
1325
+ if (attribute.specified) {
1225
1326
  pluginMediaElement.setAttribute(attribute.name, attribute.value);
1226
1327
  }
1227
1328
  }
1228
1329
 
1229
1330
  // check for placement inside a <p> tag (sometimes WYSIWYG editors do this)
1230
1331
  node = htmlMediaElement.parentNode;
1231
- while (node !== null && node.tagName.toLowerCase() !== 'body' && node.parentNode != null) {
1332
+
1333
+ while (node !== null && node.tagName != null && node.tagName.toLowerCase() !== 'body' &&
1334
+ node.parentNode != null && node.parentNode.tagName != null && node.parentNode.constructor != null && node.parentNode.constructor.name === "ShadowRoot") {
1232
1335
  if (node.parentNode.tagName.toLowerCase() === 'p') {
1233
1336
  node.parentNode.parentNode.insertBefore(node, node.parentNode);
1234
1337
  break;
@@ -1293,9 +1396,9 @@ mejs.HtmlMediaElementShim = {
1293
1396
  if (options.enablePluginSmoothing) {
1294
1397
  initVars.push('smoothing=true');
1295
1398
  }
1296
- if (options.enablePseudoStreaming) {
1297
- initVars.push('pseudostreaming=true');
1298
- }
1399
+ if (options.enablePseudoStreaming) {
1400
+ initVars.push('pseudostreaming=true');
1401
+ }
1299
1402
  if (controls) {
1300
1403
  initVars.push('controls=true'); // shows controls in the plugin if desired
1301
1404
  }
@@ -1329,7 +1432,7 @@ mejs.HtmlMediaElementShim = {
1329
1432
  '<param name="quality" value="high" />' +
1330
1433
  '<param name="bgcolor" value="#000000" />' +
1331
1434
  '<param name="wmode" value="transparent" />' +
1332
- '<param name="allowScriptAccess" value="always" />' +
1435
+ '<param name="allowScriptAccess" value="' + options.flashScriptAccess + '" />' +
1333
1436
  '<param name="allowFullScreen" value="true" />' +
1334
1437
  '<param name="scale" value="default" />' +
1335
1438
  '</object>';
@@ -1343,7 +1446,7 @@ mejs.HtmlMediaElementShim = {
1343
1446
  'quality="high" ' +
1344
1447
  'bgcolor="#000000" ' +
1345
1448
  'wmode="transparent" ' +
1346
- 'allowScriptAccess="always" ' +
1449
+ 'allowScriptAccess="' + options.flashScriptAccess + '" ' +
1347
1450
  'allowFullScreen="true" ' +
1348
1451
  'type="application/x-shockwave-flash" pluginspage="//www.macromedia.com/go/getflashplayer" ' +
1349
1452
  'src="' + options.pluginPath + options.flashName + '" ' +
@@ -1380,7 +1483,7 @@ mejs.HtmlMediaElementShim = {
1380
1483
  };
1381
1484
 
1382
1485
  if (mejs.PluginDetector.hasPluginVersion('flash', [10,0,0]) ) {
1383
- mejs.YouTubeApi.createFlash(youtubeSettings);
1486
+ mejs.YouTubeApi.createFlash(youtubeSettings, options);
1384
1487
  } else {
1385
1488
  mejs.YouTubeApi.enqueueIframe(youtubeSettings);
1386
1489
  }
@@ -1424,15 +1527,15 @@ mejs.HtmlMediaElementShim = {
1424
1527
  }
1425
1528
 
1426
1529
  function createEvent(player, pluginMediaElement, eventName, e) {
1427
- var obj = {
1530
+ var event = {
1428
1531
  type: eventName,
1429
1532
  target: pluginMediaElement
1430
1533
  };
1431
1534
  if (eventName == 'timeupdate') {
1432
- pluginMediaElement.currentTime = obj.currentTime = e.seconds;
1433
- pluginMediaElement.duration = obj.duration = e.duration;
1535
+ pluginMediaElement.currentTime = event.currentTime = e.seconds;
1536
+ pluginMediaElement.duration = event.duration = e.duration;
1434
1537
  }
1435
- pluginMediaElement.dispatchEvent(obj.type, obj);
1538
+ pluginMediaElement.dispatchEvent(event);
1436
1539
  }
1437
1540
 
1438
1541
  player.addEvent('play', function() {
@@ -1582,7 +1685,7 @@ mejs.YouTubeApi = {
1582
1685
  },
1583
1686
 
1584
1687
  createEvent: function (player, pluginMediaElement, eventName) {
1585
- var obj = {
1688
+ var event = {
1586
1689
  type: eventName,
1587
1690
  target: pluginMediaElement
1588
1691
  };
@@ -1590,25 +1693,25 @@ mejs.YouTubeApi = {
1590
1693
  if (player && player.getDuration) {
1591
1694
 
1592
1695
  // time
1593
- pluginMediaElement.currentTime = obj.currentTime = player.getCurrentTime();
1594
- pluginMediaElement.duration = obj.duration = player.getDuration();
1696
+ pluginMediaElement.currentTime = event.currentTime = player.getCurrentTime();
1697
+ pluginMediaElement.duration = event.duration = player.getDuration();
1595
1698
 
1596
1699
  // state
1597
- obj.paused = pluginMediaElement.paused;
1598
- obj.ended = pluginMediaElement.ended;
1700
+ event.paused = pluginMediaElement.paused;
1701
+ event.ended = pluginMediaElement.ended;
1599
1702
 
1600
1703
  // sound
1601
- obj.muted = player.isMuted();
1602
- obj.volume = player.getVolume() / 100;
1704
+ event.muted = player.isMuted();
1705
+ event.volume = player.getVolume() / 100;
1603
1706
 
1604
1707
  // progress
1605
- obj.bytesTotal = player.getVideoBytesTotal();
1606
- obj.bufferedBytes = player.getVideoBytesLoaded();
1708
+ event.bytesTotal = player.getVideoBytesTotal();
1709
+ event.bufferedBytes = player.getVideoBytesLoaded();
1607
1710
 
1608
1711
  // fake the W3C buffered TimeRange
1609
- var bufferedTime = obj.bufferedBytes / obj.bytesTotal * obj.duration;
1712
+ var bufferedTime = event.bufferedBytes / event.bytesTotal * event.duration;
1610
1713
 
1611
- obj.target.buffered = obj.buffered = {
1714
+ event.target.buffered = event.buffered = {
1612
1715
  start: function(index) {
1613
1716
  return 0;
1614
1717
  },
@@ -1621,7 +1724,7 @@ mejs.YouTubeApi = {
1621
1724
  }
1622
1725
 
1623
1726
  // send event up the chain
1624
- pluginMediaElement.dispatchEvent(obj.type, obj);
1727
+ pluginMediaElement.dispatchEvent(event);
1625
1728
  },
1626
1729
 
1627
1730
  iFrameReady: function() {
@@ -1645,7 +1748,7 @@ mejs.YouTubeApi = {
1645
1748
  settings.container.innerHTML =
1646
1749
  '<object type="application/x-shockwave-flash" id="' + settings.pluginId + '" data="//www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid=' + settings.pluginId + '&amp;version=3&amp;autoplay=0&amp;controls=0&amp;modestbranding=1&loop=0" ' +
1647
1750
  'width="' + settings.width + '" height="' + settings.height + '" style="visibility: visible; " class="mejs-shim">' +
1648
- '<param name="allowScriptAccess" value="always">' +
1751
+ '<param name="allowScriptAccess" value="sameDomain">' +
1649
1752
  '<param name="wmode" value="transparent">' +
1650
1753
  '</object>';
1651
1754
  */
@@ -1661,14 +1764,14 @@ mejs.YouTubeApi = {
1661
1764
  'id="' + settings.pluginId + '" width="' + settings.width + '" height="' + settings.height + '" class="mejs-shim">' +
1662
1765
  '<param name="movie" value="' + youtubeUrl + '" />' +
1663
1766
  '<param name="wmode" value="transparent" />' +
1664
- '<param name="allowScriptAccess" value="always" />' +
1767
+ '<param name="allowScriptAccess" value="' + options.flashScriptAccess + '" />' +
1665
1768
  '<param name="allowFullScreen" value="true" />' +
1666
1769
  '</object>';
1667
1770
  } else {
1668
1771
  settings.container.innerHTML =
1669
1772
  '<object type="application/x-shockwave-flash" id="' + settings.pluginId + '" data="' + youtubeUrl + '" ' +
1670
1773
  'width="' + settings.width + '" height="' + settings.height + '" style="visibility: visible; " class="mejs-shim">' +
1671
- '<param name="allowScriptAccess" value="always">' +
1774
+ '<param name="allowScriptAccess" value="' + options.flashScriptAccess + '">' +
1672
1775
  '<param name="wmode" value="transparent">' +
1673
1776
  '</object>';
1674
1777
  }
@@ -1740,13 +1843,13 @@ mejs.YouTubeApi = {
1740
1843
  }
1741
1844
  }
1742
1845
  // IFRAME
1743
- function onYouTubePlayerAPIReady() {
1846
+ window.onYouTubePlayerAPIReady = function() {
1744
1847
  mejs.YouTubeApi.iFrameReady();
1745
- }
1848
+ };
1746
1849
  // FLASH
1747
- function onYouTubePlayerReady(id) {
1850
+ window.onYouTubePlayerReady = function(id) {
1748
1851
  mejs.YouTubeApi.flashReady(id);
1749
- }
1852
+ };
1750
1853
 
1751
1854
  window.mejs = mejs;
1752
1855
  window.MediaElement = mejs.MediaElement;