|
|
4. Creating a new recording listWhen a user adds the Voice Memo gadget to iGoogle, a new recording list must be created to store the memos that will be added to the gadget. There is no need for any user interaction at this point, as there is no benefit in naming our recording list, or in selecting a specific password. Both the recording list and its password will be stored as iGoogle hidden user preferences. In our gadget init() function, we retrieve the value of the user preference recording list key, using the _IG_Prefs() Google Gadget API object. If the key is empty, we know that the gadget has not yet been initialized, and we make our first MyVox API call to create a recording list. function createNewVoiceBlog() { // Generate a random password var passwd = Math.floor(Math.random() * 1000000); prefs.set('password', passwd); // Create the new voice blog on the MyVox server myVox.createRecordingList('Voice Memo', passwd, createRecordingListCallback); } The callback createRecordingListCallback() will save the recording list key in the user preference, and will initialize our local API before initializing the user interface of the gadget. Next, 5. Creating a new recording |