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
691 stars 779 forks source link

buffering in panasonic phone #336

Open shailendra-rajpoot opened 4 years ago

shailendra-rajpoot commented 4 years ago

show error

I/BufferQueueProducer( 7257): SurfaceTexture-0-7257-4 queueBuffer: slot 0 is dropped, handle=0x78196be740 I/BufferQueueProducer( 7257): SurfaceTexture-0-7257-3 queueBuffer: slot 1 is dropped, handle=0x77e7dec4c0 I/BufferQueueProducer( 7257): SurfaceTexture-0-7257-4 queueBuffer: slot 1 is dropped, handle=0x77d4fca6c0 I/BufferQueueProducer( 7257): SurfaceTexture-0-7257-3 queueBuffer: slot 2 is dropped, handle=0x78196be980 I/BufferQueueProducer( 7257): SurfaceTexture-0-7257-4 queueBuffer: slot 0 is dropped, handle=0x78196be740 I/BufferQueueProducer( 7257): SurfaceTexture-0-7257-3 queueBuffer: slot 1 is dropped, handle=0x77e7dec4c0

shailendra-rajpoot commented 4 years ago

my code

import 'dart:convert'; import 'design_course_app_theme.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/rendering.dart'; import 'globals.dart' as global; import 'membership.dart';

class LiveVideoPlayer extends StatefulWidget { String status="",liveVideoStatus="",liveVideoId=""; LiveVideoPlayer(this.status,this.liveVideoId,this.liveVideoStatus); @override _LiveVideoPlayerState createState() => _LiveVideoPlayerState(status,liveVideoId,liveVideoStatus); }

class _LiveVideoPlayerState extends State { String doubt="",studentName=""; final doubtFormKey = GlobalKey(); YoutubePlayerController _controller; PlayerState _playerState; YoutubeMetaData _videoMetaData; bool _isPlayerReady = false; String videoId="", videoStatus="",paymentStatus="";

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

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

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

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

@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( player: YoutubePlayer( controller: _controller, showVideoProgressIndicator: true, progressIndicatorColor: Colors.blueAccent, ), /////////////////////////////////////////////////////////// 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: 19)), ] ), ), body: ((videoId.isEmpty) ? Center( child: Column( children: [ SizedBox(height: 180,), SvgPicture.asset("assets/no-video.svg",width: 80,color: Colors.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: DesignCourseAppTheme.nearlyBlue,
                      child: const Text('SEND',style: TextStyle(color: Colors.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: DesignCourseAppTheme.nearlyBlue,
                  child: Text(
                    ' Make payment',
                    style: TextStyle(color: Colors.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);
}

}

}