How to limit native voice recorder at certain time period and size?
Asked Answered
P

1

1

I'm calling native voice recorder with help of an intent

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);

And Its capturing voice as i expected. But I couldn't auto stop recording with certain length and size constraints. I tried with following options

// To Limit duration
        intent.putExtra("android.intent.extra.durationLimit", 10);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10);

// To Limit size 
        intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024);

I'm using Samsung Tab 4 running on KitKat.

Perspire answered 13/1, 2015 at 7:43 Comment(1)
below answer help you or not?Plasticine
Z
3

Use EXTRA_MAX_BYTES to stop recoding when maximum length reached.for example:

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
String MAX_SIZE = android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES;
long bytes = (long) (5900 * 4L); 
intent.putExtra(MAX_SIZE, bytes);
startActivityForResult(intent, REQUESTCODE);
Zionism answered 13/1, 2015 at 8:0 Comment(1)
Hi @ρяσѕρєя K ,Thanks a lot.It helped me out to limit the size :) So my goal has been partially reached. But I have a concern around this, That's why your answer is not accepted yet .When i started recording voice it shows remaining time available based on the memory allotted.But time decreasing double the amount than displayed. Say its started off with 30 sec available but it got terminated at 15 sec. Even time also reducing 2 sec at a shot like (30,28,26...4,2,0).Perspire

© 2022 - 2024 — McMap. All rights reserved.