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

change addbuffer position for updateend event

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