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
694 stars 788 forks source link

[BUG] Unhandled Exception: PlatformException(NullPointerException, java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.evaluateJavascript(java.lang.String, android.webkit.ValueCallback)' on a null object reference, Cause: null, Stacktrace: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.evaluateJavascript(java.lang.String, android.webkit.ValueCallback)' on a null object reference #765

Open AbdurRehman-coder opened 1 year ago

AbdurRehman-coder commented 1 year ago

Describe the bug I'm using the YouTube_player_ifram for playing YouTube videos, It is playing very smoothly, but when I click new video from the list and want to update my whole widget tree because I want to update the index number of that new playing video, so it through the above exception.

Technical Details:

Error Log [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(NullPointerException, java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.evaluateJavascript(java.lang.String, android.webkit.ValueCallback)' on a null object reference, Cause: null, Stacktrace: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.evaluateJavascript(java.lang.String, android.webkit.ValueCallback)' on a null object reference E/flutter (13513): at io.flutter.plugins.webviewflutter.WebViewHostApiImpl.evaluateJavascript(WebViewHostApiImpl.java:337) E/flutter (13513): at io.flutter.plugins.webviewflutter.GeneratedAndroidWebView$WebViewHostApi$-CC.lambda$setup$12(GeneratedAndroidWebView.java:1023) E/flutter (13513): at io.flutter.plugins.webviewflutter.GeneratedAndroidWebView$WebViewHostApi$$ExternalSyntheticLambda20.onMessage(Unknown Source:2) E/flutter (13513): at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:217) E/flutter (13513): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter (13513): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) E/flutter (13513): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter (13513): at android.os.Handler.handleCallback(Handler.java:907) E/flutter (13513): at android.os.Handler.dispatchMessage(Handler.java:105) E/flutter (13513): at android.os.Looper.loop(Looper.java:216) E/flutter (13513): at android.app.ActivityThread.main(ActivityThread.java:7625) E/flutter (13513): at java.lang.reflect.Method.invoke(Native Method) E/flutter (13513): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) E/flutter (13513): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) E/flutter (13513): , null) E/flutter (13513): #0 WebViewHostApi.evaluateJavascript (package:webview_flutter_android/src/android_webview.pigeon.dart:608:7) E/flutter (13513): <asynchronous suspension> E/flutter (13513): I/flutter (13513): playing index111 == 3 ,, ,, section: 0 I/flutter (13513): verify id main screen: null I/flutter (13513): sections name: 1 I/flutter (13513): completed skills: 0 I/chatty (13513): uid=10853(com.example.bootstrap_academy) 1.ui identical 1 line I/flutter (13513): completed skills: 0 D/skia (13513): --- Failed to create image decoder with message 'unimplemented' D/skia (13513): --- Failed to create image decoder with message 'unimplemented' D/skia (13513): --- Failed to create image decoder with message 'unimplemented'

@sarbagyastha

AbdurRehman-coder commented 1 year ago

Error Log [INFO:CONSOLE(1116)] "Unrecognized feature: 'picture-in-picture'.", source: https://www.youtube.com/s/player/e5f6cbd5/www-widgetapi.vflset/www-widgetapi.js (1116) [INFO:CONSOLE(1116)] "Unrecognized feature: 'web-share'.", source: https://www.youtube.com/s/player/e5f6cbd5/www-widgetapi.vflset/www-widgetapi.js (1116)`

Also give this error, i don't know where is the problem I also configure the webview_flutter properly, as you mentioned this package using webview_flutter under the Hook.

erdzan12 commented 1 year ago

Check your links provided to the loadVideo Function, as it uses following regex for the url RegExp(r'^https://(?:www\.|m\.)?youtube\.com/watch.*').hasMatch(url)