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

flutter: The controller is not ready for method calls. [BUG] #120

Open
fabiot21 opened this issue Nov 17, 2019 · 34 comments
Open

flutter: The controller is not ready for method calls. [BUG] #120

fabiot21 opened this issue Nov 17, 2019 · 34 comments
Assignees
Labels
bug Something isn't working

Comments

@fabiot21
Copy link

fabiot21 commented Nov 17, 2019

I'm running the example project on iOS 11 Simulator and every time I tap on a video I get this error.

    "<MRMediaRemoteCommandInfo: 0x60000136a2e0 for path <decode: missing data>
    "<MRMediaRemoteCommandInfo: 0x60000136a280, Play, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136a920, EnableLanguageOption, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136a940, ChangePlaybackRateCommand, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136aa60, SkipForward, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136aa80, EndRewind, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136aa40, EndFastForward, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136aaa0, PreviousTrack, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136aac0, Stop, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136aae0, Pause, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136ab00, SeekToPlaybackPosition, enabled = 0, options = (null)>",
    "<MRMediaRemoteCommandInfo: 0x60000136ab20 for path <decode: missing data>
flutter: The controller is not ready for method calls.
flutter: The controller is not ready for method calls.
flutter: The controller is not ready for method calls.
flutter: The controller is not ready for method calls.
flutter: The controller is not ready for method calls.
@fabiot21 fabiot21 added the bug Something isn't working label Nov 17, 2019
@sarbagyastha
Copy link
Owner

@fabiot21 Was the issue present in v6.0.3+1 ?

@fabiot21
Copy link
Author

@sarbagyastha I tried older versions and I'm having the same problem.

@sarbagyastha
Copy link
Owner

@fabiot21 Did you check by removing constraint version? like: youtube_player_flutter: 6.0.3+1 without any caret.

@fabiot21
Copy link
Author

@sarbagyastha yes :(

@sarbagyastha
Copy link
Owner

@fabiot21 Please try on real device too. Sometimes simulators maynot support playback or might freeze as platform-views a expensive.

@saitbnzl
Copy link

saitbnzl commented Nov 25, 2019

@sarbagyastha  I've seen this in real device too. It happens very often although it looks a bit random. Sometimes it disappears after a few try, sometimes not.

Tested with v6.0.3+2 on Android 9 both in release mode and debug mode.

@saitbnzl
Copy link

saitbnzl commented Dec 5, 2019

@sarbagyastha Do you have any aditional info about this? I see this issue randomly in both production&debug(see my comment above). I can try to help if you don't have time.

@ilyasKerbal
Copy link

I confirm the bug on Android.

I/flutter ( 5922): The controller is not ready for method calls.
D/eglCodecCommon( 5922): setVertexArrayObject: set vao to 1 (1) 0 0
I/flutter ( 5922): The controller is not ready for method calls.

@sgehrman
Copy link
Contributor

I just started seeing this on Android simulator.

@Alwin-Lazar
Copy link

I Confirm, this bug is still exist

@AbdullahAli1993
Copy link

I also have the same bug on android.

@victormanuelfrancodev
Copy link

I have the same error , I am seeing that it is when the video does not finish loading, I will try to solve it and send my answer.

@kalismeras61
Copy link

Same problem.

@sarbagyastha
Copy link
Owner

Sorry for the late response, was on a tight schedule. Will be working on the issue within this week.

@sfratini
Copy link

I am getting this stacktrace as well: flutter/flutter#25714

@LeeLoHoon
Copy link

LeeLoHoon commented Jan 13, 2020

I had same issue. and I solved this problem like this.

In YoutubePlayerController Class,
Add reload() in _callMethod.

_callMethod(String methodString) {
if (value.isReady) {
value.webViewController?.evaluateJavascript(methodString);
} else {
reload();
print("#######################");
print('The controller is not ready for method calls.');
}
}

@royycc
Copy link

royycc commented Jan 13, 2020

One observation is:
When the "autoPlay" flag is on, even after the video starts playing, the "isReady" is still false.
So after that, calling the callMethod afterwards, it return error:

_callMethod(String methodString) {
if (value.isReady) {
value.webViewController?.evaluateJavascript(methodString);
} else {
print('The controller is not ready for method calls [$methodString].');
}
}

@LeeLoHoon
Copy link

@royycc
Oh, i didn't check about auto play. But my solution works if you don't use auto play. :)

@ipolx
Copy link

ipolx commented Jan 15, 2020

I had same issue. and I solved this problem like this.

In YoutubePlayerController Class,
Add reload() in _callMethod.

_callMethod(String methodString) {
if (value.isReady) {
value.webViewController?.evaluateJavascript(methodString);
} else {
reload();
print("#######################");
print('The controller is not ready for method calls.');
}
}
hello, i tried your solution, but it's not working. Same error

@LeeLoHoon
Copy link

LeeLoHoon commented Jan 15, 2020

@ipolx
Hi, Could you show me the log of error?
I mean, when you clicked button, did you see the log of reloading?

@ipolx
Copy link

ipolx commented Jan 16, 2020

@ipolx
Hi, Could you show me the log of error?
I mean, when you clicked button, did you see the log of reloading?

Somehow, i managed this error. I think it was flutter version issue. Works very good !

@LeeLoHoon
Copy link

@ipolx
Nice, My pleasure :)

@saveliy-kremen
Copy link

Some devices do not yet know what arrow functions are. You need to replace the code in row_youtube_player.dart:

events: {
onReady: (event) => Ready.postMessage("Ready"),
onStateChange: (event) => sendPlayerStateChange(event.data),
onPlaybackQualityChange: (event) => PlaybackQualityChange.postMessage(event.data),
onPlaybackRateChange: (event) => PlaybackRateChange.postMessage(event.data),
onError: (error) => Errors.postMessage(error.data)
},

with

events: {
onReady: function(event) {Ready.postMessage("Ready")},
onStateChange: function(event) {sendPlayerStateChange(event.data)},
onPlaybackQualityChange: function(event) {PlaybackQualityChange.postMessage(event.data)},
onPlaybackRateChange: function(event) {PlaybackRateChange.postMessage(event.data)},
onError: function(error) {Errors.postMessage(error.data)}
},

@wagwanapps2014
Copy link

I fixed the issue by changing the following method in RawYoutubePlayer by adding the else part to automatically reload if needed

onPageFinished: (_) {
if (_isPlayerReady) {
controller.updateValue(
controller.value.copyWith(isReady: true),
);
}else{
print("reloading video");
controller.reload();
}
},

@leovar
Copy link

leovar commented Feb 3, 2020

Update flutter to the latest version and problem solved

pavlosgi added a commit to pavlosgi/youtube_player_flutter that referenced this issue Feb 20, 2020
pavlosgi added a commit to pavlosgi/youtube_player_flutter that referenced this issue Feb 20, 2020
pavlosgi added a commit to pavlosgi/youtube_player_flutter that referenced this issue Feb 20, 2020
@kalismeras61
Copy link

Update flutter to the latest version and problem solved

Latest stable?

@madhu-1stmain
Copy link

Tried the latest version, but not working

@rdcoder33
Copy link

Getting the same error with latest version

@vinothvino42
Copy link

I'm also getting the same exception. I'm using it for my production app.

@dipen-apptrait
Copy link

it's working in an ios simulator with the latest version of
youtube_player_flutter: ^8.0.0
flutter_inappwebview: ^5.3.2
and set deployment target 12.1 in Xcode.

@pavannx
Copy link

pavannx commented Nov 30, 2021

I've got the same error here

tried everything but found no solution, the thumb shows up but the video does not start

using the latest version of flutter and YouTube_player_flutter

@31Carlton7
Copy link

I was getting this error because autoplay was set to true. However when I added the onReady with an empty function, it solved my problem.

@marcio-wedoc
Copy link

marcio-wedoc commented Mar 17, 2023

SORTED OUT

My scenario is that I have a feed and I need autoplay when it appears on the screen, when I pressed play on the widget and it had just appeared on the screen, it sent this error "The controller is not ready for method calls." I solved it by initializing it with autoPlay = true and if the video was paused watching the first play, I would pause it immediately. So I check if the video has already been loaded.

@Amodh2022
Copy link

Im getting this error after making autoplay false

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

No branches or pull requests