hyzp_ybqx-Commit178:优化,已经实现违章视频的循环播放

This commit is contained in:
WinUser01
2022-11-09 23:28:47 +08:00
parent b6a6d474d9
commit c38bfd7224
2 changed files with 15 additions and 12 deletions
+1
View File
@@ -2078,6 +2078,7 @@ Future playUrl({@required int index, String url, BuildContext context}) {
id: index + 1, id: index + 1,
dwip: listDwinfoGetList2[index]['dwip'], dwip: listDwinfoGetList2[index]['dwip'],
url: urlnew, url: urlnew,
urlType: 'rtmp',
title: '点位视频\n${(index + 1)}、${listDwinfoGetList2[index]['dwmc']}', title: '点位视频\n${(index + 1)}、${listDwinfoGetList2[index]['dwmc']}',
))); )));
+9 -7
View File
@@ -22,17 +22,19 @@ const _kControlViewTypes = [kControlViewTypeDefault, kControlViewTypeWithout];
class SuperPlayerPage extends StatefulWidget { class SuperPlayerPage extends StatefulWidget {
SuperPlayerPage( SuperPlayerPage(
{@required this.url, {@required this.url,
this.urlType = 'mp4', // 视频类型:mp4,rtmp
this.id = -2, // 播放点位视频的点位编号,-2 表示播放违章视频 this.id = -2, // 播放点位视频的点位编号,-2 表示播放违章视频
this.dwip = '', // 点位IP,用于点位视频控制球机方向 this.dwip = '', // 点位IP,用于点位视频控制球机方向
this.loop = 1, this.loop = 1,
this.title = 'Tencent Player', this.title = 'Tencent Player',
Key key}) Key key})
: super(key: key); : super(key: key);
String dwip;
String url; String url;
String title; String urlType;
int loop; //设置播放循环,默认播放器的循环次数是1, 即不循环播放。如果设置循环次数0,表示无限循环。
int id; int id;
String dwip;
int loop; //设置播放循环,默认播放器的循环次数是1, 即不循环播放。如果设置循环次数0,表示无限循环。
String title;
@override @override
_SuperPlayerPageState createState() => _SuperPlayerPageState(); _SuperPlayerPageState createState() => _SuperPlayerPageState();
@@ -79,13 +81,13 @@ class _SuperPlayerPageState extends State<SuperPlayerPage> with SuperPlayerListe
print('mounted = ${mounted}'); print('mounted = ${mounted}');
await _playerController.setLoop(widget.loop); // 0无限循环,1循环一次,2循环两次,以此类推 await _playerController.setLoop(widget.loop); // 0无限循环,1循环一次,2循环两次,以此类推
if (widget.loop == 0) {
await _playerController.setOption(FijkOption.playerCategory, "mediacodec-all-videos", 1); await _playerController.setOption(FijkOption.playerCategory, "mediacodec-all-videos", 1);
await _playerController.setOption(FijkOption.hostCategory, "enable-snapshot", 1); await _playerController.setOption(FijkOption.hostCategory, "enable-snapshot", 1);
await _playerController.setOption(FijkOption.hostCategory, "request-screen-on", 1); await _playerController.setOption(FijkOption.hostCategory, "request-screen-on", 1);
await _playerController.setOption(FijkOption.hostCategory, "request-audio-focus", 1); await _playerController.setOption(FijkOption.hostCategory, "request-audio-focus", 1);
await _playerController.setOption(FijkOption.hostCategory, "enable-accurate-seek", 1); await _playerController.setOption(FijkOption.hostCategory, "enable-accurate-seek", 1);
} else { // 播放“rmtp”等网络视频设置
if (widget.urlType != 'mp4') {
/// fijkplayer播放点位视频延迟比较大优化-OK,改完后约1秒钟就能打开 - Being /// fijkplayer播放点位视频延迟比较大优化-OK,改完后约1秒钟就能打开 - Being
// 是否开启预缓冲,一般直播项目会开启,达到秒开的效果,不过带来了播放丢帧卡顿的体验 // 是否开启预缓冲,一般直播项目会开启,达到秒开的效果,不过带来了播放丢帧卡顿的体验
await _playerController.setOption(FijkOption.playerCategory, "packet-buffering", 0); await _playerController.setOption(FijkOption.playerCategory, "packet-buffering", 0);
@@ -102,8 +104,8 @@ class _SuperPlayerPageState extends State<SuperPlayerPage> with SuperPlayerListe
/// fijkplayer播放点位视频延迟比较大优化-OK,改完后半秒钟就能打开 - End /// fijkplayer播放点位视频延迟比较大优化-OK,改完后半秒钟就能打开 - End
await _playerController.setOption(FijkOption.hostCategory, "request-screen-on", 1); // await _playerController.setOption(FijkOption.hostCategory, "request-screen-on", 1);
await _playerController.setOption(FijkOption.hostCategory, "request-audio-focus", 1); // await _playerController.setOption(FijkOption.hostCategory, "request-audio-focus", 1);
} }
await _playerController.setDataSource(widget.url, autoPlay: true).catchError((e) { await _playerController.setDataSource(widget.url, autoPlay: true).catchError((e) {