youtube_player_flutter
youtube_player_flutter copied to clipboard
flutter: The controller is not ready for method calls. [BUG]
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 Was the issue present in v6.0.3+1 ?
@sarbagyastha I tried older versions and I'm having the same problem.
@fabiot21 Did you check by removing constraint version? like: youtube_player_flutter: 6.0.3+1
without any caret.
@sarbagyastha yes :(
@fabiot21 Please try on real device too. Sometimes simulators maynot support playback or might freeze as platform-views a expensive.
@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.
@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.
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.
I just started seeing this on Android simulator.
I Confirm, this bug is still exist
I also have the same bug on android.
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.
Same problem.
Sorry for the late response, was on a tight schedule. Will be working on the issue within this week.
I am getting this stacktrace as well: https://github.com/flutter/flutter/issues/25714
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.'); } }
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 Oh, i didn't check about auto play. But my solution works if you don't use auto play. :)
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 Hi, Could you show me the log of error? I mean, when you clicked button, did you see the log of reloading?
@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 Nice, My pleasure :)
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)} },
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(); } },
Update flutter to the latest version and problem solved
Update flutter to the latest version and problem solved
Latest stable?
Tried the latest version, but not working
Getting the same error with latest version
I'm also getting the same exception. I'm using it for my production app.
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.