Record audio and save permanently in iOS

Ok I finally solved it. The problem was that I was setting up the AVAudioRecorder and file the path in the viewLoad of my ViewController.m overwriting existing files with the same name. After recording and saving the audio to file and stopping the app, I could find the file in Finder. (/Users/xxxxx/Library/Application Support/iPhone Simulator/6.0/Applications/0F107E80-27E3-4F7C-AB07-9465B575EDAB/Documents/sound1.caf) When … Read more

Android : Record sound in mp3 format

There’s a work around for saving .mp3 files using MediaRecorder. Here’s how: recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); recorder.setOutputFile(Environment.getExternalStorageDirectory() .getAbsolutePath() + “/myrecording.mp3”); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); recorder.prepare(); recorder.start(); The important part here is the setOuputFormat and the setAudioEncoder. Apparently MediaRecorder records playable mp3 if you’re using MediaRecorder.OutputFormat.MPEG_4 and MediaRecorder.AudioEncoder.AAC together. Hope this helps somebody. Of course, if you’d … Read more

Simultaneous AVCaptureVideoDataOutput and AVCaptureMovieFileOutput

I have contacted an engineer at Apple’s support and he told me that simultaneous AVCaptureVideoDataOutput + AVCaptureMovieFileOutput use is not supported. I don’t know if they will support it in the future, but he used the word “not supported at this time”. I encourage you to fill a bug report / feature request on this, … Read more

Return a value if no record is found

Encapsulate the query in a sub-query to transform “no row” to a NULL value. I tested and verified this with PostgreSQL, SQL Server and MySQL. Also works with SQLite. SELECT (SELECT id FROM tbl WHERE id = 9823474) AS id; In Oracle you have to select from the dummy 1-row table DUAL like this: SELECT … Read more

Screen Video Record of Current Activity Android

Since Lollipop we can use the Media Projection API ! (API 21+) Here is the following code that I use for recording, Note that we first need to get the user permissions for that 😉 private static final int CAST_PERMISSION_CODE = 22; private DisplayMetrics mDisplayMetrics; private MediaProjection mMediaProjection; private VirtualDisplay mVirtualDisplay; private MediaRecorder mMediaRecorder; @Override … Read more

How to get the last N records in mongodb?

If I understand your question, you need to sort in ascending order. Assuming you have some id or date field called “x” you would do … .sort() db.foo.find().sort({x:1}); The 1 will sort ascending (oldest to newest) and -1 will sort descending (newest to oldest.) If you use the auto created _id field it has a … Read more

SQL – Update multiple records in one query

Try either multi-table update syntax UPDATE config t1 JOIN config t2 ON t1.config_name=”name1″ AND t2.config_name=”name2″ SET t1.config_value=”value”, t2.config_value=”value2″; Here is a SQLFiddle demo or conditional update UPDATE config SET config_value = CASE config_name WHEN ‘name1’ THEN ‘value’ WHEN ‘name2’ THEN ‘value2’ ELSE config_value END WHERE config_name IN(‘name1’, ‘name2’); Here is a SQLFiddle demo