还在尝试跑通播放状态
This commit is contained in:
+30
-10
@@ -8,6 +8,8 @@ import '../widgets/mini_player_bar.dart';
|
||||
import '../widgets/magnetic_scroll_physics.dart';
|
||||
import 'webdav_setup_page.dart';
|
||||
import 'webdav_file_list_page.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
// ==================================================
|
||||
// 歌曲数据模型
|
||||
@@ -174,8 +176,6 @@ class _HomePageState extends State<HomePage> {
|
||||
// 媒体库透明度(快速淡出)
|
||||
double get _mediaOpacity {
|
||||
final p = _progress;
|
||||
// 0% ~ 30%: 1.0 → 0.05
|
||||
// 30% ~ 100%: 0.05 → 0
|
||||
if (p <= 0.3) {
|
||||
return 1.0 - (p / 0.3) * 0.95;
|
||||
} else {
|
||||
@@ -251,17 +251,37 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 播放 ==========
|
||||
// ============================================================
|
||||
// ⭐ 核心:播放方法(UI 优先响应,然后真正播放)
|
||||
// ============================================================
|
||||
void _playSong(SongItem song) async {
|
||||
try {
|
||||
final url = WebDAVService.instance.getFileUrl(song.path);
|
||||
await PlaybackService().play(url);
|
||||
context.read<AudioService>().playSong(Song(
|
||||
id: song.path,
|
||||
title: song.displayTitle,
|
||||
artist: song.displaySubtitle,
|
||||
url: url,
|
||||
));
|
||||
|
||||
// ✅ 硬编码认证头测试
|
||||
final testHeaders = {
|
||||
'Authorization':
|
||||
'Basic ' + base64Encode(utf8.encode('test-user-1:Lxh10020328?')),
|
||||
};
|
||||
|
||||
print('🎵 测试 URL: $url');
|
||||
print('📋 测试认证头: ${testHeaders.keys}');
|
||||
|
||||
final audioService = context.read<AudioService>();
|
||||
audioService.playSong(Song(
|
||||
id: song.path,
|
||||
title: song.displayTitle,
|
||||
artist: song.displaySubtitle,
|
||||
url: url,
|
||||
));
|
||||
|
||||
// 获取认证头
|
||||
final headers = await WebDAVService.instance.getAuthHeaders();
|
||||
print('📋 认证头数量: ${headers.length}');
|
||||
print('📋 认证头内容: $headers');
|
||||
|
||||
// 播放
|
||||
await PlaybackService().play(url, headers: headers);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
||||
Reference in New Issue
Block a user