use MIHYTVideoPlayer on long press of tile
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
|
import 'package:Mzansi_Innovation_Hub/mih_components/mih_yt_video_player.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
|
|
||||||
|
|
||||||
import 'mih_window.dart';
|
import 'mih_window.dart';
|
||||||
|
|
||||||
class MIHTile extends StatefulWidget {
|
class MIHTile extends StatefulWidget {
|
||||||
final String tileName;
|
final String tileName;
|
||||||
final String? videoYTLink;
|
final String? videoID;
|
||||||
final Widget tileIcon;
|
final Widget tileIcon;
|
||||||
final void Function() onTap;
|
final void Function() onTap;
|
||||||
// final Widget tileIcon;
|
// final Widget tileIcon;
|
||||||
@@ -18,7 +16,7 @@ class MIHTile extends StatefulWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
required this.tileName,
|
required this.tileName,
|
||||||
this.videoYTLink,
|
this.videoID,
|
||||||
required this.tileIcon,
|
required this.tileIcon,
|
||||||
required this.p,
|
required this.p,
|
||||||
required this.s,
|
required this.s,
|
||||||
@@ -31,28 +29,9 @@ class MIHTile extends StatefulWidget {
|
|||||||
class _MIHTileState extends State<MIHTile> {
|
class _MIHTileState extends State<MIHTile> {
|
||||||
late Color mainC;
|
late Color mainC;
|
||||||
late Color secondC;
|
late Color secondC;
|
||||||
late YoutubePlayerController videoController;
|
|
||||||
|
|
||||||
String getVideID() {
|
|
||||||
if (widget.videoYTLink != null) {
|
|
||||||
return YoutubePlayer.convertUrlToId(widget.videoYTLink!) as String;
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// void listener() {
|
|
||||||
// if (_isPlayerReady && mounted && !videoController.value.isFullScreen) {
|
|
||||||
// setState(() {
|
|
||||||
// _playerState = videoController.value.playerState;
|
|
||||||
// _videoMetaData = videoController.metadata;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
videoController.dispose();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,19 +39,11 @@ class _MIHTileState extends State<MIHTile> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
mainC = widget.p;
|
mainC = widget.p;
|
||||||
secondC = widget.s;
|
secondC = widget.s;
|
||||||
|
|
||||||
videoController = YoutubePlayerController(
|
|
||||||
initialVideoId: getVideID(),
|
|
||||||
flags: YoutubePlayerFlags(
|
|
||||||
autoPlay: false,
|
|
||||||
mute: true,
|
|
||||||
isLive: false,
|
|
||||||
));
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayHint() {
|
void displayHint() {
|
||||||
if (widget.videoYTLink != null) {
|
if (widget.videoID != null) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -84,20 +55,7 @@ class _MIHTileState extends State<MIHTile> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
windowBody: [
|
windowBody: [
|
||||||
YoutubePlayerBuilder(
|
MIHYTVideoPlayer(videoYTLink: widget.videoID!),
|
||||||
player: YoutubePlayer(
|
|
||||||
controller: videoController,
|
|
||||||
showVideoProgressIndicator: true,
|
|
||||||
progressIndicatorColor: Colors.amber,
|
|
||||||
progressColors: ProgressBarColors(
|
|
||||||
playedColor: Colors.amber,
|
|
||||||
handleColor: Colors.amberAccent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
builder: (context, player) {
|
|
||||||
return player;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -131,9 +89,9 @@ class _MIHTileState extends State<MIHTile> {
|
|||||||
borderRadius: BorderRadius.circular(80),
|
borderRadius: BorderRadius.circular(80),
|
||||||
// ho
|
// ho
|
||||||
onTap: widget.onTap,
|
onTap: widget.onTap,
|
||||||
// onLongPress: () {
|
onLongPress: () {
|
||||||
// displayHint();
|
displayHint();
|
||||||
// },
|
},
|
||||||
// hoverDuration: ,
|
// hoverDuration: ,
|
||||||
splashColor:
|
splashColor:
|
||||||
MzanziInnovationHub.of(context)!.theme.highlightColor(),
|
MzanziInnovationHub.of(context)!.theme.highlightColor(),
|
||||||
@@ -143,26 +101,6 @@ class _MIHTileState extends State<MIHTile> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Material(
|
|
||||||
// color: mainC,
|
|
||||||
// borderRadius: BorderRadius.circular(80),
|
|
||||||
// child: Ink(
|
|
||||||
// // width: 200,
|
|
||||||
// // height: 200,
|
|
||||||
// padding: const EdgeInsets.all(20),
|
|
||||||
// child: InkWell(
|
|
||||||
// onTap: widget.onTap,
|
|
||||||
// hoverDuration: Duration(seconds: 2),
|
|
||||||
// highlightColor:
|
|
||||||
// MzanziInnovationHub.of(context)!.theme.messageTextColor(),
|
|
||||||
// child: SizedBox(
|
|
||||||
// height: 200,
|
|
||||||
// width: 200,
|
|
||||||
// child: widget.tileIcon,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 300,
|
width: 300,
|
||||||
|
|||||||
Reference in New Issue
Block a user