youtube_player_flutter icon indicating copy to clipboard operation
youtube_player_flutter copied to clipboard

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

Open fabiot21 opened this issue 4 years ago • 34 comments

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 avatar Nov 17 '19 11:11 fabiot21

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

sarbagyastha avatar Nov 17 '19 11:11 sarbagyastha

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

fabiot21 avatar Nov 17 '19 11:11 fabiot21

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

sarbagyastha avatar Nov 17 '19 12:11 sarbagyastha

@sarbagyastha yes :(

fabiot21 avatar Nov 17 '19 12:11 fabiot21

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

sarbagyastha avatar Nov 18 '19 04:11 sarbagyastha

@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 avatar Nov 25 '19 00:11 saitbnzl

@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.

saitbnzl avatar Dec 05 '19 19:12 saitbnzl

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.

ilyasKerbal avatar Dec 11 '19 08:12 ilyasKerbal

I just started seeing this on Android simulator.

sgehrman avatar Dec 19 '19 11:12 sgehrman

I Confirm, this bug is still exist

Alwin-Lazar avatar Dec 20 '19 11:12 Alwin-Lazar

I also have the same bug on android.

AbdullahAli1993 avatar Dec 23 '19 08:12 AbdullahAli1993

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.

victormanuelfrancodev avatar Dec 26 '19 03:12 victormanuelfrancodev

Same problem.

kalismeras61 avatar Dec 30 '19 12:12 kalismeras61

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

sarbagyastha avatar Dec 30 '19 12:12 sarbagyastha

I am getting this stacktrace as well: https://github.com/flutter/flutter/issues/25714

sfratini avatar Dec 31 '19 15:12 sfratini

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.'); } }

LeeLoHoon avatar Jan 13 '20 13:01 LeeLoHoon

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].'); } }

royycc avatar Jan 13 '20 19:01 royycc

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

LeeLoHoon avatar Jan 14 '20 04:01 LeeLoHoon

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

ipolx avatar Jan 15 '20 13:01 ipolx

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

LeeLoHoon avatar Jan 15 '20 13:01 LeeLoHoon

@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 !

ipolx avatar Jan 16 '20 15:01 ipolx

@ipolx Nice, My pleasure :)

LeeLoHoon avatar Jan 17 '20 04:01 LeeLoHoon

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)} },

saveliy-kremen avatar Jan 28 '20 11:01 saveliy-kremen

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(); } },

wagwanapps2014 avatar Jan 31 '20 23:01 wagwanapps2014

Update flutter to the latest version and problem solved

leovar avatar Feb 03 '20 22:02 leovar

Update flutter to the latest version and problem solved

Latest stable?

kalismeras61 avatar Feb 20 '20 17:02 kalismeras61

Tried the latest version, but not working

madhu-1stmain avatar Feb 25 '20 04:02 madhu-1stmain

Getting the same error with latest version

rdcoder33 avatar Jun 23 '20 04:06 rdcoder33

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

vinothvino42 avatar Sep 15 '20 11:09 vinothvino42

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.

dipen-apptrait avatar May 14 '21 13:05 dipen-apptrait