Commit aa9071fc authored by Xiaowu Zhang's avatar Xiaowu Zhang

unsupport video seek

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