Commit c198f439 authored by Xiaowu Zhang's avatar Xiaowu Zhang

add initialize mechanism in audio control gadget

parent 3f7d21fa
......@@ -128,7 +128,17 @@
g.io = e;
g.io.createIO({ "type" : "indexeddb",
"database": "test"},
"m");
"m")
.then(function () {
g.io.showAllIO().then(function (result) {
var array = Object.keys(result),
i;
for (i = 0; i < array.length; i += 1) {
g.playlist.push(array[i]);
}
g.sendTotalId(g.playlist.length);
});
});
});
g.audio = new window.Audio();
g.source = g.audioCtx.createMediaElementSource(g.audio);
......@@ -137,9 +147,10 @@
g.decoded = true;
g.audio.onended = function () {
g.nextToPlay().then(function (id) {
g.setSong(id);
g.setSong(id).then(function () {
g.playSong(id);
});
});
};
input_context.onchange = function () {
var tmp,
......
/*global window, rJS, RSVP, jIO, JSON, console, indexedDB */
/*jslint nomen: true*/
(function (window, jIO, rJS) {
"use strict";
var gk = rJS(window);
gk.declareMethod('createIO', function (description, key) {
indexedDB.deleteDatabase("jio:test");
// indexedDB.deleteDatabase("jio:test");
this.jio = jIO.createJIO(description);
this.key = key;
this.jio.put({
return this.jio.put({
"_id" : key
}).then(function () {
description = JSON.stringify(description, null, " ");
console.log("JIO created: " + description + "\nwith key: " + key);
}).catch(function (e) {
return;
}).fail(function (e) {
console.log("jio created error: " + e.target.result);
return;
});
})
.declareMethod('getIO', function (attachment) {
......@@ -31,18 +33,24 @@
})
.declareMethod('setIO', function (attachment, file) {
var gadget = this;
gadget.jio.putAttachment({
return gadget.jio.putAttachment({
"_id": gadget.key,
"_attachment": attachment,
"_blob": file
}).then(function (e) {
console.log(e);
return e;
}).fail(function (error) {
return "ERROR : " + error;
});
})
.declareMethod('showAllIO', function () {
var gadget = this;
return gadget.jio.allDoc({
return gadget.jio.allDocs({
"include_docs": "m"
}).then(function (result) {
return result.data.rows[0].doc._attachment;
}).fail(function (error) {
return "ERROR : " + error;
});
});
}(window, jIO, rJS));
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