Description
Steps to reproduce
I am encountering a video flickering issue specifically on iOS devices when using Flutter version 3.24.1. The videos play without any problems on Android devices. However, on iOS, the video playback exhibits noticeable flickering. This issue does not occur when using Flutter versions 3.22.3 or earlier.
- Create a Flutter project using Flutter 3.24.1.
- Implement video playback functionality (using the better_player_plus plugin).
- Run the app on an iOS device.
Expected results
Videos should play smoothly without any flickering on iOS devices, as they do on Android.
Actual results
Videos exhibit flickering during playback on iOS devices.
Code sample
Code sample
import 'dart:math';
import 'package:better_player_plus/better_player_plus.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Video List',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final List<String> _videos = [
'https://cdn.pixabay.com/video/2022/12/18/143419-782363231_large.mp4',
'https://videos.pexels.com/video-files/4678261/4678261-hd_1080_1920_25fps.mp4',
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4',
'https://videos.pexels.com/video-files/4434150/4434150-hd_1080_1920_30fps.mp4',
];
final _random = Random();
List<VideoListData> dataList = [];
@override
void initState() {
_setupData();
super.initState();
}
void _setupData() {
for (int index = 0; index < 10; index++) {
var randomVideoUrl = _videos[_random.nextInt(_videos.length)];
dataList.add(VideoListData("Video $index", randomVideoUrl));
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Video in list")),
body: ListView.builder(
itemCount: dataList.length,
itemBuilder: (context, index) {
VideoListData videoListData = dataList[index];
return VideoListWidget(
videoListData: videoListData,
index: index,
);
},
),
);
}
}
class VideoListData {
final String videoTitle;
final String videoUrl;
Duration? lastPosition;
bool? wasPlaying = false;
VideoListData(this.videoTitle, this.videoUrl);
}
class VideoListWidget extends StatefulWidget {
final VideoListData? videoListData;
final int index;
const VideoListWidget({super.key, this.videoListData, required this.index});
@override
State<VideoListWidget> createState() => _VideoListWidgetState();
}
class _VideoListWidgetState extends State<VideoListWidget> {
VideoListData? get videoListData => widget.videoListData;
BetterPlayerListVideoPlayerController? controller;
@override
void initState() {
super.initState();
controller = BetterPlayerListVideoPlayerController();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return ClipRRect(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.7,
child: ClipRRect(
child: Column(
children: [
SizedBox(
height: 50,
child: Text('Item - ${widget.index}'),
),
BetterPlayerListVideoPlayer(
BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
videoListData!.videoUrl,
bufferingConfiguration: const BetterPlayerBufferingConfiguration(
minBufferMs: 2000,
maxBufferMs: 10000,
bufferForPlaybackMs: 1000,
bufferForPlaybackAfterRebufferMs: 2000),
),
configuration: const BetterPlayerConfiguration(
autoPlay: false,
aspectRatio: 1,
handleLifecycle: true,
fit: BoxFit.cover,
expandToFill: false,
controlsConfiguration: BetterPlayerControlsConfiguration(
showControls: false,
showControlsOnInitialize: false,
),
),
playFraction: 0.8,
betterPlayerListVideoPlayerController: controller,
),
const SizedBox(
height: 50,
child: Text('Footer'),
),
],
),
),
),
);
}
}
Screenshots or Video
- For flutter 3.22.3 Working
RPReplay_Final1724840402.2.mp4
- For flutter 3.24 and 3.24.1 Not Working
RPReplay_Final1724839192.2.1.mp4
Logs
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.1, on macOS 14.5 23F79 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] Connected device (6 available)
[✓] Network resources
• No issues found!