Browse Source

Add array.fill() workaround for IE11, Safari iOS9; close #116

phoboslab 8 years ago
parent
commit
85588a30fe
5 changed files with 19 additions and 6 deletions
  1. 3 3
      jsmpeg.min.js
  2. 11 0
      src/jsmpeg.js
  3. 1 1
      src/mp2.js
  4. 2 2
      src/mpeg1.js
  5. 2 0
      src/player.js

File diff suppressed because it is too large
+ 3 - 3
jsmpeg.min.js


+ 11 - 0
src/jsmpeg.js View File

@@ -81,6 +81,17 @@ var JSMpeg = {
81 81
 		for (var i = 0; i < elements.length; i++) {
82 82
 			new JSMpeg.VideoElement(elements[i]);
83 83
 		}
84
+	},
85
+
86
+	Fill: function(array, value) {
87
+		if (array.fill) {
88
+			array.fill(value);
89
+		}
90
+		else {
91
+			for (var i = 0; i < array.length; i++) {
92
+				array[i] = value;
93
+			}
94
+		}
84 95
 	}
85 96
 };
86 97
 

+ 1 - 1
src/mp2.js View File

@@ -237,7 +237,7 @@ MP2.prototype.decodeFrame = function(left, right) {
237 237
 					MP2.MatrixTransform(this.sample[ch], p, this.V, this.VPos);
238 238
 
239 239
 					// Build U, windowing, calculate output
240
-					this.U.fill(0);
240
+					JSMpeg.Fill(this.U, 0);
241 241
 
242 242
 					var dIndex = 512 - (this.VPos >> 1);
243 243
 					var vIndex = (this.VPos % 128) >> 1;

+ 2 - 2
src/mpeg1.js View File

@@ -833,7 +833,7 @@ MPEG1.prototype.decodeBlock = function(block) {
833 833
 		else {
834 834
 			MPEG1.IDCT(this.blockData);
835 835
 			MPEG1.CopyBlockToDestination(this.blockData, destArray, destIndex, scan);
836
-			this.blockData.fill(0);
836
+			JSMpeg.Fill(this.blockData, 0);
837 837
 		}
838 838
 	}
839 839
 	else {
@@ -845,7 +845,7 @@ MPEG1.prototype.decodeBlock = function(block) {
845 845
 		else {
846 846
 			MPEG1.IDCT(this.blockData);
847 847
 			MPEG1.AddBlockToDestination(this.blockData, destArray, destIndex, scan);
848
-			this.blockData.fill(0);
848
+			JSMpeg.Fill(this.blockData, 0);
849 849
 		}
850 850
 	}
851 851
 

+ 2 - 0
src/player.js View File

@@ -58,6 +58,8 @@ var Player = function(url, options) {
58 58
 	if (this.autoplay) {
59 59
 		this.play();
60 60
 	}
61
+
62
+	window.player = this;
61 63
 };
62 64
 
63 65
 Player.prototype.showHide = function(ev) {