Skip to content

Commit 0f1c4bf

Browse files
committed
1 parent 8137d3e commit 0f1c4bf

7 files changed

Lines changed: 20 additions & 115 deletions

File tree

.github/AAR Source (Android)/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@
1313
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
1414
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="replace" />
1515
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
16-
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" tools:node="replace" />
17-
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" tools:node="replace" />
1816
</manifest>

.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCamera.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,6 @@ public static int CheckPermission( Context context, final boolean isPicturePermi
9191
if( context.checkSelfPermission( Manifest.permission.READ_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED )
9292
return 0;
9393
}
94-
else if( Build.VERSION.SDK_INT < 34 && context.checkSelfPermission( isPicturePermission ? "android.permission.READ_MEDIA_IMAGES" : "android.permission.READ_MEDIA_VIDEO" ) != PackageManager.PERMISSION_GRANTED )
95-
{
96-
// On Android 14+ (34), partial media access permission is introduced which we want to avoid in a camera app (it'd be confusing for the end user):
97-
// https://developer.android.com/about/versions/14/changes/partial-photo-video-access
98-
// We're hoping that by now, the native camera apps have become smart enough to avoid saving the captured media to Gallery.
99-
return 0;
100-
}
10194
}
10295

10396
// If CAMERA permission is declared, we must request it: https://developer.android.com/reference/android/provider/MediaStore#ACTION_IMAGE_CAPTURE

.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCameraPermissionFragment.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public void onCreate( Bundle savedInstanceState )
6767

6868
if( Build.VERSION.SDK_INT < 33 || getActivity().getApplicationInfo().targetSdkVersion < 33 )
6969
permissions.add( Manifest.permission.READ_EXTERNAL_STORAGE );
70-
else if( Build.VERSION.SDK_INT < 34 )
71-
permissions.add( getArguments().getBoolean( PICTURE_PERMISSION_ID ) ? "android.permission.READ_MEDIA_IMAGES" : "android.permission.READ_MEDIA_VIDEO" );
7270

7371
if( permissions.size() > 0 )
7472
{

.github/AAR Source (Android)/java/com/yasirkula/unity/NativeCameraUtils.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,13 @@ public static String GetVideoProperties( Context context, final String path )
756756
}
757757
finally
758758
{
759-
metadataRetriever.release();
759+
try
760+
{
761+
metadataRetriever.release();
762+
}
763+
catch( Exception e )
764+
{
765+
}
760766
}
761767
}
762768

@@ -824,7 +830,13 @@ public static String GetVideoThumbnail( Context context, final String path, fina
824830
}
825831
finally
826832
{
827-
metadataRetriever.release();
833+
try
834+
{
835+
metadataRetriever.release();
836+
}
837+
catch( Exception e )
838+
{
839+
}
828840
}
829841
}
830842

-135 Bytes
Binary file not shown.

Plugins/NativeCamera/README.txt

Lines changed: 5 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,6 @@
1-
= Native Camera for Android & iOS (v1.4.0) =
1+
= Native Camera for Android & iOS (v1.4.1) =
22

3-
Online documentation & example code available at: https://github.com/yasirkula/UnityNativeCamera
4-
E-mail: yasirkula@gmail.com
5-
6-
7-
1. ABOUT
8-
This plugin helps you take pictures/record videos natively with your device's camera on Android & iOS.
9-
10-
11-
2. HOW TO
12-
NativeCamera no longer requires any manual setup on Android. If you were using an older version of the plugin, you need to remove NativeCamera's "<provider ... />" from your AndroidManifest.xml.
13-
14-
For reference, the legacy documentation is available at: https://github.com/yasirkula/UnityNativeCamera/wiki/Manual-Setup-for-Android
15-
16-
2.2. iOS Setup
17-
There are two ways to set up the plugin on iOS:
18-
19-
2.2.a. Automated Setup for iOS
20-
- (optional) change the values of 'Camera Usage Description' and 'Microphone Usage Description' at 'Project Settings/yasirkula/Native Camera'
21-
22-
2.2.b. Manual Setup for iOS
23-
- set the value of 'Automated Setup' to false at 'Project Settings/yasirkula/Native Camera'
24-
- build your project
25-
- enter a Camera Usage Description to Info.plist in Xcode
26-
- insert "-framework MobileCoreServices -framework ImageIO" to the "Other Linker Flags" of Unity-iPhone Target (and UnityFramework Target on Unity 2019.3 or newer)
27-
28-
29-
3. FAQ
30-
- Can't use the camera, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.NativeCamera" in Logcat
31-
If you are sure that your plugin is up-to-date, then enable "Custom Proguard File" option from Player Settings and add the following line to that file: -keep class com.yasirkula.unity.* { *; }
32-
33-
34-
4. SCRIPTING API
35-
Please see the online documentation for a more in-depth documentation of the Scripting API: https://github.com/yasirkula/UnityNativeCamera
36-
37-
enum NativeCamera.Permission { Denied = 0, Granted = 1, ShouldAsk = 2 };
38-
enum NativeCamera.Quality { Default = -1, Low = 0, Medium = 1, High = 2 };
39-
enum NativeCamera.ImageOrientation { Unknown = -1, Normal = 0, Rotate90 = 1, Rotate180 = 2, Rotate270 = 3, FlipHorizontal = 4, Transpose = 5, FlipVertical = 6, Transverse = 7 }; // EXIF orientation: http://sylvana.net/jpegcrop/exif_orientation.html (indices are reordered)
40-
41-
delegate void PermissionCallback( NativeCamera.Permission permission );
42-
delegate void CameraCallback( string path );
43-
44-
//// Accessing Camera ////
45-
46-
// This operation is asynchronous! After user takes a picture or cancels the operation, the callback is called (on main thread)
47-
// CameraCallback takes a string parameter which stores the path of the captured image, or null if the operation is canceled
48-
// maxSize: determines the maximum size of the returned image in pixels on iOS. A larger image will be down-scaled for better performance. If untouched, its value will be set to SystemInfo.maxTextureSize. Has no effect on Android
49-
// saveAsJPEG: determines whether the image is saved as JPEG or PNG. Has no effect on Android
50-
// preferredCamera: determines whether the rear camera or the front camera should be opened by default
51-
NativeCamera.Permission NativeCamera.TakePicture( CameraCallback callback, int maxSize = -1, bool saveAsJPEG = true, PreferredCamera preferredCamera = PreferredCamera.Default );
52-
53-
// quality: determines the quality of the recorded video
54-
// maxDuration: determines the maximum duration, in seconds, for the recorded video. If untouched, there will be no limit. Please note that the functionality of this parameter depends on whether the device vendor has added this capability to the camera or not. So, this parameter may not have any effect on some devices
55-
// maxSizeBytes: determines the maximum size, in bytes, for the recorded video. If untouched, there will be no limit. This parameter has no effect on iOS. Please note that the functionality of this parameter depends on whether the device vendor has added this capability to the camera or not. So, this parameter may not have any effect on some devices
56-
NativeCamera.Permission NativeCamera.RecordVideo( CameraCallback callback, Quality quality = Quality.Default, int maxDuration = 0, long maxSizeBytes = 0L, PreferredCamera preferredCamera = PreferredCamera.Default );
57-
58-
bool NativeCamera.DeviceHasCamera(); // returns false if the device doesn't have a camera. In this case, TakePicture and RecordVideo functions will not execute
59-
60-
bool NativeCamera.IsCameraBusy(); // returns true if the camera is currently open. In that case, another TakePicture or RecordVideo request will simply be ignored
61-
62-
63-
//// Runtime Permissions ////
64-
65-
// Accessing camera is only possible when permission state is Permission.Granted. TakePicture and RecordVideo functions request permission internally (and return the result) but you can also check/request the permissions manually
66-
// isPicturePermission: whether we're checking permission to take a picture or record a video. Has no effect on iOS
67-
NativeCamera.Permission NativeCamera.CheckPermission( bool isPicturePermission );
68-
NativeCamera.Permission NativeCamera.RequestPermission( bool isPicturePermission );
69-
70-
// Asynchronous variants of RequestPermission. Unlike RequestPermission, these functions don't freeze the app unnecessarily before the permission dialog is displayed. So it's recommended to call these functions instead
71-
void NativeCamera.RequestPermissionAsync( PermissionCallback callback, PermissionType permissionType, MediaType mediaTypes );
72-
Task<NativeCamera.Permission> NativeCamera.RequestPermissionAsync( PermissionType permissionType, MediaType mediaTypes );
73-
74-
// If permission state is Permission.Denied, user must grant the necessary permission(s) manually from the Settings (Android requires Storage and, if declared in AndroidManifest, Camera permissions; iOS requires Camera permission). These functions help you open the Settings directly from within the app
75-
void NativeCamera.OpenSettings();
76-
bool NativeCamera.CanOpenSettings();
77-
78-
79-
//// Utility Functions ////
80-
81-
// Creates a Texture2D from the specified image file in correct orientation and returns it. Returns null, if something goes wrong
82-
// maxSize: determines the maximum size of the returned Texture2D in pixels. Larger textures will be down-scaled. If untouched, its value will be set to SystemInfo.maxTextureSize. It is recommended to set a proper maxSize for better performance
83-
// markTextureNonReadable: marks the generated texture as non-readable for better memory usage. If you plan to modify the texture later (e.g. GetPixels/SetPixels), set its value to false
84-
// generateMipmaps: determines whether texture should have mipmaps or not
85-
// linearColorSpace: determines whether texture should be in linear color space or sRGB color space
86-
Texture2D NativeCamera.LoadImageAtPath( string imagePath, int maxSize = -1, bool markTextureNonReadable = true, bool generateMipmaps = true, bool linearColorSpace = false );
87-
async Task<Texture2D> NativeCamera.LoadImageAtPathAsync( string imagePath, int maxSize = -1, bool markTextureNonReadable = true, bool generateMipmaps = true, bool linearColorSpace = false );
88-
89-
// Creates a Texture2D thumbnail from a video file and returns it. Returns null, if something goes wrong
90-
// maxSize: determines the maximum size of the returned Texture2D in pixels. Larger thumbnails will be down-scaled. If untouched, its value will be set to SystemInfo.maxTextureSize. It is recommended to set a proper maxSize for better performance
91-
// captureTimeInSeconds: determines the frame of the video that the thumbnail is captured from. If untouched, OS will decide this value
92-
// markTextureNonReadable: see LoadImageAtPath
93-
// generateMipmaps: see LoadImageAtPath
94-
// linearColorSpace: see LoadImageAtPath
95-
Texture2D NativeCamera.GetVideoThumbnail( string videoPath, int maxSize = -1, double captureTimeInSeconds = -1.0, bool markTextureNonReadable = true, bool generateMipmaps = true, bool linearColorSpace = false );
96-
async Task<Texture2D> NativeCamera.GetVideoThumbnailAsync( string videoPath, int maxSize = -1, double captureTimeInSeconds = -1.0, bool markTextureNonReadable = true, bool generateMipmaps = true, bool linearColorSpace = false );
97-
98-
// Returns an ImageProperties instance that holds the width, height and mime type information of an image file without creating a Texture2D object. Mime type will be null, if it can't be determined
99-
NativeCamera.ImageProperties NativeCamera.GetImageProperties( string imagePath );
100-
101-
// Returns a VideoProperties instance that holds the width, height, duration (in milliseconds) and rotation information of a video file. To play a video in correct orientation, you should rotate it by rotation degrees clockwise. For a 90-degree or 270-degree rotated video, values of width and height should be swapped to get the display size of the video
102-
NativeCamera.VideoProperties NativeCamera.GetVideoProperties( string videoPath );
3+
Documentation: https://github.com/yasirkula/UnityNativeCamera
4+
FAQ: https://github.com/yasirkula/UnityNativeCamera#faq
5+
Example code: https://github.com/yasirkula/UnityNativeCamera#example-code
6+
E-mail: yasirkula@gmail.com

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.nativecamera",
33
"displayName": "Native Camera",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"documentationUrl": "https://github.com/yasirkula/UnityNativeCamera",
66
"changelogUrl": "https://github.com/yasirkula/UnityNativeCamera/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityNativeCamera/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)