Open shailendra-rajpoot opened 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
_LiveVideoPlayerState(this.paymentStatus,this.videoId,this.videoStatus);
Future
@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:
),
):
(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);
}
}
}
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