The recorded video will store in /sdcard/Pictures/MyCameraApp/*.mp4
- Support Start/Stop button.
- Support choosing front or back camera for recording.
License: MIT License
Sample of using Android camera in service.
License: MIT License
The recorded video will store in /sdcard/Pictures/MyCameraApp/*.mp4
License: MIT License
Your code does not include a license, can this codebase be used?
I want to turn off the sound of pressing the record button. When you press the button, the sound "beep" occurs. How to turn off this sound?
If in the class CameraService.java remove mMediaRecorder.setAudioSource (MediaRecorder.AudioSource.MIC) then an error occurs!
FATAL EXCEPTION: main
Process: example.chatea.servicecamera, PID: 15568 java.lang.RuntimeException: Unable to start service example.chatea.servicecamera.CameraService@e8912c4 with null: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Intent.getIntExtra(java.lang.String, int)' on a null object reference
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3057)
at android.app.ActivityThread.access$2200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1467)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5546)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Intent.getIntExtra(java.lang.String, int)' on a null object reference
at example.chatea.servicecamera.CameraService.onStartCommand(CameraService.java:89)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3040)
at android.app.ActivityThread.access$2200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1467)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5546)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
After selecting the front camera, recording is performed by the Back camera:
mMediaRecorder.setProfile(CamcorderProfile.get(findFrontFacingCamera(),CamcorderProfile.QUALITY_LOW));
private int findFrontFacingCamera() {
int cameraId = -1;
// Search for the front facing camera
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
Log.d(TAG, "Camera found");
cameraId = i;
break;
}
}
return cameraId;
}
What am I doing wrong?Help me please
In MainActivityJava
lines 38,39,80
change 'front' to 'back'
I just change 2 Lines of the project to switch to the front camera but it failed. Under the path it generate a MP4 file, but my cell phone failed to open it. (real device debugging)
Thanks for the code, but I am wondering what if the service needs to be a remote service witch runs in another process? Can camera open and running works in this remote service?
Can I ask for help?
mCamera.setPreviewCallback
-> @override onPreviewFrame()
function.@override onPreviewFrame()
function seem never work.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.