还在尝试跑通播放状态
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:provider/provider.dart';
|
||||
import '../services/webdav_service.dart';
|
||||
import '../services/playback_service.dart';
|
||||
import '../services/audio_service.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
class WebDAVFileListPage extends StatefulWidget {
|
||||
final String currentPath;
|
||||
@@ -69,15 +71,25 @@ class _WebDAVFileListPageState extends State<WebDAVFileListPage> {
|
||||
void _playSong(WebDAVItem file) async {
|
||||
try {
|
||||
final url = WebDAVService.instance.getFileUrl(file.path);
|
||||
await PlaybackService().play(url);
|
||||
|
||||
// ✅ 硬编码认证头(与 home_page 保持一致)
|
||||
final testHeaders = {
|
||||
'Authorization':
|
||||
'Basic ' + base64Encode(utf8.encode('test-user-1:Lxh10020328?')),
|
||||
};
|
||||
|
||||
print('🎵 [文件列表] 播放 URL: $url');
|
||||
print('📋 [文件列表] 认证头已设置');
|
||||
|
||||
final song = Song(
|
||||
id: file.path,
|
||||
title: _safeDecode(file.name).replaceAll(RegExp(r'\.[^.]*$'), ''),
|
||||
title: file.name.replaceAll(RegExp(r'\.[^.]*$'), ''),
|
||||
artist: '未知艺术家',
|
||||
url: url,
|
||||
);
|
||||
context.read<AudioService>().playSong(song);
|
||||
|
||||
await PlaybackService().play(url, headers: testHeaders);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
||||
Reference in New Issue
Block a user