Commit a9a8596e authored by Xiaowu Zhang's avatar Xiaowu Zhang

add jio excepted when getattachment with option _start, _end

parent 92d7f2c7
...@@ -184,11 +184,11 @@ ...@@ -184,11 +184,11 @@
}); });
} }
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this, command_context = g.__element.getElementsByClassName("command")[0], mute_context = g.__element.getElementsByClassName("mute")[0], bar_context = g.__element.getElementsByClassName("bar")[0], box_context = g.__element.getElementsByClassName("box")[0], filter_context = g.__element.getElementsByClassName("filter")[0], filter_type = $("select"), loop_context = g.__element.getElementsByClassName("loop")[0], loop = false, time_context = g.__element.getElementsByClassName("time")[0]; var g = this, blob, command_context = g.__element.getElementsByClassName("command")[0], mute_context = g.__element.getElementsByClassName("mute")[0], bar_context = g.__element.getElementsByClassName("bar")[0], box_context = g.__element.getElementsByClassName("box")[0], filter_context = g.__element.getElementsByClassName("filter")[0], filter_type = $("select"), loop_context = g.__element.getElementsByClassName("loop")[0], loop = false, time_context = g.__element.getElementsByClassName("time")[0];
bar_context.value = 0; bar_context.value = 0;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
set.call(g); set.call(g);
return RSVP.all([ g.plEnablePage(), g.plGive("loop"), g.plGive("mute") ]); return RSVP.all([ g.plGive("loop"), g.plGive("mute") ]);
}).push(function(list) { }).push(function(list) {
if (list[1]) { if (list[1]) {
loop = true; loop = true;
...@@ -209,9 +209,12 @@ ...@@ -209,9 +209,12 @@
_attachment: "enclosure" _attachment: "enclosure"
}); });
} }
}).push(function(blob) { }).push(function(result) {
blob = result;
return g.plEnablePage();
}).push(function() {
if (blob) { if (blob) {
g.audio.src = URL.createObjectURL(g.blob); g.audio.src = URL.createObjectURL(blob);
g.audio.load(); g.audio.load();
g.audio.play(); g.audio.play();
} }
......
...@@ -13,9 +13,19 @@ ...@@ -13,9 +13,19 @@
<script id="network" type="text/x-handlebars-template"> <script id="network" type="text/x-handlebars-template">
{{#each rows}} {{#each rows}}
<li> <li>
<a href=#page=control&id={{this.id}}&action=localhost> {{#compare this.doc.type}}
<a href=#page=control&id={{this.id}}&action=offline>
{{this.doc.title}} {{this.doc.title}}
</a> </a>
{{else}}
<a href=#page=video_control&id={{this.id}}&action=offline>
{{this.doc.title}}
</a>
{{/compare}}
<a href=#page=playlist&id={{this.id}}&action=delete>
data-rel=popup
data-position-to=window
</a>
</li> </li>
{{/each}} {{/each}}
</script> </script>
......
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
}); });
}).push(function(e) { }).push(function(e) {
var tmp = e.data.rows, i, j, exp; var tmp = e.data.rows, i, j, exp;
Handlebars.registerHelper("compare", function(v1, options) {
if (v1 === "audio/mp3" || v1 === "audio/mpeg") {
return options.fn(this);
}
return options.inverse(this);
});
if (options.id !== undefined && options.id !== "localhost") { if (options.id !== undefined && options.id !== "localhost") {
tmp = []; tmp = [];
for (i = 0, j = 0; i < e.data.rows.length; i += 1) { for (i = 0, j = 0; i < e.data.rows.length; i += 1) {
......
...@@ -13,9 +13,19 @@ ...@@ -13,9 +13,19 @@
<script id="network" type="text/x-handlebars-template"> <script id="network" type="text/x-handlebars-template">
{{#each rows}} {{#each rows}}
<li> <li>
<a href=#page=control&id={{this.id}}&action=online> {{#compare this.doc.type}}
<a href=#page=control&id={{this.id}}&action=offline>
{{this.doc.title}} {{this.doc.title}}
</a> </a>
{{else}}
<a href=#page=video_control&id={{this.id}}&action=offline>
{{this.doc.title}}
</a>
{{/compare}}
<a href=#page=playlist&id={{this.id}}&action=delete>
data-rel=popup
data-position-to=window
</a>
</li> </li>
{{/each}} {{/each}}
</script> </script>
......
...@@ -100,6 +100,12 @@ ...@@ -100,6 +100,12 @@
}).push(function(e) { }).push(function(e) {
if (e.data) { if (e.data) {
var tmp = e.data.rows, i, j, exp; var tmp = e.data.rows, i, j, exp;
Handlebars.registerHelper("compare", function(v1, options) {
if (v1 === "audio/mp3" || v1 === "audio/mpeg") {
return options.fn(this);
}
return options.inverse(this);
});
if (options.id !== undefined && options.id !== "online") { if (options.id !== undefined && options.id !== "online") {
tmp = []; tmp = [];
for (i = 0, j = 0; i < e.data.rows.length; i += 1) { for (i = 0, j = 0; i < e.data.rows.length; i += 1) {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
var share_context = g.__element.getElementsByClassName("share")[0]; var share_context = g.__element.getElementsByClassName("share")[0];
share_context.href = "https://twitter.com/intent/tweet?hashtags=MusicPlayer&text=" + encodeURI(result.data.title); share_context.href = "https://twitter.com/intent/tweet?hashtags=MusicPlayer&text=" + encodeURI(result.data.title);
g.size = result.data.size; g.size = result.data.size;
g.format = result.data.format;
return g.displayThisTitle(options.action + " : " + result.data.title); return g.displayThisTitle(options.action + " : " + result.data.title);
}).push(function() { }).push(function() {
return g.allDocs({ return g.allDocs({
...@@ -72,23 +73,26 @@ ...@@ -72,23 +73,26 @@
}); });
} }
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this; var g = this, blob;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return g.plEnablePage();
}).push(function() {
if (g.rebuild) { if (g.rebuild) {
return g.jio_getAttachment({ return g.jio_getAttachment({
_id: g.id, _id: g.id,
_attachment: "enclosure" _attachment: "enclosure"
}); });
} }
}).push(function(blob) { }).push(function(result) {
blob = result;
return g.plEnablePage();
}).push(function() {
if (blob) { if (blob) {
g.video.src = URL.createObjectURL(g.blob); g.video.src = URL.createObjectURL(blob);
g.video.load(); g.video.load();
g.video.play(); g.video.play();
} }
return RSVP.any([ loopEventListener(g.sourceBuffer, "updateend", false, function() { return RSVP.any([ loopEventListener(g.video, "ended", false, function() {
window.location = g.__element.getElementsByClassName("next")[0].href;
}), loopEventListener(g.sourceBuffer, "updateend", false, function() {
if (!g.fin) { if (!g.fin) {
return; return;
} }
......
This diff is collapsed.
...@@ -252,6 +252,7 @@ ...@@ -252,6 +252,7 @@
}) })
.declareMethod("startService", function () { .declareMethod("startService", function () {
var g = this, var g = this,
blob,
command_context = g.__element.getElementsByClassName("command")[0], command_context = g.__element.getElementsByClassName("command")[0],
mute_context = g.__element.getElementsByClassName("mute")[0], mute_context = g.__element.getElementsByClassName("mute")[0],
bar_context = g.__element.getElementsByClassName("bar")[0], bar_context = g.__element.getElementsByClassName("bar")[0],
...@@ -266,7 +267,6 @@ ...@@ -266,7 +267,6 @@
.push(function () { .push(function () {
set.call(g); set.call(g);
return RSVP.all([ return RSVP.all([
g.plEnablePage(),
g.plGive("loop"), g.plGive("loop"),
g.plGive("mute") g.plGive("mute")
]); ]);
...@@ -290,9 +290,13 @@ ...@@ -290,9 +290,13 @@
"_attachment" : "enclosure"}); "_attachment" : "enclosure"});
} }
}) })
.push(function (blob) { .push(function (result) {
blob = result;
return g.plEnablePage();
})
.push(function () {
if (blob) { if (blob) {
g.audio.src = URL.createObjectURL(g.blob); g.audio.src = URL.createObjectURL(blob);
g.audio.load(); g.audio.load();
g.audio.play(); g.audio.play();
} }
......
...@@ -13,9 +13,19 @@ ...@@ -13,9 +13,19 @@
<script id="network" type="text/x-handlebars-template"> <script id="network" type="text/x-handlebars-template">
{{#each rows}} {{#each rows}}
<li> <li>
<a href=#page=control&id={{this.id}}&action=localhost> {{#compare this.doc.type}}
<a href=#page=control&id={{this.id}}&action=offline>
{{this.doc.title}} {{this.doc.title}}
</a> </a>
{{else}}
<a href=#page=video_control&id={{this.id}}&action=offline>
{{this.doc.title}}
</a>
{{/compare}}
<a href=#page=playlist&id={{this.id}}&action=delete>
data-rel=popup
data-position-to=window
</a>
</li> </li>
{{/each}} {{/each}}
</script> </script>
......
...@@ -40,6 +40,12 @@ ...@@ -40,6 +40,12 @@
i, i,
j, j,
exp; exp;
Handlebars.registerHelper("compare", function (v1, options) {
if (v1 === "audio/mp3" || v1 === "audio/mpeg") {
return options.fn(this);
}
return options.inverse(this);
});
if (options.id !== undefined && options.id !== "localhost") { if (options.id !== undefined && options.id !== "localhost") {
tmp = []; tmp = [];
for (i = 0, j = 0; i < e.data.rows.length; i += 1) { for (i = 0, j = 0; i < e.data.rows.length; i += 1) {
......
...@@ -13,9 +13,19 @@ ...@@ -13,9 +13,19 @@
<script id="network" type="text/x-handlebars-template"> <script id="network" type="text/x-handlebars-template">
{{#each rows}} {{#each rows}}
<li> <li>
<a href=#page=control&id={{this.id}}&action=online> {{#compare this.doc.type}}
<a href=#page=control&id={{this.id}}&action=offline>
{{this.doc.title}} {{this.doc.title}}
</a> </a>
{{else}}
<a href=#page=video_control&id={{this.id}}&action=offline>
{{this.doc.title}}
</a>
{{/compare}}
<a href=#page=playlist&id={{this.id}}&action=delete>
data-rel=popup
data-position-to=window
</a>
</li> </li>
{{/each}} {{/each}}
</script> </script>
......
...@@ -139,6 +139,12 @@ ...@@ -139,6 +139,12 @@
i, i,
j, j,
exp; exp;
Handlebars.registerHelper("compare", function (v1, options) {
if (v1 === "audio/mp3" || v1 === "audio/mpeg") {
return options.fn(this);
}
return options.inverse(this);
});
if (options.id !== undefined && options.id !== "online") { if (options.id !== undefined && options.id !== "online") {
tmp = []; tmp = [];
for (i = 0, j = 0; i < e.data.rows.length; i += 1) { for (i = 0, j = 0; i < e.data.rows.length; i += 1) {
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
"https://twitter.com/intent/tweet?hashtags=MusicPlayer&text=" "https://twitter.com/intent/tweet?hashtags=MusicPlayer&text="
+ encodeURI(result.data.title); + encodeURI(result.data.title);
g.size = result.data.size; g.size = result.data.size;
g.format = result.data.format;
return g.displayThisTitle(options.action + " : " return g.displayThisTitle(options.action + " : "
+ result.data.title); + result.data.title);
}) })
...@@ -104,24 +105,31 @@ ...@@ -104,24 +105,31 @@
} }
}) })
.declareMethod("startService", function () { .declareMethod("startService", function () {
var g = this; var g = this,
blob;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () {
return g.plEnablePage();
})
.push(function () { .push(function () {
if (g.rebuild) { if (g.rebuild) {
return g.jio_getAttachment({"_id" : g.id, return g.jio_getAttachment({"_id" : g.id,
"_attachment" : "enclosure"}); "_attachment" : "enclosure"});
} }
}) })
.push(function (blob) { .push(function (result) {
blob = result;
return g.plEnablePage();
})
.push(function () {
if (blob) { if (blob) {
g.video.src = URL.createObjectURL(g.blob); g.video.src = URL.createObjectURL(blob);
g.video.load(); g.video.load();
g.video.play(); g.video.play();
} }
return RSVP.any([ return RSVP.any([
loopEventListener(g.video, "ended", false, function () {
window.location = g.__element
.getElementsByClassName("next")[0].href;
}),
loopEventListener(g.sourceBuffer, "updateend", false, function () { loopEventListener(g.sourceBuffer, "updateend", false, function () {
if (!g.fin) { if (!g.fin) {
return; return;
......
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