Commit 27a61737 authored by Xiaowu Zhang's avatar Xiaowu Zhang

change addbuffer position for updateend event

parent aa9071fc
...@@ -170,11 +170,7 @@ ...@@ -170,11 +170,7 @@
}).push(function(blob) { }).push(function(blob) {
g.sourceBuffer = g.mediaSource.addSourceBuffer("audio/mpeg;"); g.sourceBuffer = g.mediaSource.addSourceBuffer("audio/mpeg;");
return jIO.util.readBlobAsArrayBuffer(blob).then(function(e) { return jIO.util.readBlobAsArrayBuffer(blob).then(function(e) {
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result)); g.buffer = e.target.result;
if (g.index >= g.size) {
g.mediaSource.endOfStream();
}
g.audio.play();
g.fin = true; g.fin = true;
}); });
}).push(undefined, function(error) { }).push(undefined, function(error) {
...@@ -220,6 +216,8 @@ ...@@ -220,6 +216,8 @@
g.audio.src = URL.createObjectURL(blob); g.audio.src = URL.createObjectURL(blob);
g.audio.load(); g.audio.load();
g.audio.play(); g.audio.play();
} else {
g.sourceBuffer.appendBuffer(new Uint8Array(g.buffer));
} }
return RSVP.any([ play.call(g), loopEventListener(g.sourceBuffer, "updateend", false, function() { return RSVP.any([ play.call(g), loopEventListener(g.sourceBuffer, "updateend", false, function() {
if (!g.fin) { if (!g.fin) {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
} else { } else {
ipValue = ipValue.substring(ipValue.indexOf("//") + 2); ipValue = ipValue.substring(ipValue.indexOf("//") + 2);
tmp = ipValue.charAt(0); tmp = ipValue.charAt(0);
if (tmp >= "0" || tmp <= "9") { if (tmp >= "0" && tmp <= "9") {
port = ipValue.indexOf(":"); port = ipValue.indexOf(":");
portEnd = ipValue.indexOf(":/"); portEnd = ipValue.indexOf(":/");
if (port !== -1) { if (port !== -1) {
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
g.id = options.id; g.id = options.id;
g.index = 35e5; g.index = 35e5;
return g.jio_getAttachment({ return g.jio_getAttachment({
_id: options.id, _id: g.id,
_attachment: "enclosure", _attachment: "enclosure",
_start: 0, _start: 0,
_end: 35e5 _end: 35e5
...@@ -59,8 +59,7 @@ ...@@ -59,8 +59,7 @@
}).push(function(blob) { }).push(function(blob) {
g.sourceBuffer = g.mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"'); g.sourceBuffer = g.mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
return jIO.util.readBlobAsArrayBuffer(blob).then(function(e) { return jIO.util.readBlobAsArrayBuffer(blob).then(function(e) {
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result)); g.buffer = e.target.result;
g.video.play();
g.fin = true; g.fin = true;
}); });
}).push(undefined, function(error) { }).push(undefined, function(error) {
...@@ -89,6 +88,9 @@ ...@@ -89,6 +88,9 @@
g.video.src = URL.createObjectURL(blob); g.video.src = URL.createObjectURL(blob);
g.video.load(); g.video.load();
g.video.play(); g.video.play();
} else {
g.sourceBuffer.appendBuffer(new Uint8Array(g.buffer));
g.video.play();
} }
return RSVP.any([ loopEventListener(g.video, "ended", false, function() { return RSVP.any([ loopEventListener(g.video, "ended", false, function() {
window.location = g.__element.getElementsByClassName("next")[0].href; window.location = g.__element.getElementsByClassName("next")[0].href;
...@@ -105,9 +107,6 @@ ...@@ -105,9 +107,6 @@
if (!g.fin) { if (!g.fin) {
return; return;
} }
if (g.mediaSource.sourceBuffers[0].updating) {
return;
}
g.fin = false; g.fin = false;
if (g.index >= g.size) { if (g.index >= g.size) {
g.mediaSource.endOfStream(); g.mediaSource.endOfStream();
......
...@@ -9783,7 +9783,7 @@ function sequence(thens) { ...@@ -9783,7 +9783,7 @@ function sequence(thens) {
} }
return getIndexedDB(store, [param._id, param._attachment, start]) return getIndexedDB(store, [param._id, param._attachment, start])
.then(function (result) { .then(function (result) {
var blobPart; var blobPart = result.blob;
if (result.blob.byteLength !== undefined) { if (result.blob.byteLength !== undefined) {
blobPart = new Blob([result.blob]); blobPart = new Blob([result.blob]);
} }
......
...@@ -232,11 +232,7 @@ ...@@ -232,11 +232,7 @@
.push(function (blob) { .push(function (blob) {
g.sourceBuffer = g.mediaSource.addSourceBuffer('audio/mpeg;'); g.sourceBuffer = g.mediaSource.addSourceBuffer('audio/mpeg;');
return jIO.util.readBlobAsArrayBuffer(blob).then(function (e) { return jIO.util.readBlobAsArrayBuffer(blob).then(function (e) {
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result)); g.buffer = e.target.result;
if (g.index >= g.size) {
g.mediaSource.endOfStream();
}
g.audio.play();
g.fin = true; g.fin = true;
}); });
}) })
...@@ -302,6 +298,8 @@ ...@@ -302,6 +298,8 @@
g.audio.src = URL.createObjectURL(blob); g.audio.src = URL.createObjectURL(blob);
g.audio.load(); g.audio.load();
g.audio.play(); g.audio.play();
} else {
g.sourceBuffer.appendBuffer(new Uint8Array(g.buffer));
} }
return RSVP.any([ return RSVP.any([
play.call(g), play.call(g),
...@@ -328,7 +326,6 @@ ...@@ -328,7 +326,6 @@
return g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result)); return g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
}); });
}), }),
loopEventListener(mute_context, "click", false, function () { loopEventListener(mute_context, "click", false, function () {
mute_context.innerHTML = g.gain.gain.value ? mute_context.innerHTML = g.gain.gain.value ?
"mute on" : "mute off"; "mute on" : "mute off";
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
} else { } else {
ipValue = ipValue.substring(ipValue.indexOf("//") + 2); ipValue = ipValue.substring(ipValue.indexOf("//") + 2);
tmp = ipValue.charAt(0); tmp = ipValue.charAt(0);
if (tmp >= '0' || tmp <= '9') { if (tmp >= '0' && tmp <= '9') {
port = ipValue.indexOf(":"); port = ipValue.indexOf(":");
portEnd = ipValue.indexOf(":/"); portEnd = ipValue.indexOf(":/");
if (port !== -1) { if (port !== -1) {
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
g.__element.getElementsByClassName("next")[0].href = url; g.__element.getElementsByClassName("next")[0].href = url;
g.id = options.id; g.id = options.id;
g.index = 3500000; g.index = 3500000;
return g.jio_getAttachment({"_id" : options.id, return g.jio_getAttachment({"_id" : g.id,
"_attachment" : "enclosure", "_attachment" : "enclosure",
"_start": 0, "_start": 0,
"_end": 3500000}); "_end": 3500000});
...@@ -81,8 +81,7 @@ ...@@ -81,8 +81,7 @@
.push(function (blob) { .push(function (blob) {
g.sourceBuffer = g.mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"'); g.sourceBuffer = g.mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
return jIO.util.readBlobAsArrayBuffer(blob).then(function (e) { return jIO.util.readBlobAsArrayBuffer(blob).then(function (e) {
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result)); g.buffer = e.target.result;
g.video.play();
g.fin = true; g.fin = true;
}); });
}) })
...@@ -123,6 +122,9 @@ ...@@ -123,6 +122,9 @@
g.video.src = URL.createObjectURL(blob); g.video.src = URL.createObjectURL(blob);
g.video.load(); g.video.load();
g.video.play(); g.video.play();
} else {
g.sourceBuffer.appendBuffer(new Uint8Array(g.buffer));
g.video.play();
} }
return RSVP.any([ return RSVP.any([
loopEventListener(g.video, "ended", false, function () { loopEventListener(g.video, "ended", false, function () {
...@@ -144,9 +146,6 @@ ...@@ -144,9 +146,6 @@
if (!g.fin) { if (!g.fin) {
return; return;
} }
if (g.mediaSource.sourceBuffers[0].updating) {
return;
}
g.fin = false; g.fin = false;
if (g.index >= g.size) { if (g.index >= g.size) {
g.mediaSource.endOfStream(); g.mediaSource.endOfStream();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment