**i used flick vidoe player package for flutter TV plateform it works fine on emulator but when i create a release for it and intall on phycial device it me causing lagging in video and not showing contolas on TV device
i try the of offical pub.dev package code but just one thing i change that onEnd the video will play in loop i have links of videos last video play then first video play again and repeat process**
class LandscapePlayerControls extends StatelessWidget {
const LandscapePlayerControls(
{Key? key, this.iconSize = 20, this.fontSize = 12, this.dataManager})
: super(key: key);
final double iconSize;
final double fontSize;
final DataManager? dataManager;
@override
Widget build(BuildContext context) {
const String logo = 'assets/images/logo.svg';
FlickVideoManager flickVideoManager =
Provider.of<FlickVideoManager>(context);
return Stack(
children: <Widget>[
FlickShowControlsAction(
child: FlickSeekVideoAction(
child: Center(
child: flickVideoManager.nextVideoAutoPlayTimer != null
? FlickAutoPlayCircularProgress(
colors: FlickAutoPlayTimerProgressColors(
backgroundColor: Colors.white30,
color: Colors.red,
),
)
: FlickAutoHideChild(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () {
dataManager!.skipToPreviousVideo();
},
child: Icon(
Icons.skip_previous,
color: dataManager!.hasPreviousVideo()
? Colors.white
: Colors.white38,
size: 35,
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: FlickPlayToggle(size: 50),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () {
dataManager!.skipToNextVideo();
},
child: Icon(
Icons.skip_next,
color: dataManager!.hasNextVideo()
? Colors.white
: Colors.white38,
size: 35,
),
),
)
],
),
),
),
),
),
Positioned.fill(
child: FlickAutoHideChild(
child: Column(
children: <Widget>[
Expanded(
child: Container(),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
color: Color.fromRGBO(0, 0, 0, 0.4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
FlickPlayToggle(
size: 20,
),
SizedBox(
width: 10,
),
FlickCurrentPosition(
fontSize: fontSize,
),
SizedBox(
width: 10,
),
Expanded(
child: Container(
child: FlickVideoProgressBar(
flickProgressBarSettings: FlickProgressBarSettings(
height: 10,
handleRadius: 10,
padding: EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 8,
),
backgroundColor: Colors.white24,
bufferedColor: Colors.white38,
getPlayedPaint: (
{double? handleRadius,
double? height,
double? playedPart,
double? width}) {
return Paint()
..shader = LinearGradient(colors: [
Color.fromRGBO(108, 165, 242, 1),
Color.fromRGBO(97, 104, 236, 1)
], stops: [
0.0,
0.5
]).createShader(
Rect.fromPoints(
Offset(0, 0),
Offset(width!, 0),
),
);
},
getHandlePaint: (
{double? handleRadius,
double? height,
double? playedPart,
double? width}) {
return Paint()
..shader = RadialGradient(
colors: [
Color.fromRGBO(97, 104, 236, 1),
Color.fromRGBO(97, 104, 236, 1),
Colors.white,
],
stops: [0.0, 0.4, 0.5],
radius: 0.4,
).createShader(
Rect.fromCircle(
center: Offset(playedPart!, height! / 2),
radius: handleRadius!,
),
);
},
),
),
),
),
FlickTotalDuration(
fontSize: fontSize,
),
SizedBox(
width: 10,
),
FlickSoundToggle(
size: 20,
),
],
),
),
],
),
),
),
Positioned(
right: 20,
top: 10,
child: SvgPicture.asset(
logo,
semanticsLabel: 'Logo',
// colorFilter: ColorFilter.mode(Colors.redAccent, BlendMode.srcIn),
),
),
],
);
}
}
class SamplePlayer extends StatefulWidget {
SamplePlayer();
@override
_SamplePlayerState createState() => _SamplePlayerState();
}
class _SamplePlayerState extends State<SamplePlayer> {
late FlickManager flickManager;
late DataManager dataManager;
List<String> urls = (videoData["videos"] as List)
.map<String>((link) => link["videoUrl"])
.toList();
@override
void initState() {
super.initState();
flickManager = FlickManager(
videoPlayerController: VideoPlayerController.networkUrl(
Uri.parse(urls[0]),
),
onVideoEnd: () {
dataManager.skipToNextVideo(Duration(seconds: 5));
});
dataManager = DataManager(flickManager: flickManager, urls: urls);
}
@override
void dispose() {
flickManager.dispose();
super.dispose();
}
skipToVideo(String url) {
flickManager
.handleChangeVideo(VideoPlayerController.networkUrl(Uri.parse(url)));
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: FlickVideoPlayer(
flickManager: flickManager,
preferredDeviceOrientation: [
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft
],
systemUIOverlay: [],
flickVideoWithControls: FlickVideoWithControls(
controls: LandscapePlayerControls(dataManager: dataManager),
),
),
);
}
}
class DataManager {
DataManager({required this.flickManager, required this.urls});
int currentPlaying = 0;
final FlickManager flickManager;
final List<String> urls;
late Timer videoChangeTimer;
// checking is there any next video
String getNextVideo() {
currentPlaying++;
return urls[currentPlaying % urls.length];
}
// checking that the list has the next video link
bool hasNextVideo() {
return true; // Always return true for infinite looping
}
// previousVideos
bool hasPreviousVideo() {
return true; // Always return true for infinite looping
}
// the function that plays the next video in the list
skipToNextVideo([Duration? duration]) {
debugPrint("video next index====>>$currentPlaying");
String nextVideo = getNextVideo();
flickManager.handleChangeVideo(
VideoPlayerController.networkUrl(
Uri.parse(nextVideo),
),
videoChangeDuration: duration,
);
}
skipToPreviousVideo() {
currentPlaying--;
flickManager.handleChangeVideo(
VideoPlayerController.networkUrl(
Uri.parse(urls[currentPlaying % urls.length]),
),
);
}
cancelVideoAutoPlayTimer({required bool playNext}) {
flickManager.flickVideoManager
?.cancelVideoAutoPlayTimer(playNext: playNext);
}
> }