react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

Feature | Support onBytesWrittenVideo to receive bytes on JS while recording Video

Open felire opened this issue 6 months ago • 2 comments

What

This PR Adds the onBytesWrittenVideo callback in order to receive the bytes of the video while it is being recorded.

Changes

IOS

  • Implementing DispatchSourceTimer on Ios in order to read the file size from the FileSystem every 400 ms, that will be executed after the video has started and when finished the timer is cleaned.
  • Adding onBytesWrittenVideoEvent as RCTDirectEventBlock in order to send events to JS in RCTViewManager

Android

  • Creating BytesWrittenVideoEvent class
  • Adding onBytesWrittenVideo on the getExportedCustomDirectEventTypeConstants and all the logic to treat that as an Event and send data to JS
  • Send the data directly from VideoRecordEvent.Status as it is available there

TSX/TS

  • Adding types and JS Docs
  • Adding the onBytesWrittenVideo and destructuring the NativeEvent to just expose (bytes: number) => void

Docs

  • Add an example on video page

Tested on

  • iPhone 8
  • Samsung Galaxy S24 FE

Related issues

felire avatar Jun 12 '25 01:06 felire

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 1:23am

vercel[bot] avatar Jun 12 '25 01:06 vercel[bot]

cool!

mrousavy avatar Jun 12 '25 10:06 mrousavy