youtube_player_flutter icon indicating copy to clipboard operation
youtube_player_flutter copied to clipboard

[BUG] Full screen is not working, when i clicked on fullscreen button there is no effect on screen

Open Mohammad-taqi1212 opened this issue 2 years ago • 1 comments

Describe the bug I followed example step but full screen is not working, when i press fullscreen button on player, there is no action in code and no error also but full screen is not working.

For testing purpose I am using real android device

Following are my code:

@override
  void initState() {
    // TODO: implement initState
    super.initState();

    _controller = YoutubePlayerController(
      params: YoutubePlayerParams(
        showControls: true,
        mute: false,
        showFullscreenButton: true,
        loop: false,
      )
    );

    _controller.setFullScreenListener(
          (isFullScreen) {
        log('${isFullScreen ? 'Entered' : 'Exited'} Fullscreen.');
      },
    );
  }

 @override
  void dispose() {
    _controller.close();
    super.dispose();
  }



@override
  Widget build(BuildContext context) {
    return YoutubePlayerScaffold(
      controller: _controller,
      aspectRatio: 16 / 9,
      builder: (context, player) {
        return SafeArea(
            child: Scaffold(
              appBar: AppBar(title: Text("Live Program",
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 25
                ),),
                centerTitle: true,
                backgroundColor: Color(hexColors('006064')),
              ),
              body: StreamBuilder<LinkModel>(
                stream: stream,
                builder: (context,snapshot){
                  if(snapshot.hasData){
                    return SmartRefresher(
                      controller: refreshController,
                      enablePullUp: true,
                      child: ListView.builder(
                        itemCount: snapshot.data!.data!.length,
                          itemBuilder: (context, index){
                        var allItem = snapshot.data!.data![index];
                        var videoId = allItem.link!.substring(17);
                        return Card(
                          color: Color(hexColors("03A9F4")),
                          elevation: 6,
                          shape: RoundedRectangleBorder(
                              borderRadius:
                              BorderRadius.circular(10.0)),
                          child: Column(
                            children: [
                             YoutubePlayer(
                               controller: _controller = YoutubePlayerController.fromVideoId(videoId: videoId,
                               autoPlay: false,
                               params: YoutubePlayerParams(showFullscreenButton: true ))
                                 ),
                              SizedBox(height: 5,),
                              Text("City :- ${allItem.city}",
                              style: TextStyle(
                                color: Colors.white,
                                fontWeight: FontWeight.bold,
                                fontSize: 15
                              ),),
                              Padding(
                                padding: const EdgeInsets.all(10.0),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(allItem.username.toString()),
                                    Text(allItem.postDateTime.toString()),
                                    IconButton(onPressed: () async{
                                      await Share.share(allItem.link.toString());
                                    },
                                        icon: Icon(Icons.share,color: Colors.white))
                                  ],
                                ),
                              )
                            ],
                          ),

                        );
                      }
                      ),

                    );
                  }else{
                    return Container(child: Center(child: CircularProgressIndicator(),),);
                  }

                },
              ),
            )
        );
      },
    );
}

Mohammad-taqi1212 avatar Feb 21 '23 05:02 Mohammad-taqi1212

Try YoutubePlayerScaffold instead of YoutubePlayer.

YoutubePlayerScaffold(
          controller: _youtubeController,
          aspectRatio: 16 / 9,
          builder: (context, player) {
            return SingleChildScrollView(
                child: Column(
              children: [player],
            ));
          },
        )

Hsiao-Chien-Ti avatar Feb 21 '24 02:02 Hsiao-Chien-Ti