Closed AlexanderLukashin closed 5 months ago
May I see your code?
Here is the method for processing pressing the start recording button
private void RecordVideo(ClickEvent eventArgs)
{
_ = NativeCamera.RecordVideo(Record);
void Record(string path)
{
AddFiles(_data.TaskMedia, path).Forget();
}
}
Hmm, it looks good to me. We need to figure out whether this is a device-specific issue or Unity version-specific issue. Do you have older Unity versions (2021 or older) that you can test the example code on?
I tried to build in Unity 2021.3.38f, but the path is still returned null. Link to the log file
This bug is also reproduced on the Galaxy tab 8 tablet (Android 14, OneUI 6.0)
I've created the APK inside this zip archive on 2021.3.29f1 using Mono (faster build) and it works well on my Galaxy S8. Could you give it a try? Source code:
NativeCamera.Permission permission = NativeCamera.RecordVideo( ( path ) =>
{
if( path != null )
{
// Play the recorded video
Handheld.PlayFullScreenMovie( "file://" + path );
}
} );
It doesn't work again, here is a link to the archive with videos and logs
Thank you, it's evidently a device-specific issue. I'll investigate it.
There is no such error in the plugin version 1.4.2, maybe it will help somehow
I've been having a busy schedule so I couldn't take a look at it yet.
I've now added a few extra logs to the sections of the code that were added in v1.4.3. Reading those logs could prove useful. Could you replace NativeCamera.aar with the one inside this zip archive and post all logcat logs that have the log tag "Unity"?
PS. The issue doesn't occur on an Android 14 Galaxy S23 device either.
OK I think I figured it out. Thank you for providing the logs. The issue is, the video is saved to path X (that we provide to the camera) but Android wraps that path inside a Uri, let's call it Y. Normally, the native GetPathFromURI function can convert Y to X but for unknown reasons, this failed on your Xiaomi device. The fallback to this scenario is, copying the file from Y to a filepath that we provide (this behaviour was added in v1.4.3). The thing I overlooked is, I was passing back X to that filepath. So, NativeCamera was trying to copy the video from X back to X.
I've resolved this issue in two steps:
Could you give this new aar file a shot and verify that the issue is resolved? I'd also appreciate if you could send the Unity-tagged logs one last time to make sure that nothing goes wrong.
These changes have fixed the bug. Xiaomi-23127PN0CG-Android-14_2024-06-24_110638.zip
After the user finishes recording the video, null is returned instead of the path.