@ayden-fc2/riffle-bridge-web 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +15 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -160,6 +160,7 @@ const tilt = bridge.utils.getTiltDirection(x, y);
160
160
  ```
161
161
 
162
162
  ### 3.3 音频模块(录音、播放)
163
+ > 特别注意拿到的uri文件资源是webview外的native文件路径,当前webview无法直接播放音频,请参考录音模块代码,先调用readAsBase64转码再播放!
163
164
 
164
165
  **播放模块:**
165
166
 
@@ -210,12 +211,23 @@ if (result?.uri) {
210
211
  await bridge.fileStorage.addCustomFileMapping('local://recording/aydens-voice', result.uri);
211
212
  }
212
213
 
213
- // 后续直接播放
214
+ // 1. 后续让native层播放
214
215
  await bridge.audio.playOnline({ uri: 'local://recording/aydens-voice' });
216
+
217
+ // 2. 后续直接让web播放
218
+ const audioData = await bridge.fileStorage.readAsBase64(result.uri);
219
+ const audio = new Audio(audioData.dataUrl); // dataUrl 已是完整 'data:audio/mp4;base64,...'
220
+ audio.play();
221
+
222
+ // 或使用 React 方式
223
+ <audio src={audioData.dataUrl} controls />
224
+
215
225
  ```
216
226
 
217
227
  ### 3.4 相机模块(实时相机、拍照、相册、闪光灯)
218
228
 
229
+ >> 特别注意拿到的uri文件资源是webview外的native文件路径,当前webview无法直接渲染,请参考下方**拍照/相册**的代码,先调用readAsBase64转码再渲染!
230
+
219
231
  **实时相机**
220
232
 
221
233
  相机采用「透明 WebView + 原生相机层」实现,**打开相机时必须设置web应用背景透明**。
@@ -229,7 +241,7 @@ document.body.style.background = 'transparent';
229
241
  document.documentElement.style.background = 'transparent';
230
242
  document.getElementById('root')!.style.background = 'transparent';
231
243
 
232
- // 拍照
244
+ // 拍照 ⚠️ 拍照后不要直接渲染,参考下方**拍照/相册**的代码,先调用readAsBase64转码再渲染!
233
245
  const photo = await bridge.camera.takePhoto();
234
246
 
235
247
  // 切换摄像头
@@ -300,6 +312,7 @@ const base64 = await bridge.fileStorage.readAsBase64('local://photos/aydens-demo
300
312
  当应用需要闪光灯而不要实时相机时,可以使用非透明web应用背景来遮挡实时相机
301
313
 
302
314
  ### 3.5 文件存储模块
315
+ >> 特别注意拿到的uri文件资源是webview外的native文件路径,当前webview无法直接渲染图片或播放音频,请参考下方代码,先调用readAsBase64转码再渲染或播放!相机&录音等模块也都有联动说明
303
316
 
304
317
  文件映射系统维护了一个MAP映射表,支持本地文件和网络资源两种存储,web应用要根据需求选择使用哪种
305
318
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayden-fc2/riffle-bridge-web",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Riffle Bridge Web SDK - WebView 与 Native 通信桥接库",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",