Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRonald Muller
2,430 PointsSetting the video duration limit not working
I have tested this on two devices, HTC One and Galaxy Nexus, both do not limit the duration. HTC One continues past the defined limit and the Galaxy Nexus doesn't record at all. Any ideas on how to rewrite this code to do so across multiple devices/manufactures? (Or am I missing something else here?)
Note: I tried using the API specified constant value in the documentation: "android:intent.extra.finishOnCompletion" in place of "MediaStore.EXTRA_DURATION_LIMIT". They both seem to be interchangeable and perform (or don't perform) the same action(s).
Edit: From what I am finding this seems to be a constant issue. Anyone know a good workaround? Maybe a way to stop the intent after a period of time regardless of the activity?
2 Answers
Ben Jakuben
Treehouse TeacherThe issue with HTC appears to be a common one. I haven't come across a good workaround in a little bit of research. You might be able to use the MediaRecorder class, though I don't know if its setMaxDuration() method will have the same problem or not: http://developer.android.com/guide/topics/media/camera.html#capture-video
Another not-great workaround is to message the user to record less than 10 seconds and then check the file size once the video is recorded. You could reuse the code we have to check the file size when picking a video from the Gallery.
This could should work on the Galaxy Nexus, though. Do you get any error messages when trying to record video on the Nexus?
MUZ140265 Blessing Kabasa
4,996 PointsMy video recording limit is also not working. I am using a sony xperia v. it is recording upto 20 sec even if i change from 10s to 5s in the code
Travis Avey
18,876 PointsTravis Avey
18,876 PointsI know this is a year old, but I wanted to say that I am having the same issues my Galaxy Nexus (running Cyanogen mod11).
But I did get it to record by setting the quality to high:
takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
It didn't record if I set it to the lowest setting.
I am going to try the MediaRecorder class and see what happens