自定义线路与线路优化

This commit is contained in:
2026-06-04 17:52:16 +08:00
parent 33509de4e3
commit e6c60a9d6d
16 changed files with 1184 additions and 203 deletions
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:media_kit/media_kit.dart';
import '../../../data/models/file_model.dart';
import '../../../services/custom_line_service.dart';
import '../../../services/file_service.dart';
/// 音频预览页面
@@ -43,7 +44,11 @@ class _AudioPreviewPageState extends State<AudioPreviewPage> {
setState(() {
_isLoading = false;
});
player.open(Media(url), play: true);
await CustomLineService.instance.configureMediaPlayerProxy(
player,
url,
);
await player.open(Media(url), play: true);
}
} else {
if (mounted) {
@@ -104,11 +109,7 @@ class _AudioPreviewPageState extends State<AudioPreviewPage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
size: 64,
color: Colors.white54,
),
const Icon(Icons.error_outline, size: 64, color: Colors.white54),
const SizedBox(height: 16),
Text(
_errorMessage!,
@@ -140,14 +141,17 @@ class AudioPlayerWidget extends StatefulWidget {
final Player player;
final String fileName;
const AudioPlayerWidget({super.key, required this.player, required this.fileName});
const AudioPlayerWidget({
super.key,
required this.player,
required this.fileName,
});
@override
State<AudioPlayerWidget> createState() => _AudioPlayerWidgetState();
}
class _AudioPlayerWidgetState extends State<AudioPlayerWidget> {
@override
Widget build(BuildContext context) {
return Container(
@@ -155,10 +159,7 @@ class _AudioPlayerWidgetState extends State<AudioPlayerWidget> {
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
const Color(0xFF1A1A2E),
const Color(0xFF16213E),
],
colors: [const Color(0xFF1A1A2E), const Color(0xFF16213E)],
),
),
child: Padding(
@@ -246,12 +247,18 @@ class _AudioPlayerWidgetState extends State<AudioPlayerWidget> {
return SliderTheme(
data: SliderThemeData(
trackHeight: 4,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 8),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 16),
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 8,
),
overlayShape: const RoundSliderOverlayShape(
overlayRadius: 16,
),
activeTrackColor: const Color(0xFFE94560),
inactiveTrackColor: Colors.white.withValues(alpha: 0.1),
thumbColor: const Color(0xFFE94560),
overlayColor: const Color(0xFFE94560).withValues(alpha: 0.3),
overlayColor: const Color(
0xFFE94560,
).withValues(alpha: 0.3),
),
child: Slider(
value: position.inMilliseconds.toDouble(),
@@ -259,9 +266,7 @@ class _AudioPlayerWidgetState extends State<AudioPlayerWidget> {
? duration.inMilliseconds.toDouble()
: 1.0,
onChanged: (value) {
widget.player.seek(
Duration(milliseconds: value.toInt()),
);
widget.player.seek(Duration(milliseconds: value.toInt()));
},
),
);