jonataslaw / jonataslaw/VideoCompress
Use of compute function with package
- Dominant language
- Swift
- Stars
- 262
- Forks
- 344
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to send the work of compiling the video to a separate thread so there won't be a noticeable drop in frames when compressing the video. When I compressed the video on the main thread, there is a drop in frames while the video is compressing (understandably).
I'm using the `compute` function to spin up an isolate and handle the task on a seperate thread.
```dart
Future compress(String path) async {
var media = await compute(VideoCompress.compressVideo, path);
return media;
}
```
However, when it tries to compress the video, I get the following error message and don't recieve an output for the compression.
```
flutter: VideoCompress: You can try to subscribe to the
flutter: compressProgress$ stream to know the compressing state.
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: Binding has not yet been initialized.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding.
```
I have already added the line `WidgetsFlutterBinding.ensureInitialized();` to my `main.dart` file before running `runApp(...)`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.