Skip to content

Commit

Permalink
better player
Browse files Browse the repository at this point in the history
  • Loading branch information
Predidit committed Mar 29, 2024
1 parent 7a58609 commit 49192ff
Showing 1 changed file with 123 additions and 100 deletions.
223 changes: 123 additions & 100 deletions lib/pages/video/video_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,115 +170,121 @@ class _VideoPageState extends State<VideoPage> with WindowListener {
1.75,
2.0
];
SmartDialog.show(useAnimation: false, builder: (context) {
return AlertDialog(
title: const Text('播放速度'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Wrap(
spacing: 8,
runSpacing: 2,
children: [
for (final double i in speedsList) ...<Widget>[
if (i == currentSpeed) ...<Widget>[
FilledButton(
onPressed: () async {
await videoController.setPlaybackSpeed(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
await videoController.setPlaybackSpeed(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
]
]
SmartDialog.show(
useAnimation: false,
builder: (context) {
return AlertDialog(
title: const Text('播放速度'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Wrap(
spacing: 8,
runSpacing: 2,
children: [
for (final double i in speedsList) ...<Widget>[
if (i == currentSpeed) ...<Widget>[
FilledButton(
onPressed: () async {
await videoController.setPlaybackSpeed(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
] else ...[
FilledButton.tonal(
onPressed: () async {
await videoController.setPlaybackSpeed(i);
SmartDialog.dismiss();
},
child: Text(i.toString()),
),
]
]
],
);
}),
actions: <Widget>[
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style:
TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
await videoController.setPlaybackSpeed(1.0);
SmartDialog.dismiss();
},
child: const Text('默认速度'),
),
],
);
}),
actions: <Widget>[
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
await videoController.setPlaybackSpeed(1.0);
SmartDialog.dismiss();
},
child: const Text('默认速度'),
),
],
);
});
});
}

/// 发送弹幕 由于接口限制, 暂时未提交云端
void showShootDanmakuSheet() {
final TextEditingController textController = TextEditingController();
bool isSending = false; // 追踪是否正在发送
SmartDialog.show(useAnimation: false, builder: (context) {
return AlertDialog(
title: const Text('发送弹幕'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextField(
controller: textController,
);
}),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextButton(
onPressed: isSending
? null
: () async {
final String msg = textController.text;
if (msg.isEmpty) {
SmartDialog.showToast('弹幕内容不能为空');
return;
} else if (msg.length > 100) {
SmartDialog.showToast('弹幕内容不能超过100个字符');
return;
}
setState(() {
isSending = true; // 开始发送,更新状态
});
// Todo 接口方限制
SmartDialog.show(
useAnimation: false,
builder: (context) {
return AlertDialog(
title: const Text('发送弹幕'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextField(
controller: textController,
);
}),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style:
TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextButton(
onPressed: isSending
? null
: () async {
final String msg = textController.text;
if (msg.isEmpty) {
SmartDialog.showToast('弹幕内容不能为空');
return;
} else if (msg.length > 100) {
SmartDialog.showToast('弹幕内容不能超过100个字符');
return;
}
setState(() {
isSending = true; // 开始发送,更新状态
});
// Todo 接口方限制

setState(() {
isSending = false; // 发送结束,更新状态
});
SmartDialog.showToast('发送成功');
danmakuController.addItems([
DanmakuItem(
msg,
// color: Colors.purple,
)
]);
SmartDialog.dismiss();
},
child: Text(isSending ? '发送中...' : '发送'),
);
})
],
);
});
setState(() {
isSending = false; // 发送结束,更新状态
});
SmartDialog.showToast('发送成功');
danmakuController.addItems([
DanmakuItem(
msg,
// color: Colors.purple,
)
]);
SmartDialog.dismiss();
},
child: Text(isSending ? '发送中...' : '发送'),
);
})
],
);
});
}

@override
Expand Down Expand Up @@ -617,6 +623,23 @@ class _VideoPageState extends State<VideoPage> with WindowListener {
}
},
),
(videoController.androidFullscreen == true)
? IconButton(
color: Colors.white,
icon: const Icon(Icons.skip_next),
onPressed: () {
if (videoController.episode ==
videoController
.token.length) {
SmartDialog.showToast(
'已经是最新一集');
return;
}
videoController.changeEpisode(
videoController.episode + 1);
},
)
: Container(),
Expanded(
child: ProgressBar(
timeLabelLocation:
Expand Down

0 comments on commit 49192ff

Please sign in to comment.