Skip to content
Permalink
Browse files
updated several tests for iOS
audio - create file to record to via file API's for iOS devices
contacts - check for existence of object before accessing -- if (contact.emails && contact.emails.length).
Notifications - fixed some copy/paste errors. JavaScript examples are now correct.
Misc - moved Map IBM to Android only since other platforms do not support geo: uri.  Added history.back to page2.html.
  • Loading branch information
becka11y committed Jul 21, 2011
1 parent 5f4bd0e commit 8d24f308ada2c0f3a1387e348c1c261b589bc0a4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 17 deletions.
@@ -19,6 +19,7 @@
var media1 = null;
var media1Timer = null;
var audioSrc = null;
var recordSrc = "myRecording.mp3";

/**
* Play audio
@@ -76,10 +77,10 @@
});
}
audioSrc = src;

document.getElementById('audio_duration').innerHTML = "";
// Play audio
media1.play();
if (media1Timer == null) {
if (media1Timer == null && media1.getCurrentPosition) {
media1Timer = setInterval(
function() {
media1.getCurrentPosition(
@@ -165,7 +166,7 @@
console.log(" -- media="+mediaRec);
if (mediaRec == null) {

var src = "myrecording.mp3";
var src = recordSrc;
mediaRec = new Media(src,
function() {
console.log("recordAudio():Audio Success");
@@ -193,7 +194,11 @@
setAudioPosition(recTime+" sec");
if (recTime >= 10) {
clearInterval(recInterval);
mediaRec.stopRecord();
if (mediaRec.stopAudioRecord){
mediaRec.stopAudioRecord();
} else {
mediaRec.stopRecord();
}
console.log("recordAudio(): stop");
navigator.notification.beep(1);
}
@@ -204,7 +209,24 @@
* Play back recorded audio
*/
function playRecording() {
playAudio("myrecording.mp3");
playAudio(recordSrc);
}

/**
* Function to create a file for iOS recording
*/
function getRecordSrc() {
var fsFail = function(error) {
console.log("error creating file for iOS recording");
};
var gotFile = function(file) {
recordSrc = file.fullPath;
//console.log("recording Src: " + recordSrc);
};
var gotFS = function(fileSystem) {
fileSystem.root.getFile("iOSRecording.wav", {create: true}, gotFile, fsFail);
};
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
}

/**
@@ -213,6 +235,10 @@
function init() {
document.addEventListener("deviceready", function() {
deviceReady = true;
if (device.platform.indexOf("iPhone") !=-1 || device.platform.indexOf("iPad") !=-1)
{
getRecordSrc();
}
console.log("Device="+device.platform+" "+device.version);
}, false);
window.setTimeout(function() {
@@ -230,7 +256,7 @@
<h1>Audio</h1>
<div id="info">
<table width="100%">
<tr><td><b>Status:</b></td><td id="audio_status">Stopped</td></tr>
<tr><td><b>Status:</b></td><td id="audio_status">&nbsp;</td></tr>
<tr><td><b>Duration:</b></td><td id="audio_duration"></td></tr>
<tr><td><b>Position:</b></td><td id="audio_position"></td></tr>
</table>
@@ -241,6 +267,7 @@ <h2>Action</h2>
<a href="javascript:" class="btn large" onclick="stopAudio();">Stop Playing Audio</a>
<a href="javascript:" class="btn large" onclick="recordAudio();">Record Audio for 10 sec</a>
<a href="javascript:" class="btn large" onclick="playRecording();">Play/Unpause Recording</a>
<h2>&nbsp</h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
<h2>&nbsp</h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>

</body>
</html>
@@ -20,7 +20,6 @@
obj = new ContactFindOptions();
obj.filter = "D"; //Brooks";
obj.multiple = true;
obj.limit = 1000;
navigator.contacts.find(
["displayName", "name", "phoneNumbers", "emails", "urls", "note"],
function(contacts) {
@@ -33,11 +32,11 @@
for (var i=0; i<contacts.length; i++) {
var contact = contacts[i];
s = s + "<tr><td>" + contact.name.formatted + "</td><td>";
if (contact.phoneNumbers.length > 0) {
if (contact.phoneNumbers && contact.phoneNumbers.length > 0) {
s = s + contact.phoneNumbers[0].value;
}
s = s + "</td><td>"
if (contact.emails.length > 0) {
if (contact.emails && contact.emails.length > 0) {
s = s + contact.emails[0].value;
}
s = s + "</td></tr>";
@@ -47,7 +46,7 @@
document.getElementById('contacts_results').innerHTML = s;
},
function(e) {
document.getElementById('contacts_results').innerHTML = "Error: "+e;
document.getElementById('contacts_results').innerHTML = "Error: "+e.code;
},
obj);
};
@@ -72,7 +71,7 @@

contact.save(
function() { alert("Contact saved.");},
function(e) { alert("Contact save failed: " + e); }
function(e) { alert("Contact save failed: " + e.code); }
);
console.log("you have saved the contact");
}
@@ -44,14 +44,14 @@ <h1>Display Other Content</h1>
</div>
<h2>Action</h2>
<a href="javascript:" class="btn large" onclick="document.location='tel:5551212';" >Call 411</a>
<a href="geo:0,0?q=11400 Burnet Rd, Austin, TX" class="btn large">Map IBM</a>
<a href="mailto:bob@abc.org?subject=My Subject&body=This is the body.%0D%0ANew line." class="btn large">Send Mail</a>
<a href="sms:5125551234?body=The SMS message." class="btn large">Send SMS</a>
<a href="http://www.google.com" class="btn large">Load Web Site</a>
<!-- Need new URL -->
<!-- a href="http://handle.library.cornell.edu/control/authBasic/authTest/" class="btn large">Basic Auth: test/this</a -->
<a href="page2.html?me=test" class="btn large">Load another PhoneGap page</a>
<h2>Android Only</h2>
<a href="geo:0,0?q=11400 Burnet Rd, Austin, TX" class="btn large">Map IBM</a>
<a href="market://search?q=google" class="btn large">Search Android market</a>
<a href="content://media/external/images/media" class="btn large">View image app</a>

@@ -20,5 +20,6 @@ <h4>Name: <span id="name">&nbsp;</span></h4>
<h4>Width: <span id="width"> &nbsp;</span>, Height: <span id="height">&nbsp;
</span>, Color Depth: <span id="colorDepth"></span></h4>
</div>
<div><button onclick="history.back();">Back</button></div>
</body>
</html>
@@ -39,7 +39,7 @@
navigator.notification.confirm(message,
function(r) {
console.log("You selected " + r);
prompt("You selected " + r);
alert("You selected " + (buttons.split(","))[r-1]);
},
title,
buttons);
@@ -74,9 +74,9 @@ <h2>Action</h2>
<a href="javascript:" class="btn large" onclick="vibrate();">Vibrate</a>
<a href="javascript:" class="btn large" onclick="alertDialog('You pressed alert.', 'Alert Dialog', 'Continue');">Alert Dialog</a>
<a href="javascript:" class="btn large" onclick="confirmDialog('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');">Confirm Dialog</a>
<a href="javascript:" class="btn large" onclick="alert('You pressed alert.', 'Alert Dialog', 'Continue');">Built-in Alert Dialog</a>
<a href="javascript:" class="btn large" onclick="alert('You entered '+ confirm('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe'));">Built-in Confirm Dialog</a>
<a href="javascript:" class="btn large" onclick="alert('You entered ' + prompt('This is a prompt.', 'Default value'));">Built-in Prompt Dialog</a>
<a href="javascript:" class="btn large" onclick="alert('You pressed alert.');">Built-in Alert Dialog</a>
<a href="javascript:" class="btn large" onclick="confirm('You selected confirm');">Built-in Confirm Dialog</a>
<a href="javascript:" class="btn large" onclick="prompt('This is a prompt.', 'Default value');">Built-in Prompt Dialog</a>
<h2>&nbsp</h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
</body>
</html>

0 comments on commit 8d24f30

Please sign in to comment.