Commit aa9071fc authored by Xiaowu Zhang's avatar Xiaowu Zhang

unsupport video seek

parent a0c15110
......@@ -157,6 +157,7 @@
page: "playlist"
}).push(gadget.pleaseRedirectMyHash.bind(gadget));
}
gadget.__element.getElementsByClassName("console")[0].innerHTML = "";
gadget.storageType = gadget.storageType || 0;
if (options.page === "playlist") {
if (options.id === "offline") {
......@@ -191,7 +192,7 @@
return page_gadget.startService(options);
}
}).fail(function(e) {
gadget.__element.getElementsByClassName("console")[0].innerHTML = JSON.stringify(e);
gadget.__element.getElementsByClassName("console")[0].innerHTML = e;
});
});
})(window, rJS, jQuery, RSVP);
\ No newline at end of file
/*global window, rJS, RSVP, jIO, JSON, promiseEventListener, console,
Math, ID3, FileAPIReader, dataReader, String, decodeURIComponent, escape */
Math, ID3, FileAPIReader, dataReader, String, decodeURIComponent,
DataView, escape */
/*jslint nomen: true*/
/*jslint bitwise: true*/
(function(window, jIO, rJS) {
"use strict";
var gk = rJS(window);
......
......@@ -93,38 +93,18 @@
return RSVP.any([ loopEventListener(g.video, "ended", false, function() {
window.location = g.__element.getElementsByClassName("next")[0].href;
}), loopEventListener(g.video, "seeking", false, function(e) {
g.seeking = true;
console.log(e.target.currentTime);
if (g.mediaSource.readyState === "open") {
g.mediaSource.sourceBuffers[0].abort();
}
if (g.mediaSource.readyState === "closed") {
return;
}
if (g.mediaSource.sourceBuffers[0].updating) {
return;
if (g.buffedTime === undefined) {
g.video.currentTime = 0;
} else {
if (g.video.currentTime > g.buffedTime) {
g.video.currentTime = g.buffedTime;
}
}
g.index = 35e5;
return g.jio_getAttachment({
_id: g.id,
_attachment: "enclosure",
_start: g.index,
_end: g.index + 35e5
}).then(function(blob) {
g.index += 35e5;
return jIO.util.readBlobAsArrayBuffer(blob);
}).then(function(e) {
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
g.video.play();
g.seeking = false;
});
}), loopEventListener(g.sourceBuffer, "updateend", false, function() {
g.buffedTime = g.sourceBuffer.buffered.end(0);
if (!g.fin) {
return;
}
if (g.seeking) {
return;
}
if (g.mediaSource.sourceBuffers[0].updating) {
return;
}
......@@ -139,19 +119,13 @@
_start: g.index,
_end: g.index + 35e5
}).then(function(blob) {
if (g.seeking === false) {
g.index += 35e5;
return jIO.util.readBlobAsArrayBuffer(blob);
}
g.index += 35e5;
return jIO.util.readBlobAsArrayBuffer(blob);
}).then(function(e) {
g.fin = true;
if (g.seeking === false) {
return g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
}
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
});
}) ]);
}).push(function(error) {
console.log(error);
});
});
gk.ready(function(g) {
......
......@@ -189,6 +189,8 @@
return gadget.aq_pleasePublishMyState({page: "playlist"})
.push(gadget.pleaseRedirectMyHash.bind(gadget));
}
gadget.__element.getElementsByClassName('console')[0].
innerHTML = "";
gadget.storageType = gadget.storageType || 0;
if (options.page === "playlist") {
if (options.id === "offline") {
......@@ -229,7 +231,7 @@
}
}).fail(function (e) {
gadget.__element.getElementsByClassName('console')[0].
innerHTML = JSON.stringify(e);
innerHTML = e;
});
});
}(window, rJS, jQuery, RSVP));
/*global window, rJS, RSVP, jIO, JSON, promiseEventListener, console,
Math, ID3, FileAPIReader, dataReader, String, decodeURIComponent, escape */
Math, ID3, FileAPIReader, dataReader, String, decodeURIComponent,
DataView, escape */
/*jslint nomen: true*/
/*jslint bitwise: true*/
(function (window, jIO, rJS) {
"use strict";
var gk = rJS(window);
function promiseId3(file) {
var resolver;
resolver = function (resolve) {
......
......@@ -131,39 +131,19 @@
}),
loopEventListener(g.video, "seeking", false, function (e) {
g.seeking = true;
console.log(e.target.currentTime);
if (g.mediaSource.readyState === "open") {
g.mediaSource.sourceBuffers[0].abort();
if (g.buffedTime === undefined) {
g.video.currentTime = 0;
} else {
if (g.video.currentTime > g.buffedTime) {
g.video.currentTime = g.buffedTime;
}
}
if (g.mediaSource.readyState === "closed") {
return;
}
if (g.mediaSource.sourceBuffers[0].updating) {
return;
}
g.index = 3500000;
return g.jio_getAttachment({"_id" : g.id,
"_attachment" : "enclosure",
"_start": g.index,
"_end": g.index + 3500000})
.then(function (blob) {
g.index += 3500000;
return jIO.util.readBlobAsArrayBuffer(blob);
})
.then(function (e) {
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
g.video.play();
g.seeking = false;
});
}),
loopEventListener(g.sourceBuffer, "updateend", false, function () {
g.buffedTime = g.sourceBuffer.buffered.end(0);
if (!g.fin) {
return;
}
if (g.seeking) {
return;
}
if (g.mediaSource.sourceBuffers[0].updating) {
return;
}
......@@ -177,22 +157,15 @@
"_start": g.index,
"_end": g.index + 3500000})
.then(function (blob) {
if (g.seeking === false) {
g.index += 3500000;
return jIO.util.readBlobAsArrayBuffer(blob);
}
g.index += 3500000;
return jIO.util.readBlobAsArrayBuffer(blob);
})
.then(function (e) {
g.fin = true;
if (g.seeking === false) {
return g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
}
g.sourceBuffer.appendBuffer(new Uint8Array(e.target.result));
});
})
]);
})
.push(function (error) {
console.log(error);
});
});
gk.ready(function (g) {
......
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