sarbagyastha / youtube_player_flutter

A Flutter plugin for inline playback or streaming of YouTube videos using the official iFrame Player API.
https://youtube.sarbagyastha.com.np
BSD 3-Clause "New" or "Revised" License
704 stars 811 forks source link

On Dispose session seems to be active when user try to play new video get error. #300

Open akshayru opened 4 years ago

akshayru commented 4 years ago

Describe the bug On Dispose session seems to be active when user try to play new video get error.

To Reproduce Steps to reproduce the behavior: 1 - Call API from different page by passing youtube id 2 - Hit go back to go to youtube playlist and choose different id. 3 - After coming back to play screen it throws below error.

Error: Bad state: Cannot add new events after calling close at Object.throw_ [as throw] (http://localhost:60937/dart_sdk.js:4463:11) at _AsyncBroadcastStreamController.new.add (http://localhost:60937/dart_sdk.js:31128:55) at controller.YoutubePlayerController.new.add (http://localhost:60937/packages/youtube_player_iframe/src/helpers/youtube_value_builder.dart.lib.js:827:32) at http://localhost:60937/packages/youtube_player_iframe/src/helpers/youtube_value_builder.dart.lib.js:426:31 at Object._checkAndCall (http://localhost:60937/dart_sdk.js:4673:16) at Object.dcall (http://localhost:60937/dart_sdk.js:4678:17)

Expected behavior Dispose should clear session.

Screenshots If applicable, add screenshots to help explain your problem.

Technical Details:

Additional context Video still plays but it keeps login error..

nstrelow commented 4 years ago

I have the same problem. Could this be solved using YoutubePlayerControllerProvider?

Using one controller for all the widgets and never closing it?

nstrelow commented 4 years ago

Anything new on this?

nstrelow commented 4 years ago

@sarbagyastha Did you have a chance to look into this?

Let me know how I could help.

sarbagyastha commented 4 years ago

@nstrelow Isn't this fixed with the new update ?

dheerajsarwaiya commented 4 years ago

no. same problem on web with 1.1.0 update as well.

View the page with youtube link, then go back and come back or go to next youtube page.

Error: Bad state: Cannot add new events after calling close
    at Object.throw_ [as throw] (http://localhost:45583/dart_sdk.js:4322:11)
    at _AsyncBroadcastStreamController.new.add (http://localhost:45583/dart_sdk.js:31061:55)
    at controller.YoutubePlayerController.new.add (http://localhost:45583/packages/youtube_player_iframe/src/helpers/youtube_value_builder.dart.lib.js:820:32)
    at http://localhost:45583/packages/youtube_player_iframe/src/helpers/youtube_value_builder.dart.lib.js:423:29
    at Object._checkAndCall (http://localhost:45583/dart_sdk.js:4532:16)
    at Object.dcall (http://localhost:45583/dart_sdk.js:4537:17)
    at http://localhost:45583/dart_sdk.js:104668:21
markgrancapal commented 4 years ago

I also have this issue.

beingsalmanshaikh commented 2 years ago

Any update on this? I am using multiple youtube videos on a single page and I don't know after updating the package from 1.1.0 to 2.2.2, it started giving the mentioned error.

Bad state: Cannot add new events after calling close
    at Object.throw_ [as throw] (http://0.0.0.0:55556/dart_sdk.js:5391:11)
    at _AsyncBroadcastStreamController.new.add (http://0.0.0.0:55556/dart_sdk.js:36356:55)
    at controller.YoutubePlayerController.new.add (http://0.0.0.0:55556/packages/youtube_player_iframe/src/helpers/youtube_value_builder.dart.lib.js:1039:33)
    at http://0.0.0.0:55556/packages/youtube_player_iframe/src/helpers/youtube_value_builder.dart.lib.js:541:33
    at Object._checkAndCall (http://0.0.0.0:55556/dart_sdk.js:5603:16)
    at Object.dcall (http://0.0.0.0:55556/dart_sdk.js:5608:17)
    at http://0.0.0.0:55556/dart_sdk.js:115918:21

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.65.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
Danielelkhal commented 2 years ago

Has there been a solution to this issue? I'm having the same problem!

sarbagyastha commented 2 years ago

@Danielelkhal Which version are you using ?

Danielelkhal commented 2 years ago

Version 3.0.3

sarbagyastha commented 2 years ago

@Danielelkhal Can you provide a reproducible code ?