Comments (4)
Oh, got it! I don't see any issue with making this change.
I'll create a new release as soon as possible with this update. If you'd like, please feel free to open the pull request
And thanks for opening the issue!
from camposer.
Perfect, thanks for your response @ujizin! I'm shamelessly going to use this thread to ask you a question that's not related to this issue. Do you know if you can use cameraX in a foreground service? :D I couldn't find anything about it on the internet and my attempts all failed. Since you seem to know a lot about cameraX, I was wondering if you know whether that is even possible :D
from camposer.
To be honest, I've never seen it, but this discussion might be useful for you: https://groups.google.com/a/android.com/g/camerax-developers/c/CqPqokS4Lkk
I'll try to create a sample later. If I succeed, I'll send it to you.
ps: and don't worry about using this thread to ask questions โ it's related to the topic of this thread too ๐
from camposer.
That was quick, thank you very much!
Regarding CameraX in Foreground Services, it seems as if that is really not possible as camerax needs to run on the main thread, I tried running this service:
@ExperimentalVideo class VideoRecorderService: LifecycleService() {
lateinit var cameraController: LifecycleCameraController
private var job = SupervisorJob()
private var scope = CoroutineScope(Dispatchers.IO + job)
override fun onCreate() {
super.onCreate()
scope.launch {
cameraController = LifecycleCameraController(this@VideoRecorderService)
// Hack to make sure camera is initialized
delay(2000L)
startRecording()
}
}
fun startRecording() {
cameraController.startRecording(
OutputFileOptions.builder(
File(externalCacheDir!!.absolutePath + "/video.mp4"),
).build(),
ContextCompat.getMainExecutor(this),
object: OnVideoSavedCallback {
override fun onVideoSaved(outputFileResults: OutputFileResults) {
println("Video saved")
}
override fun onError(videoCaptureError: Int, message: String, cause: Throwable?) {
println("Video error")
}
}
)
}
}
but this results in the following error:
java.lang.IllegalStateException: Not in application's main thread
I guess I'll stick to Camera2 :/
from camposer.
Related Issues (20)
- ByteArray as return on ImageCaptureResult HOT 4
- API 21: support HOT 4
- Add support for Audio config HOT 1
- Documentation example raise type mismatch HOT 1
- Aspect Ratio support. HOT 2
- Image rotation issue HOT 5
- Update CameraX to 1.2.2 HOT 5
- Add support for UVC Camera HOT 4
- Provide way to access underlying CameraController HOT 1
- add control the exposure๏ผ HOT 2
- Add focus mode adjustment and exposure support HOT 1
- Aspect Ratio support. HOT 1
- Add takePicture with ImageCapture and update camera to 1.3 HOT 2
- Can't change alpha on `CameraPreview` HOT 3
- Allow VideoCapture to be used with Image Analysis.
- Still can't figure out how to change aspect ratio! HOT 1
- Help how to add a semi-transparent layer used to crop image? HOT 2
- Enabled use case problem HOT 7
- CameraPreview extends over parent size on API level 24 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camposer.