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

Video player, audio track doesn't stop[BUG] #752

Closed
yeras-is opened this issue Jul 1, 2021 · 10 comments · Fixed by #622
Closed

Video player, audio track doesn't stop[BUG] #752

yeras-is opened this issue Jul 1, 2021 · 10 comments · Fixed by #622
Labels
bug Something isn't working

Comments

@yeras-is
Copy link

yeras-is commented Jul 1, 2021

Describe the bug:
playback of video/audio doesn't stop when widget disposed

Example
https://github.com/yeras-is/video_error

Expected behavior:
playback stop when widget dispose

Device details and Flutter/Dart/flutter_html versions:
flutter_html - 2.1.0
devices= [ android emulator, Samsung A80, iOS simulator, Iphone 11 ]

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, 2.3.0-12.1.pre, on Microsoft Windows [Version 10.0.19041.1052], locale ru-KZ)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.2)
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
[√] VS Code (version 1.56.2)
[√] Connected device (4 available)

• No issues found!

Used HTML

  <!DOCTYPE html>
   <html lang="en">
   <link rel="stylesheet" href="https://cdn.plyr.io/3.6.8/plyr.css"/>
   <body>
   <video id="player" controls>
   <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4" type="video/mp4" size="576"/>
   </video>
   <script src="https://cdn.plyr.io/3.6.8/plyr.polyfilled.js"></script>
   <script>const player = new Plyr('#player');</script>
   </body>
   </html>
@yeras-is yeras-is added the bug Something isn't working label Jul 1, 2021
@tneotia
Copy link
Collaborator

tneotia commented Jul 2, 2021

Duplicate of #610. We do have a PR for this but we are hesitant to merge that because we would like to handle disposing the controllers on our own without needing a dispose method

@Crzech
Copy link

Crzech commented Jul 20, 2021

Hello @tneotia, is there any workaround to fix this? or how can we handle disposing on our own?

@tneotia
Copy link
Collaborator

tneotia commented Jul 20, 2021

The only current solution is to make a git dependency on my PR (#622) using the branch name and my fork URL. However it currently isn't merged with the latest changes so you will be missing out on some bug fixes or features.

When you get the pubspec configured then you can do:

  late final Html htmlWidget;
  final String htmlData = '<p>html data</p>';
  //dispose is especially important when using <video> or <audio> in your HTML code
  @override
  void dispose() {
    htmlWidget.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text('flutter_html Usage'),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
        child: htmlWidget = Html(
          data: htmlData, //required
          //other parameters here
        ),
      ),
    );
  }

to properly dispose audio.

@Crzech
Copy link

Crzech commented Jul 20, 2021

Nice, thanks for your help @tneotia

@tneotia
Copy link
Collaborator

tneotia commented Jul 20, 2021

No problem, if you do try it out please let me know if it actually works because I wasn't able to reproduce the issue.

@moaiedi
Copy link

moaiedi commented Aug 10, 2021

The only current solution is to make a git dependency on my PR (#622) using the branch name and my fork URL. However it currently isn't merged with the latest changes so you will be missing out on some bug fixes or features.

When you get the pubspec configured then you can do:

  late final Html htmlWidget;
  final String htmlData = '<p>html data</p>';
  //dispose is especially important when using <video> or <audio> in your HTML code
  @override
  void dispose() {
    htmlWidget.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text('flutter_html Usage'),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
        child: htmlWidget = Html(
          data: htmlData, //required
          //other parameters here
        ),
      ),
    );
  }

to properly dispose audio.
@tneotia
hi dear friend im try code but error
Dart: Unexpected text 'late'
and The method 'dispose' isn't defined for the type 'Html'.
how can we handle disposing on our own?
please help me.

@erickok erickok mentioned this issue Aug 19, 2021
@18518278831
Copy link

The method 'dispose' isn't defined for the type 'Html'. (Documentation)Try correcting the name to the name of an existing method, or definingsmethod named 'dispose'.

@18518278831
Copy link

Nice, thanks for your help @tneotia

您好,您解决了吗?我这里发生意外.

@18518278831
Copy link

我不清楚我这次请教会不会有回答,请与我联系,谢谢大佬。

@erickok
Copy link
Collaborator

erickok commented Aug 20, 2021

Yes, the fix from #622 is not yet merged due to being a public API change. As stated before, you may use the specific branch/commit if you really need it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants