Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compress more than one video, getting error #26

Closed
PavieOlivier opened this issue Jun 24, 2020 · 5 comments
Closed

Cannot compress more than one video, getting error #26

PavieOlivier opened this issue Jun 24, 2020 · 5 comments

Comments

@PavieOlivier
Copy link

PavieOlivier commented Jun 24, 2020

I cannot compress more videos after compressing the 1st one I get that error

Bad state: Stream has already been listened to.

This happens whenever I go back to a page inside the ''initState'' method

@syahrizalakbar
Copy link

i have the same too although i have unsubscribed in dispose method

@syahrizalakbar
Copy link

i think that because this is using Singleton, and after unsubscribe Stream, you cannot reinitialize the stream, the solution is you can reset compressProgress$ with this code in initState

VideoCompress.compressProgress$ = ObservableBuilder();

@yanivshaked
Copy link
Contributor

Or you can wrap VideoCompress.compressProgress$ with StreamController that supports multiple subscriptions:

static StreamController<double> _progressStreamController = StreamController<double>();
static Stream<double> progressStream = _progressStreamController.stream.asBroadcastStream();
.
.
.
VideoCompress.compressProgress$.subscribe((value) {
  _progressStreamController.sink.add(value / 100);
});

and register the stream in your widget:

  @override
  void initState() {
    super.initState();
    if (widget.progressStream != null) {
      _progressSusbscription = widget.progressStream.listen((p) {
        setState(() {
          _progress = p;
        });
      });
    }
  }

@jonataslaw
Copy link
Owner

Fix um last version

@ribesh-code
Copy link

Video compress: 3.1.0

[✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-arm, locale
en-NP)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.67.2)

I am still facing the issue where multiple video cannot be compressed. any possible solutions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants