-
-
Save pietromalerba/5510061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.Media.showCamera({ | |
allowEditing: true, | |
success: function(event) { | |
var image = event.media; | |
var pxhr = Titanium.Network.createHTTPClient(); | |
pxhr.onerror = function() { | |
Ti.UI.createNotification({ | |
message:'Upload failed, please try again.' | |
}).show(); | |
} | |
pxhr.onload = function() { | |
Ti.UI.createNotification({ | |
message:'Uploaded: ' + this.responseText | |
}).show(); | |
}; | |
pxhr.setTimeout('10000'); | |
pxhr.open("POST","http://example.com/upload.php"); | |
pxhr.send({file:image}); | |
}, | |
cancel: function() { | |
}, | |
error: function(error) { | |
// create alert | |
var a = Titanium.UI.createAlertDialog({ | |
title:'Camera' | |
}); | |
// set message | |
if (error.code == Titanium.Media.NO_CAMERA) { | |
a.setMessage('Device does not have video recording capabilities'); | |
} else { | |
a.setMessage('Unexpected error: ' + error.code); | |
} | |
// show alert | |
a.show(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment