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
713 stars 829 forks source link

dear friend plz resolve youtube live video issue plz buffring only some device show black screen #349

Open shailendra-rajpoot opened 4 years ago

shailendra-rajpoot commented 4 years ago

plz plz bro give update of the depandancy so many issue is coming in live video plz update

shailendra-rajpoot commented 4 years ago

are you doing work on this or not ?????

mirkarpude commented 4 years ago

+1

shailendra-rajpoot commented 4 years ago

+1

mirkarpude i m not getting you plz clear your thought

shailendra-rajpoot commented 4 years ago

The controller is not ready for method calls. this message show in the device where is show only buffering and this code working fine in other device my code is here class _YoutubeVideoPlayerState extends State { String doubt="",studentName=""; final doubtFormKey = GlobalKey(); YoutubePlayerController _controller; PlayerState _playerState; bool _isPlayerReady = false; String videoId="", videoStatus="",paymentStatus="";

_YoutubeVideoPlayerState(this.paymentStatus,this.videoId,this.videoStatus);

Future getSharedPrefs() async { SharedPreferences prefs = await SharedPreferences.getInstance(); studentName = prefs.getString("StudentName"); }

@override void initState() { super.initState(); getSharedPrefs(); _controller = YoutubePlayerController( initialVideoId: videoId.trim(), flags: const YoutubePlayerFlags( autoPlay: true, disableDragSeek: false, loop: false, isLive: true, forceHD: false, enableCaption: false, ), )..addListener(listener); _playerState = PlayerState.unknown; }

void listener() { if (_isPlayerReady && mounted && !_controller.value.isFullScreen) { setState(() { _playerState = _controller.value.playerState; }); } }

@override void deactivate() { // Pauses video while navigating to next page. _controller.pause(); super.deactivate(); }

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

@override Widget build(BuildContext context) { return YoutubePlayerBuilder( onExitFullScreen: () { // The player forces portraitUp after exiting fullscreen. This overrides the behaviour. SystemChrome.setPreferredOrientations(DeviceOrientation.values); }, player: YoutubePlayer( controller: _controller, showVideoProgressIndicator: false, // progressIndicatorColor: Colors.blueAccent, onReady: () { _isPlayerReady = true; print("ready"); }, ), /////////////////////////////////////////////////////////// builder: (context, player) => Scaffold( appBar: AppBar( automaticallyImplyLeading: true, leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: () => Navigator.pop(context, false), ), title: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Text(global.appName,style: TextStyle(fontSize: 16,color: MyColor.white,fontWeight: FontWeight.bold,letterSpacing: .5)), ] ), ), body: ((videoId.isEmpty) ? Center( child: Column( children: [ SizedBox(height: 180,), SvgPicture.asset("assets/no-video.svg",width: 80,color: MyColor.grey,), SizedBox(height: 20,), Text("No Live Class is going on now...",style: TextStyle(fontSize: 20,color: Colors.black,fontWeight: FontWeight.w500)) ],

          ),
        ):
        (videoStatus=="free" || paymentStatus=="success") ?
        ListView(
          //shrinkWrap: true,
          //crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            player,
            Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(top: 30,left: 10,bottom: 10,right: 10),
                  //width: MediaQuery.of(context).size.width,
                  child: Form(
                      key: doubtFormKey,
                      child: TextFormField(
                        keyboardType: TextInputType.multiline,
                        maxLines: 4,
                        autofocus: false,
                        //autovalidate: true,
                        decoration: InputDecoration(
                          // hintText: 'Mobile',
                          labelText: 'Ask doubt ?',
                          //contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
                          border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
                        ),
                        validator: (String value) {
                          return value.isEmpty ? "Please enter doubt" : null;
                        },
                        onSaved: (String value) {
                          doubt=value;
                        },
                      )
                  ),
                ),
                Container(
                  height: 40,
                  width: 100,
                  child: FlatButton(
                      color: MyColor.themeColor,
                      child: const Text('SEND',style: TextStyle(color: MyColor.white),),
                      onPressed: () {
                        //Navigator.pop(context);
                        if(doubtFormKey.currentState.validate()) {
                          doubtFormKey.currentState.save();
                          print("called");
                          sendDoubt();
                        }
                      }),
                ),
                SizedBox(height: 20,)
              ],
            ),

          ],
        ):
        Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Text("Buy premium to watch live class...",style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)),
              SizedBox(height: 10,),
              FlatButton(
                color: MyColor.themeColor,
                child: Text(
                  ' Make payment',
                  style: TextStyle(color: MyColor.white),
                ),
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute<dynamic>(
                      builder: (BuildContext context) => Membership(),
                    ),
                  );

                },
              )
            ],
          )
          )

      )
      )

    );

}

void sendDoubt() { Fluttertoast.showToast( msg: "Doubt send successfully", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, backgroundColor: Colors.black, textColor: Colors.white, fontSize: 16.0 ); doubtFormKey.currentState.reset(); print("path="+"https://jeevandangwalior.com/admin/public/chatRoom/addChat.php?name="+"studentName"+"&id="+global.teacher_id+"&message="+doubt); try { Dio().get("https://www.jeevandangwalior.com/admin/public/chatRoom/addChat.php?name=" + studentName + '&message=' + doubt+ "&id=" + global.teacher_id).then((response) async{

  });

}
catch(error){
  print("error"+error);
}

}

}

RohithKilaparthi commented 3 years ago

@shailendra-rajpoot did you find a solution to this? If not can you help sharing the logs.