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;
} }
......
...@@ -526,15 +526,12 @@ constants.http_status_text = { ...@@ -526,15 +526,12 @@ constants.http_status_text = {
"0": "Unknown", "0": "Unknown",
"550": "Internal JIO Error", "550": "Internal JIO Error",
"551": "Internal Storage Error", "551": "Internal Storage Error",
"555": "Cancelled",
"Unknown": "Unknown", "Unknown": "Unknown",
"Internal JIO Error": "Internal JIO Error", "Internal JIO Error": "Internal JIO Error",
"Internal Storage Error": "Internal Storage Error", "Internal Storage Error": "Internal Storage Error",
"Cancelled": "Cancelled",
"unknown": "Unknown", "unknown": "Unknown",
"internal_jio_error": "Internal JIO Error", "internal_jio_error": "Internal JIO Error",
"internal_storage_error": "Internal Storage Error", "internal_storage_error": "Internal Storage Error",
"cancelled": "Cancelled",
"200": "Ok", "200": "Ok",
"201": "Created", "201": "Created",
...@@ -641,15 +638,12 @@ constants.http_status = { ...@@ -641,15 +638,12 @@ constants.http_status = {
"0": 0, "0": 0,
"550": 550, "550": 550,
"551": 551, "551": 551,
"555": 555,
"Unknown": 0, "Unknown": 0,
"Internal JIO Error": 550, "Internal JIO Error": 550,
"Internal Storage Error": 551, "Internal Storage Error": 551,
"Cancelled": 555,
"unknown": 0, "unknown": 0,
"internal_jio_error": 550, "internal_jio_error": 550,
"internal_storage_error": 551, "internal_storage_error": 551,
"cancelled": 555,
"200": 200, "200": 200,
"201": 201, "201": 201,
...@@ -756,15 +750,12 @@ constants.http_action = { ...@@ -756,15 +750,12 @@ constants.http_action = {
"0": "error", "0": "error",
"550": "error", "550": "error",
"551": "error", "551": "error",
"555": "error",
"Unknown": "error", "Unknown": "error",
"Internal JIO Error": "error", "Internal JIO Error": "error",
"Internal Storage Error": "error", "Internal Storage Error": "error",
"Cancelled": "error",
"unknown": "error", "unknown": "error",
"internal_jio_error": "error", "internal_jio_error": "error",
"internal_storage_error": "error", "internal_storage_error": "error",
"cancelled": "error",
"200": "success", "200": "success",
"201": "success", "201": "success",
...@@ -1214,22 +1205,8 @@ function generateUuid() { ...@@ -1214,22 +1205,8 @@ function generateUuid() {
exports.util.generateUuid = generateUuid; exports.util.generateUuid = generateUuid;
/** /**
* Concatenate a `string` `n` times. * JSON stringify a value. Dict keys are sorted in order to make a kind of
* * deepEqual thanks to a simple strict equal string comparison.
* @param {String} string The string to concat
* @param {Number} n The number of time to concat
* @return {String} The concatenated string
*/
function concatStringNTimes(string, n) {
/*jslint plusplus: true */
var res = "";
while (--n >= 0) { res += string; }
return res;
}
/**
* JSON stringify a value. Object keys are sorted in order to make a kind of
* deepEqual thanks to a simple string comparison.
* *
* JSON.stringify({"a": "b", "c": "d"}) === * JSON.stringify({"a": "b", "c": "d"}) ===
* JSON.stringify({"c": "d", "a": "b"}) // false * JSON.stringify({"c": "d", "a": "b"}) // false
...@@ -1240,84 +1217,43 @@ function concatStringNTimes(string, n) { ...@@ -1240,84 +1217,43 @@ function concatStringNTimes(string, n) {
* uniqueJSONStringify({"c": "d", "a": "b"}) // true * uniqueJSONStringify({"c": "d", "a": "b"}) // true
* *
* @param {Any} value The value to stringify * @param {Any} value The value to stringify
* @param {Function,Array} [replacer] A function to replace values during parse * @param {Function} [replacer] A function to replace values during parse
* @param {String,Number} [space] Causes the result to be pretty-printed
* @return {String} The unique JSON stringified value
*/ */
function uniqueJSONStringify(value, replacer, space) { function uniqueJSONStringify(value, replacer) {
var indent, key_value_space = ""; function subStringify(value, key) {
if (typeof space === "string") { var i, res;
if (space !== "") { if (typeof replacer === 'function') {
indent = space;
key_value_space = " ";
}
} else if (typeof space === "number") {
if (isFinite(space) && space > 0) {
indent = concatStringNTimes(" ", space);
key_value_space = " ";
}
}
function uniqueJSONStringifyRec(key, value, deep) {
var i, l, res, my_space;
if (value && typeof value.toJSON === "function") {
value = value.toJSON();
}
if (typeof replacer === "function") {
value = replacer(key, value); value = replacer(key, value);
} }
if (indent) {
my_space = concatStringNTimes(indent, deep);
}
if (Array.isArray(value)) { if (Array.isArray(value)) {
res = []; res = [];
for (i = 0; i < value.length; i += 1) { for (i = 0; i < value.length; i += 1) {
res[res.length] = uniqueJSONStringifyRec(i, value[i], deep + 1); res[res.length] = subStringify(value[i], i);
if (res[res.length - 1] === undefined) { if (res[res.length - 1] === undefined) {
res[res.length - 1] = "null"; res[res.length - 1] = 'null';
} }
} }
if (res.length === 0) { return "[]"; } return '[' + res.join(',') + ']';
if (indent) {
return "[\n" + my_space + indent +
res.join(",\n" + my_space + indent) +
"\n" + my_space + "]";
}
return "[" + res.join(",") + "]";
} }
if (typeof value === "object" && value !== null) { if (typeof value === 'object' && value !== null &&
if (Array.isArray(replacer)) { typeof value.toJSON !== 'function') {
res = replacer.reduce(function (p, c) { res = [];
p.push(c); for (i in value) {
return p; if (value.hasOwnProperty(i)) {
}, []); res[res.length] = subStringify(value[i], i);
} else { if (res[res.length - 1] !== undefined) {
res = Object.keys(value); res[res.length - 1] = JSON.stringify(i) + ":" + res[res.length - 1];
} } else {
res.sort(); res.length -= 1;
for (i = 0, l = res.length; i < l; i += 1) { }
key = res[i];
res[i] = uniqueJSONStringifyRec(key, value[key], deep + 1);
if (res[i] !== undefined) {
res[i] = JSON.stringify(key) + ":" + key_value_space + res[i];
} else {
res.splice(i, 1);
l -= 1;
i -= 1;
} }
} }
if (res.length === 0) { return "{}"; } res.sort();
if (indent) { return '{' + res.join(',') + '}';
return "{\n" + my_space + indent +
res.join(",\n" + my_space + indent) +
"\n" + my_space + "}";
}
return "{" + res.join(",") + "}";
} }
return JSON.stringify(value); return JSON.stringify(value);
} }
return uniqueJSONStringifyRec("", value, 0); return subStringify(value, '');
} }
exports.util.uniqueJSONStringify = uniqueJSONStringify; exports.util.uniqueJSONStringify = uniqueJSONStringify;
...@@ -2832,7 +2768,7 @@ function addJobRuleCondition(name, method) { ...@@ -2832,7 +2768,7 @@ function addJobRuleCondition(name, method) {
exports.addJobRuleCondition = addJobRuleCondition; exports.addJobRuleCondition = addJobRuleCondition;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */
/*global constants, dictUpdate, deepClone, DOMException */ /*global constants, dictUpdate, deepClone */
function restCommandRejecter(param, args) { function restCommandRejecter(param, args) {
// reject(status, reason, message, {"custom": "value"}); // reject(status, reason, message, {"custom": "value"});
...@@ -2905,22 +2841,8 @@ function restCommandRejecter(param, args) { ...@@ -2905,22 +2841,8 @@ function restCommandRejecter(param, args) {
if ((arg.statusText || arg.status >= 0)) { if ((arg.statusText || arg.status >= 0)) {
current_priority.status = arg.statusText || arg.status; current_priority.status = arg.statusText || arg.status;
} }
if (arg instanceof Error || arg instanceof DOMException) { if (arg instanceof Error) {
if (arg.code !== undefined && arg.code !== null) { current_priority.reason = arg.message || "";
current_priority.code = arg.code;
}
if (arg.lineNumber !== undefined && arg.lineNumber !== null) {
current_priority.lineNumber = arg.lineNumber;
}
if (arg.columnNumber !== undefined && arg.columnNumber !== null) {
current_priority.columnNumber = arg.columnNumber;
}
if (arg.filename !== undefined && arg.filename !== null) {
current_priority.filename = arg.filename;
}
if (arg.message !== undefined && arg.message !== null) {
current_priority.reason = arg.message;
}
current_priority.error = arg.name; current_priority.error = arg.name;
} }
} }
...@@ -2951,7 +2873,6 @@ function restCommandRejecter(param, args) { ...@@ -2951,7 +2873,6 @@ function restCommandRejecter(param, args) {
priority.error = priority.statusText.toLowerCase().replace(/ /g, '_'). priority.error = priority.statusText.toLowerCase().replace(/ /g, '_').
replace(/[^_a-z]/g, ''); replace(/[^_a-z]/g, '');
} }
param.storage_response = priority;
return param.solver.reject(deepClone(priority)); return param.solver.reject(deepClone(priority));
} }
...@@ -3079,7 +3000,6 @@ function restCommandResolver(param, args) { ...@@ -3079,7 +3000,6 @@ function restCommandResolver(param, args) {
]); ]);
} }
param.storage_response = priority;
return param.solver.resolve(deepClone(priority)); return param.solver.resolve(deepClone(priority));
} }
...@@ -3126,11 +3046,11 @@ function enableJobChecker(jio, shared, options) { ...@@ -3126,11 +3046,11 @@ function enableJobChecker(jio, shared, options) {
if (!original_job.solver) { if (!original_job.solver) {
original_job.solver = new_job.solver; original_job.solver = new_job.solver;
} else { } else {
original_job.promise.then(function () { original_job.promise.then(
new_job.command.resolve(deepClone(original_job.storage_response)); new_job.command.resolve,
}, function () { new_job.command.reject,
new_job.command.reject(deepClone(original_job.storage_response)); new_job.command.notify
}, new_job.command.notify); );
} }
} }
new_job.state = 'running'; new_job.state = 'running';
...@@ -3499,13 +3419,6 @@ function enableJobMaker(jio, shared, options) { ...@@ -3499,13 +3419,6 @@ function enableJobMaker(jio, shared, options) {
job.command.storage = function () { job.command.storage = function () {
return shared.createRestApi.apply(null, arguments); return shared.createRestApi.apply(null, arguments);
}; };
job.command.setCanceller = function (canceller) {
job.cancellers["command:canceller"] = canceller;
};
job.cancellers = job.cancellers || {};
job.cancellers["job:canceller"] = function () {
shared.emit("job:reject", job, ["cancelled"]);
};
} }
function createJobFromRest(param) { function createJobFromRest(param) {
...@@ -3686,10 +3599,9 @@ function enableJobRecovery(jio, shared, options) { ...@@ -3686,10 +3599,9 @@ function enableJobRecovery(jio, shared, options) {
var i, job_array, delay, deadline, recovery_delay; var i, job_array, delay, deadline, recovery_delay;
// 1 m 30 s === default firefox request timeout recovery_delay = numberOrDefault(options.recovery_delay, 10000);
recovery_delay = numberOrDefault(options.recovery_delay, 90000);
if (recovery_delay < 0) { if (recovery_delay < 0) {
recovery_delay = 90000; recovery_delay = 10000;
} }
if (options.job_management !== false && options.job_recovery !== false) { if (options.job_management !== false && options.job_recovery !== false) {
...@@ -3890,8 +3802,8 @@ function enableJobTimeout(jio, shared, options) { ...@@ -3890,8 +3802,8 @@ function enableJobTimeout(jio, shared, options) {
number : default_value); number : default_value);
} }
// Infinity by default // 10 seconds by default
var default_timeout = positiveNumberOrDefault(options.default_timeout, 0); var default_timeout = positiveNumberOrDefault(options.default_timeout, 10000);
function timeoutReject(param) { function timeoutReject(param) {
return function () { return function () {
...@@ -3906,8 +3818,7 @@ function enableJobTimeout(jio, shared, options) { ...@@ -3906,8 +3818,7 @@ function enableJobTimeout(jio, shared, options) {
} }
function initJob(job) { function initJob(job) {
if (typeof job.timeout !== 'number' || !isFinite(job.timeout) || if (typeof job.timeout !== 'number' || job.timeout < 0) {
job.timeout < 0) {
job.timeout = positiveNumberOrDefault( job.timeout = positiveNumberOrDefault(
job.options.timeout, job.options.timeout,
default_timeout default_timeout
...@@ -4006,7 +3917,6 @@ function enableRestAPI(jio, shared) { // (jio, shared, options) ...@@ -4006,7 +3917,6 @@ function enableRestAPI(jio, shared) { // (jio, shared, options)
param.solver.reject = reject; param.solver.reject = reject;
param.solver.notify = notify; param.solver.notify = notify;
}, function () { }, function () {
if (!param.cancellers) { return; }
var k; var k;
for (k in param.cancellers) { for (k in param.cancellers) {
if (param.cancellers.hasOwnProperty(k)) { if (param.cancellers.hasOwnProperty(k)) {
...@@ -4147,13 +4057,39 @@ function enableRestParamChecker(jio, shared) { ...@@ -4147,13 +4057,39 @@ function enableRestParamChecker(jio, shared) {
} }
}); });
shared.on('getAttachment', function (param) {
if (param.storage_spec.type !== "indexeddb" &&
(param.kwargs._start !== undefined ||
param.kwargs._end !== undefined)) {
restCommandRejecter(param, [
'bad_request',
'not support',
'options _start, _end do not support.'
]);
delete param.solver;
return false;
}
if (!checkId(param)) {
checkAttachmentId(param);
}
});
shared.on('removeAttachment', function (param) {
if (!checkId(param)) {
checkAttachmentId(param);
}
});
/*
["getAttachment", "removeAttachment"].forEach(function (method) { ["getAttachment", "removeAttachment"].forEach(function (method) {
shared.on(method, function (param) { shared.on(method, function (param) {
if (!checkId(param)) { if (!checkId(param)) {
checkAttachmentId(param); checkAttachmentId(param);
} }
}); });
}); });*/
["check", "repair"].forEach(function (method) { ["check", "repair"].forEach(function (method) {
shared.on(method, function (param) { shared.on(method, function (param) {
......
...@@ -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