Commit 8dbd2b4a authored by Xiaowu Zhang's avatar Xiaowu Zhang

add MSE enable alert

parent be799896
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
type: "audio/mpeg" type: "audio/mpeg"
}); });
} }
g.audio.src = URL.createObjectURL(g.blob);
if (g.index < g.length) { if (g.index < g.length) {
return loopEvent(g); return loopEvent(g);
} }
...@@ -313,6 +312,7 @@ ...@@ -313,6 +312,7 @@
}); });
}); });
gk.ready(function(g) { gk.ready(function(g) {
var info;
g.audio = g.__element.getElementsByTagName("audio")[0]; g.audio = g.__element.getElementsByTagName("audio")[0];
g.audio.style.display = "none"; g.audio.style.display = "none";
g.source = audioCtx.createMediaElementSource(g.audio); g.source = audioCtx.createMediaElementSource(g.audio);
...@@ -320,6 +320,11 @@ ...@@ -320,6 +320,11 @@
g.gain = audioCtx.createGain(); g.gain = audioCtx.createGain();
g.filter = audioCtx.createBiquadFilter(); g.filter = audioCtx.createBiquadFilter();
g.canvas = g.__element.getElementsByTagName("canvas")[0]; g.canvas = g.__element.getElementsByTagName("canvas")[0];
if (MediaSource === undefined) {
info = g.__element.getElementsByClassName("info")[0];
info.innerHTML = "<ul>\n<li>for a better performence, pleasa enable MediaSource</li>\n<li>1.Type about:config into the web browser's address bar and hit enter.\nConfirm that you will be careful if a warning message is displayed.</li>\n<li>2.search for media.mediasource.enabled and double-click the name.</li>\n</ul>";
return;
}
g.mediaSource = new MediaSource(); g.mediaSource = new MediaSource();
g.audio.src = URL.createObjectURL(g.mediaSource); g.audio.src = URL.createObjectURL(g.mediaSource);
}); });
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
<button type="button" data-icon="refresh" class="loop" ></button> <button type="button" data-icon="refresh" class="loop" ></button>
<div class="info">
</div>
<div id="visualizer"> <div id="visualizer">
<canvas id="can" width="800" height="350"> <canvas id="can" width="800" height="350">
!Canvas not supported by your browser !Canvas not supported by your browser
......
...@@ -10,6 +10,30 @@ ...@@ -10,6 +10,30 @@
(function(window, rJS, RSVP, loopEventListener, $, promiseEventListener) { (function(window, rJS, RSVP, loopEventListener, $, promiseEventListener) {
"use strict"; "use strict";
var gk = rJS(window), MediaSource = window.MediaSource || window.WebKitMediaSource || window.mozMediaSource; var gk = rJS(window), MediaSource = window.MediaSource || window.WebKitMediaSource || window.mozMediaSource;
function loopEvent(g) {
return new RSVP.Queue().push(function() {
if (g.rebuild) {
return g.jio_getAttachment({
_id: g.id,
_attachment: "enclosure" + g.index
});
}
}).push(function(blob) {
if (g.rebuild) {
g.index += 1;
if (g.blob) {
g.blob = new Blob([ g.blob, blob ]);
} else {
g.blob = new Blob([ blob ]);
}
if (g.index < g.length) {
return loopEvent(g);
}
}
}).push(undefined, function(error) {
throw error;
});
}
gk.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment").declareAcquiredMethod("jio_get", "jio_get").declareAcquiredMethod("jio_remove", "jio_remove").declareAcquiredMethod("plSave", "plSave").declareAcquiredMethod("plGive", "plGive").declareAcquiredMethod("displayThisPage", "displayThisPage").declareAcquiredMethod("displayThisTitle", "displayThisTitle").declareAcquiredMethod("allDocs", "allDocs").declareAcquiredMethod("plEnablePage", "plEnablePage").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareMethod("render", function(options) { gk.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment").declareAcquiredMethod("jio_get", "jio_get").declareAcquiredMethod("jio_remove", "jio_remove").declareAcquiredMethod("plSave", "plSave").declareAcquiredMethod("plGive", "plGive").declareAcquiredMethod("displayThisPage", "displayThisPage").declareAcquiredMethod("displayThisTitle", "displayThisTitle").declareAcquiredMethod("allDocs", "allDocs").declareAcquiredMethod("plEnablePage", "plEnablePage").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareMethod("render", function(options) {
var g = this; var g = this;
if (options.id) { if (options.id) {
...@@ -62,12 +86,10 @@ ...@@ -62,12 +86,10 @@
}); });
}).push(undefined, function(error) { }).push(undefined, function(error) {
if (!(error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
window.location = g.__element.getElementsByClassName("next")[0].href; g.rebuild = true;
if (error.status === 404 && error.method === "getAttachment") { //xxx
return g.jio_remove({ g.sourceBuffer = new Audio();
_id: error.id return;
});
}
} }
}); });
} }
...@@ -76,6 +98,15 @@ ...@@ -76,6 +98,15 @@
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return g.plEnablePage(); return g.plEnablePage();
}).push(function() { }).push(function() {
if (g.rebuild) {
return loopEvent(g);
}
}).push(function() {
if (g.blob) {
g.video.src = URL.createObjectURL(g.blob);
g.video.load();
g.video.play();
}
return RSVP.any([ loopEventListener(g.sourceBuffer, "updateend", false, function() { return RSVP.any([ loopEventListener(g.sourceBuffer, "updateend", false, function() {
if (!g.fin) { if (!g.fin) {
return; return;
...@@ -101,7 +132,13 @@ ...@@ -101,7 +132,13 @@
}); });
}); });
gk.ready(function(g) { gk.ready(function(g) {
var info;
g.video = g.__element.getElementsByTagName("video")[0]; g.video = g.__element.getElementsByTagName("video")[0];
if (MediaSource === undefined) {
info = g.__element.getElementsByClassName("info")[0];
info.innerHTML = "<ul>\n<li>for a better performence, pleasa enable MediaSource</li>\n<li>1.Type about:config into the web browser's address bar and hit enter.\nConfirm that you will be careful if a warning message is displayed.</li>\n<li>2.search for media.mediasource.enabled and double-click the name.</li>\n</ul>";
return;
}
g.mediaSource = new MediaSource(); g.mediaSource = new MediaSource();
g.video.src = URL.createObjectURL(g.mediaSource); g.video.src = URL.createObjectURL(g.mediaSource);
}); });
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<link rel="stylesheet" href="./control.css" media="screen" ></link> <link rel="stylesheet" href="./control.css" media="screen" ></link>
</head> </head>
<body> <body>
<div class="info">
</div>
<div id="video" > <div id="video" >
<video id="videoControl" class="videoMP4" controls> <video id="videoControl" class="videoMP4" controls>
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
} else { } else {
g.blob = new Blob([blob], {type: "audio/mpeg"}); g.blob = new Blob([blob], {type: "audio/mpeg"});
} }
g.audio.src = URL.createObjectURL(g.blob);
if (g.index < g.length) { if (g.index < g.length) {
return loopEvent(g); return loopEvent(g);
} }
...@@ -404,6 +403,7 @@ ...@@ -404,6 +403,7 @@
}); });
}); });
gk.ready(function (g) { gk.ready(function (g) {
var info;
g.audio = g.__element.getElementsByTagName('audio')[0]; g.audio = g.__element.getElementsByTagName('audio')[0];
g.audio.style.display = "none"; g.audio.style.display = "none";
g.source = audioCtx.createMediaElementSource(g.audio); g.source = audioCtx.createMediaElementSource(g.audio);
...@@ -411,6 +411,16 @@ ...@@ -411,6 +411,16 @@
g.gain = audioCtx.createGain(); g.gain = audioCtx.createGain();
g.filter = audioCtx.createBiquadFilter(); g.filter = audioCtx.createBiquadFilter();
g.canvas = g.__element.getElementsByTagName('canvas')[0]; g.canvas = g.__element.getElementsByTagName('canvas')[0];
if (MediaSource === undefined) {
info = g.__element.getElementsByClassName('info')[0];
info.innerHTML = "<ul>
<li>for a better performence, pleasa enable MediaSource</li>
<li>1.Type about:config into the web browser's address bar and hit enter.
Confirm that you will be careful if a warning message is displayed.</li>
<li>2.search for media.mediasource.enabled and double-click the name.</li>
</ul>";
return;
}
g.mediaSource = new MediaSource(); g.mediaSource = new MediaSource();
g.audio.src = URL.createObjectURL(g.mediaSource); g.audio.src = URL.createObjectURL(g.mediaSource);
}); });
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
<button type="button" data-icon="refresh" class="loop" ></button> <button type="button" data-icon="refresh" class="loop" ></button>
<div class="info">
</div>
<div id="visualizer"> <div id="visualizer">
<canvas id="can" width="800" height="350"> <canvas id="can" width="800" height="350">
!Canvas not supported by your browser !Canvas not supported by your browser
......
...@@ -17,6 +17,31 @@ ...@@ -17,6 +17,31 @@
var gk = rJS(window), var gk = rJS(window),
MediaSource = window.MediaSource || window.WebKitMediaSource MediaSource = window.MediaSource || window.WebKitMediaSource
|| window.mozMediaSource; || window.mozMediaSource;
function loopEvent(g) {
return new RSVP.Queue()
.push(function () {
if (g.rebuild) {
return g.jio_getAttachment({"_id" : g.id,
"_attachment" : "enclosure" + g.index });
}
})
.push(function (blob) {
if (g.rebuild) {
g.index += 1;
if (g.blob) {
g.blob = new Blob([g.blob, blob]);
} else {
g.blob = new Blob([blob]);
}
if (g.index < g.length) {
return loopEvent(g);
}
}
})
.push(undefined, function (error) {
throw error;
});
}
gk.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") gk.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_remove", "jio_remove") .declareAcquiredMethod("jio_remove", "jio_remove")
...@@ -84,12 +109,18 @@ ...@@ -84,12 +109,18 @@
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
if (!(error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
g.rebuild = true;
//xxx
g.sourceBuffer = new Audio();
return;
/* if (MediaSource) {
window.location = g.__element window.location = g.__element
.getElementsByClassName("next")[0].href; .getElementsByClassName("next")[0].href;
if ((error.status === 404) if ((error.status === 404)
&& (error.method === "getAttachment")) { && (error.method === "getAttachment")) {
return g.jio_remove({"_id" : error.id}); return g.jio_remove({"_id" : error.id});
} }
}*/
} }
}); });
} }
...@@ -101,6 +132,16 @@ ...@@ -101,6 +132,16 @@
return g.plEnablePage(); return g.plEnablePage();
}) })
.push(function () { .push(function () {
if (g.rebuild) {
return loopEvent(g);
}
})
.push(function () {
if (g.blob) {
g.video.src = URL.createObjectURL(g.blob);
g.video.load();
g.video.play();
}
return RSVP.any([ return RSVP.any([
loopEventListener(g.sourceBuffer, "updateend", false, function () { loopEventListener(g.sourceBuffer, "updateend", false, function () {
if (!g.fin) { if (!g.fin) {
...@@ -129,7 +170,18 @@ ...@@ -129,7 +170,18 @@
}); });
}); });
gk.ready(function (g) { gk.ready(function (g) {
var info;
g.video = g.__element.getElementsByTagName('video')[0]; g.video = g.__element.getElementsByTagName('video')[0];
if (MediaSource === undefined) {
info = g.__element.getElementsByClassName('info')[0];
info.innerHTML = "<ul>
<li>for a better performence, pleasa enable MediaSource</li>
<li>1.Type about:config into the web browser's address bar and hit enter.
Confirm that you will be careful if a warning message is displayed.</li>
<li>2.search for media.mediasource.enabled and double-click the name.</li>
</ul>";
return;
}
g.mediaSource = new MediaSource(); g.mediaSource = new MediaSource();
g.video.src = URL.createObjectURL(g.mediaSource); g.video.src = URL.createObjectURL(g.mediaSource);
}); });
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<link rel="stylesheet" href="./control.css" media="screen" ></link> <link rel="stylesheet" href="./control.css" media="screen" ></link>
</head> </head>
<body> <body>
<div class="info">
</div>
<div id="video" > <div id="video" >
<video id="videoControl" class="videoMP4" controls> <video id="videoControl" class="videoMP4" controls>
......
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