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
690 stars 766 forks source link

[web] player works fine on debug but crashes on deployed site #819

Open aytunch opened 1 year ago

aytunch commented 1 year ago

The moment controller is created, we get an error. In debug mode it works perfectly. Do anyone have any idea? I will supply more crash logs soon..

In debug mode, we get an error but it does not effect the functionality:

Screenshot 2023-05-02 at 19 33 52

In release deployment we get this error the moment controller is created and no player and widget is rendered on screen: NoSuchMethodError: method not found: 'bw8' on null

halfaHalfawy commented 1 year ago

same issue

talhaocakci commented 1 year ago

I solved the problem like this: First, the reason is: WebYoutubePlayerIframePlatform is not loaded via flutter_web_view since following plugin is not loaded in release mode: https://github.com/sarbagyastha/youtube_player_flutter/blob/master/packages/youtube_player_iframe_web/pubspec.yaml#L15

I have initialized the WebViewPlatform.instance in my own widget's initState method of the webview_flutter which is used by youtube player plugin of this repository.

WebViewPlatform.instance = WebYoutubePlayerIframePlatform();

required imports are

 import 'package:webview_flutter_platform_interface/src/webview_platform.dart';
import 'package:youtube_player_iframe_web/src/web_youtube_player_iframe_platform.dart';