rns-mediapicker 0.1.0 โ 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
# ๐ต / ๐ผ๏ธ / ๐ฅ rns-mediapicker
|
|
2
2
|
|
|
3
|
-
A high-performance native media picker for React Native and Expo
|
|
4
|
-
Supports audio, image, and video selection from camera or library
|
|
3
|
+
A **high-performance native media picker** for **React Native** and **Expo**.
|
|
4
|
+
Supports **audio, image, and video** selection from **camera or library**, automatic JPEG compression, EXIF-safe dimensions, and transparent-image flattening.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
## Installation
|
|
8
|
+
## ๐ Installation
|
|
9
9
|
|
|
10
|
+
Choose any method:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
10
13
|
yarn add rns-mediapicker
|
|
11
|
-
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```bash
|
|
12
17
|
npm install rns-mediapicker
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx expo install rns-mediapicker
|
|
22
|
+
```
|
|
13
23
|
|
|
14
24
|
---
|
|
15
25
|
|
|
16
|
-
## Expo Configuration
|
|
26
|
+
## โ๏ธ Expo Configuration
|
|
17
27
|
|
|
18
|
-
Add the plugin to your app.json or app.config.js
|
|
28
|
+
Add the plugin to your `app.json` or `app.config.js`.
|
|
29
|
+
This automatically configures:
|
|
19
30
|
|
|
31
|
+
- iOS permissions (`Info.plist`)
|
|
32
|
+
- Android intent queries
|
|
33
|
+
- Android `FileProvider`
|
|
34
|
+
|
|
35
|
+
```json
|
|
20
36
|
{
|
|
21
37
|
"expo": {
|
|
22
38
|
"plugins": ["rns-mediapicker"]
|
|
23
39
|
}
|
|
24
40
|
}
|
|
41
|
+
```
|
|
25
42
|
|
|
26
43
|
---
|
|
27
44
|
|
|
28
|
-
## Usage
|
|
45
|
+
## ๐งโ๐ป Usage
|
|
29
46
|
|
|
47
|
+
```js
|
|
30
48
|
import MediaPicker from 'rns-mediapicker';
|
|
31
49
|
|
|
32
50
|
const pickMedia = async () => {
|
|
33
51
|
try {
|
|
34
52
|
const result = await MediaPicker.pick(
|
|
35
|
-
false,
|
|
36
|
-
'both',
|
|
37
|
-
'back'
|
|
53
|
+
false, // useCamera: true = camera, false = picker
|
|
54
|
+
'both', // mediaType: 'audio' | 'image' | 'video' | 'both'
|
|
55
|
+
'back' // env: 'front' | 'back' (camera only)
|
|
38
56
|
);
|
|
39
57
|
|
|
40
58
|
console.log('URI:', result.uri);
|
|
@@ -51,46 +69,62 @@ const pickMedia = async () => {
|
|
|
51
69
|
}
|
|
52
70
|
}
|
|
53
71
|
};
|
|
72
|
+
```
|
|
54
73
|
|
|
55
74
|
---
|
|
56
75
|
|
|
57
|
-
## API
|
|
76
|
+
## ๐งฉ API Reference
|
|
58
77
|
|
|
59
|
-
pick(useCamera, mediaType, env)
|
|
78
|
+
### `pick(useCamera, mediaType, env)`
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
| Parameter | Type | Description |
|
|
81
|
+
|-----------|----------|-------------|
|
|
82
|
+
| useCamera | boolean | `true` opens the camera, `false` opens the media picker |
|
|
83
|
+
| mediaType | string | `'audio'`, `'image'`, `'video'`, or `'both'` |
|
|
84
|
+
| env | string | `'front'` or `'back'` camera (camera mode only) |
|
|
64
85
|
|
|
65
86
|
---
|
|
66
87
|
|
|
67
|
-
## Response Object
|
|
88
|
+
## ๐ฆ Response Object
|
|
68
89
|
|
|
90
|
+
```js
|
|
69
91
|
{
|
|
70
|
-
uri: string;
|
|
71
|
-
width: number;
|
|
72
|
-
height: number;
|
|
73
|
-
type: string;
|
|
74
|
-
isVideo: boolean;
|
|
75
|
-
isAudio: boolean;
|
|
92
|
+
uri: string; // Local file URI
|
|
93
|
+
width: number; // Media width (0 for audio)
|
|
94
|
+
height: number; // Media height (0 for audio)
|
|
95
|
+
type: string; // 'image' | 'video' | 'audio'
|
|
96
|
+
isVideo: boolean; // Helper flag
|
|
97
|
+
isAudio: boolean; // Helper flag
|
|
76
98
|
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## โจ Features
|
|
104
|
+
|
|
105
|
+
- ๐ต Audio / ๐ผ๏ธ Image / ๐ฅ Video support
|
|
106
|
+
- ๐ท Camera and ๐ Library selection
|
|
107
|
+
- ๐ฌ Camera video capture (Android & iOS)
|
|
108
|
+
- ๐๏ธ Automatic JPEG compression
|
|
109
|
+
- โฌ White-background flattening for transparent images
|
|
110
|
+
- ๐ EXIF-safe rotation and accurate dimensions
|
|
111
|
+
- ๐ Scoped-storage safe temporary files
|
|
112
|
+
- ๐ค Android 11+ intent queries handled automatically
|
|
113
|
+
- ๐ Android `FileProvider` preconfigured
|
|
114
|
+
- ๐ iOS swipe-to-dismiss cancellation handling
|
|
115
|
+
- ๐งน Clean promise lifecycle (no leaks)
|
|
77
116
|
|
|
78
117
|
---
|
|
79
118
|
|
|
80
|
-
##
|
|
119
|
+
## ๐ Notes
|
|
81
120
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
- White-background flattening
|
|
87
|
-
- EXIF-safe rotation and dimensions
|
|
88
|
-
- Scoped-storage safe temp files
|
|
89
|
-
- Android FileProvider configured
|
|
90
|
-
- iOS swipe-to-dismiss cancellation handling
|
|
121
|
+
- All returned files are copied into the appโs **temporary cache directory**
|
|
122
|
+
- Audio files preserve original encoding
|
|
123
|
+
- Front camera selection is **best-effort** on Android
|
|
124
|
+
- No external native dependencies required
|
|
91
125
|
|
|
92
126
|
---
|
|
93
127
|
|
|
94
|
-
## License
|
|
128
|
+
## ๐ License
|
|
95
129
|
|
|
96
130
|
MIT
|