youtube_player_flutter
youtube_player_flutter copied to clipboard
[BUG] Docs are unclear for youtube_player_iframe - YoutubePlayerIFrame
Describe the bug
The docs don't sufficently cover how to generate a player without Full Screen support and cue a video within said player.
The number of variations I have tried have resulted in no video being cued.
I also don't think that YoutubePlayerControllerProvider
is accepting the controller
being passed to it properly.
I tried passing in a controller with the mute
set to true
and it wasn't muted. So somethings awry
Same, I can't get videos to load or cue on web ('an error occured' in the player frame). If the package is functional, it's not clear to me how to load videos properly. :( :(
I also don't think that YoutubePlayerControllerProvider is accepting the controller being passed to it properly.
@BarryCarlyon YoutubePlayerControllerProvider
is an inherited widget, so make sure that the player is under descendant BuildContext
of the provider.
Same, I can't get videos to load or cue on web ('an error occured' in the player frame).
@CosmicPangolin Can you post how you're doing it currently ?
I have a problem with setting up the player too. In my case I want to have 4 Youtube players on one page. I use a stack to place multiple players. However on each reload a seemingly random selection of the players work, the others give the error message "An error occured. Please try again later". Sometimes it is one video working, sometimes two. Very rarely it has been three videos working. Can it have something to do with loading 4 videos not beeing fast enough?
Here is a portion of my code
`class MainPageState extends State<MainPage> { late final YoutubePlayerController _controllerStream1; late final YoutubePlayerController _controllerStream2; late final YoutubePlayerController _controllerStream3; late final YoutubePlayerController _controllerStream4; bool videoLoaded = true; var result;
@override void initState() { super.initState(); _controllerStream1 = YoutubePlayerController(params: const YoutubePlayerParams(showFullscreenButton: false, showControls: true)) ..onInit = () async { await _controllerStream1.loadVideoById(videoId: _videoIds[0]); }; _controllerStream2 = YoutubePlayerController(params: const YoutubePlayerParams(showFullscreenButton: false, showControls: true)) ..onInit = () async { await _controllerStream2.loadVideoById(videoId: _videoIds[1]); }; _controllerStream3 = YoutubePlayerController(params: const YoutubePlayerParams(showFullscreenButton: false, showControls: true)) ..onInit = () async { await _controllerStream3.loadVideoById(videoId: _videoIds[2]); }; _controllerStream4 = YoutubePlayerController(params: const YoutubePlayerParams(showFullscreenButton: false, showControls: true)) ..onInit = () async { await _controllerStream4.loadVideoById(videoId: _videoIds[3]); }; } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.grey, body: Stack(children: [ Positioned( child: PointerInterceptor( intercepting: false, child: ResizebleWidget( onDrag: (windowIndex, width, height) { setState(() {}); }, windowIndex: 0, child: Container( padding: const EdgeInsets.all(5), child: YoutubePlayer( key: ObjectKey(_controllerStream1), aspectRatio: 16 / 9, enableFullScreenOnVerticalDrag: false, controller: _controllerStream1, ), ), ), ), ), Positioned( child: PointerInterceptor( intercepting: false, child: ResizebleWidget( onDrag: (windowIndex, width, height) { setState(() {}); }, windowIndex: 1, child: Container( padding: const EdgeInsets.all(5), child: YoutubePlayer( key: ObjectKey(_controllerStream2), aspectRatio: 16 / 9, enableFullScreenOnVerticalDrag: false, controller: _controllerStream2, ), ), ), ), ),`