现阶段基础播放能力已经实现,接下来将尽全力往UI方向再调整一下
This commit is contained in:
+19
-14
@@ -9,7 +9,6 @@ import '../widgets/magnetic_scroll_physics.dart';
|
||||
import 'webdav_setup_page.dart';
|
||||
import 'webdav_file_list_page.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
// ==================================================
|
||||
// 歌曲数据模型
|
||||
@@ -258,15 +257,7 @@ class _HomePageState extends State<HomePage> {
|
||||
try {
|
||||
final url = WebDAVService.instance.getFileUrl(song.path);
|
||||
|
||||
// ✅ 硬编码认证头测试
|
||||
final testHeaders = {
|
||||
'Authorization':
|
||||
'Basic ' + base64Encode(utf8.encode('test-user-1:Lxh10020328?')),
|
||||
};
|
||||
|
||||
print('🎵 测试 URL: $url');
|
||||
print('📋 测试认证头: ${testHeaders.keys}');
|
||||
|
||||
// 1️⃣ 先更新 UI(立即响应)
|
||||
final audioService = context.read<AudioService>();
|
||||
audioService.playSong(Song(
|
||||
id: song.path,
|
||||
@@ -275,12 +266,26 @@ class _HomePageState extends State<HomePage> {
|
||||
url: url,
|
||||
));
|
||||
|
||||
// 获取认证头
|
||||
// 2️⃣ 动态获取认证头
|
||||
final headers = await WebDAVService.instance.getAuthHeaders();
|
||||
print('📋 认证头数量: ${headers.length}');
|
||||
print('📋 认证头内容: $headers');
|
||||
|
||||
// 播放
|
||||
if (headers.isEmpty) {
|
||||
print('⚠️ 未获取到认证头,请检查 WebDAV 登录状态');
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请先登录 WebDAV'),
|
||||
backgroundColor: Colors.orange,
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
print('🎵 [收藏列表] 播放 URL: $url');
|
||||
print('📋 [收藏列表] 认证头已设置: ${headers.keys}');
|
||||
|
||||
// 3️⃣ 播放
|
||||
await PlaybackService().play(url, headers: headers);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
|
||||
Reference in New Issue
Block a user