재생 화면 조절 줄 좁을 때 두 줄 (P2) · 재생 목록 모듈: 소리 파일은 소리끼리

- P2 (관리자 지시 10/21, 28 찾음): Windows 창 폭 412 에서 조절 줄이 184px 넘쳐 속도 · 자막 · 목록 · 전체 화면이 잘림 →
  한 줄에 들지 않으면 두 줄 (위 재생 단추, 아래 소리 · 메뉴 · 전체 화면). 단추 크기 그대로, 소리 막대만 남는 폭 (최대 100)
- 판단은 공용 함수 lib/ui/row_fit.dart fitRow (약속: 아이템 최소 폭 목록 · 줄일 수 있는 아이템 범위 → 나눌지 · 폭) - 관리자 지시, d3 AdaptiveRow 자리
- 재생 목록 모듈 (관리자 지시 10/21): buildPlaylist 가 형제를 동영상으로만 걸러 mp3 를 틀면 같은 폴더 곡이 빠짐 →
  playlist.dart 의 samePlayKind · isPlayableFile · folderPlaylist 한 곳에서 정하고 컨트롤러 · 탐색기는 부르기만.
  동영상이 없는 폴더의 [재생] 은 소리 파일을 (안내 글도 "동영상 · 소리 파일")
- 확인: full_player_test 에 실제 mpv 장면 (412 · 600 · 960 × ko · ja, mp3 폴더 목록) - 같은 판에서 2회 통과. player_test 약속 줄

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
after_1020
RyuJongJin 2026-10-21 20:34:26 +09:00
parent a22832d130
commit 82a87dafb0
10 changed files with 212 additions and 56 deletions

View File

@ -2103,8 +2103,8 @@
"이 폴더를 rsync 원본 · 대상으로 고르기": "Choose this folder as rsync source · target", "이 폴더를 rsync 원본 · 대상으로 고르기": "Choose this folder as rsync source · target",
"이 폴더를 볼 권한이 없습니다": "No permission to view this folder", "이 폴더를 볼 권한이 없습니다": "No permission to view this folder",
"이 폴더를 읽을 권한이 없습니다": "No permission to read this folder", "이 폴더를 읽을 권한이 없습니다": "No permission to read this folder",
"이 폴더에 동영상이 없습니다.": "There are no videos in this folder.",
"이 폴더에 새 폴더": "New folder in this folder", "이 폴더에 새 폴더": "New folder in this folder",
"이 폴더에 재생할 동영상 · 소리 파일이 없습니다.": "No videos or audio files to play in this folder.",
"이 폴더에 현재 페이지 추가": "Add the current page to this folder", "이 폴더에 현재 페이지 추가": "Add the current page to this folder",
"이 폴더에는 고를 파일이 없습니다": "There are no files to choose in this folder", "이 폴더에는 고를 파일이 없습니다": "There are no files to choose in this folder",
"이 폴더에는 그림 · 동영상이 없습니다": "No pictures or videos in this folder", "이 폴더에는 그림 · 동영상이 없습니다": "No pictures or videos in this folder",

View File

@ -2103,8 +2103,8 @@
"이 폴더를 rsync 원본 · 대상으로 고르기": "このフォルダーを rsync の元 · 対象に選ぶ", "이 폴더를 rsync 원본 · 대상으로 고르기": "このフォルダーを rsync の元 · 対象に選ぶ",
"이 폴더를 볼 권한이 없습니다": "このフォルダーを表示する権限がありません", "이 폴더를 볼 권한이 없습니다": "このフォルダーを表示する権限がありません",
"이 폴더를 읽을 권한이 없습니다": "このフォルダーを読む権限がありません", "이 폴더를 읽을 권한이 없습니다": "このフォルダーを読む権限がありません",
"이 폴더에 동영상이 없습니다.": "このフォルダーに動画がありません。",
"이 폴더에 새 폴더": "このフォルダーに新しいフォルダー", "이 폴더에 새 폴더": "このフォルダーに新しいフォルダー",
"이 폴더에 재생할 동영상 · 소리 파일이 없습니다.": "このフォルダーに再生できる動画・音声ファイルがありません。",
"이 폴더에 현재 페이지 추가": "このフォルダーに現在のページを追加", "이 폴더에 현재 페이지 추가": "このフォルダーに現在のページを追加",
"이 폴더에는 고를 파일이 없습니다": "このフォルダーには選べるファイルがありません", "이 폴더에는 고를 파일이 없습니다": "このフォルダーには選べるファイルがありません",
"이 폴더에는 그림 · 동영상이 없습니다": "このフォルダーには画像・動画がありません", "이 폴더에는 그림 · 동영상이 없습니다": "このフォルダーには画像・動画がありません",

View File

@ -2103,8 +2103,8 @@
"이 폴더를 rsync 원본 · 대상으로 고르기": "选择此文件夹作为 rsync 源 · 目标", "이 폴더를 rsync 원본 · 대상으로 고르기": "选择此文件夹作为 rsync 源 · 目标",
"이 폴더를 볼 권한이 없습니다": "没有查看此文件夹的权限", "이 폴더를 볼 권한이 없습니다": "没有查看此文件夹的权限",
"이 폴더를 읽을 권한이 없습니다": "没有读取此文件夹的权限", "이 폴더를 읽을 권한이 없습니다": "没有读取此文件夹的权限",
"이 폴더에 동영상이 없습니다.": "此文件夹中没有视频。",
"이 폴더에 새 폴더": "在此文件夹中新建文件夹", "이 폴더에 새 폴더": "在此文件夹中新建文件夹",
"이 폴더에 재생할 동영상 · 소리 파일이 없습니다.": "此文件夹中没有可播放的视频或音频文件。",
"이 폴더에 현재 페이지 추가": "将当前页面添加到此文件夹", "이 폴더에 현재 페이지 추가": "将当前页面添加到此文件夹",
"이 폴더에는 고를 파일이 없습니다": "此文件夹中没有可选择的文件", "이 폴더에는 고를 파일이 없습니다": "此文件夹中没有可选择的文件",
"이 폴더에는 그림 · 동영상이 없습니다": "此文件夹中没有图片或视频", "이 폴더에는 그림 · 동영상이 없습니다": "此文件夹中没有图片或视频",

View File

@ -1,12 +1,23 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart'; import 'package:integration_test/integration_test.dart';
import 'package:jj_mkvmaker/app/app_controller.dart';
import 'package:jj_mkvmaker/app/i18n_controller.dart';
import 'package:jj_mkvmaker/core/playlist.dart';
import 'package:jj_mkvmaker/l10n/tr.dart';
import 'package:jj_mkvmaker/platform/common/media_kit_full_player.dart'; import 'package:jj_mkvmaker/platform/common/media_kit_full_player.dart';
import 'package:jj_mkvmaker/platform/common/media_kit_player.dart'; import 'package:jj_mkvmaker/platform/common/media_kit_player.dart';
import 'package:jj_mkvmaker/platform/windows/desktop_shell.dart'; import 'package:jj_mkvmaker/platform/windows/desktop_shell.dart';
import 'package:jj_mkvmaker/platform/windows/desktop_storage_service.dart';
import 'package:jj_mkvmaker/platform/windows/process_media_tool.dart';
import 'package:jj_mkvmaker/services/platform_services.dart';
import 'package:jj_mkvmaker/services/media_player.dart'; import 'package:jj_mkvmaker/services/media_player.dart';
import 'package:jj_mkvmaker/ui/player_page.dart';
import 'package:jj_mkvmaker/ui/theme.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
import 'support/temp_dir.dart'; import 'support/temp_dir.dart';
@ -99,4 +110,76 @@ void main() {
await tester.runAsync(() => pl.dispose()); await tester.runAsync(() => pl.dispose());
dir.deleteSync(recursive: true); dir.deleteSync(recursive: true);
}, timeout: const Timeout(Duration(minutes: 3))); }, timeout: const Timeout(Duration(minutes: 3)));
// P2 · 재생 목록 모듈 (관리자 지시 10/21, 28 찾음): 실제 mpv 로 재생 화면 - ① 창 폭 412 · 600 · 960 × ko · ja 에서 조절 줄이 넘치지 않고
// (좁으면 두 줄) 끝의 [전체 화면] 이 화면 안 ② mp3 를 고르면 같은 폴더의 다른 곡이 목록에 들고 동영상은 빠진다 ("폴더 전체")
testWidgets('재생 화면 조절 줄 · 음악 재생 목록 (실제 mpv)', (t) async {
MediaKitPreviewPlayer.ensureInitialized();
final out = Platform.environment['JJ_SHOT_DIR'] ?? '';
final dir = testTempDir('jj_fpctl_');
appTempInto(dir);
Future<void> make(String name, List<String> args) async {
final r = await t.runAsync(() => Process.run('ffmpeg', ['-y', '-v', 'error', ...args, p.join(dir.path, name)]));
expect(r!.exitCode, 0, reason: '${r.stderr}');
}
await make('ep1.mkv', ['-f', 'lavfi', '-i', 'testsrc=size=640x360:rate=25', '-f', 'lavfi', '-i', 'sine', '-t', '20', //
'-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-c:a', 'aac']);
for (final (n, hz) in [('Artist - Song A.mp3', 440), ('Other - Track 2.mp3', 550), ('Another title.mp3', 660)]) {
await make(n, ['-f', 'lavfi', '-i', 'sine=frequency=$hz:duration=20', '-c:a', 'libmp3lame']);
}
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool.locate(), storage: DesktopStorageService()));
c.settings.playlistMode = PlaylistMode.folder;
// ② 재생 목록 모듈: mp3 하나를 고르면 같은 폴더의 곡 셋 (동영상 ep1.mkv 는 빠짐)
final plan = await t.runAsync(() => c.preparePlayback([p.join(dir.path, 'Other - Track 2.mp3')], internal: true));
expect(plan!.$1.map(p.basename).toList(), ['Another title.mp3', 'Artist - Song A.mp3', 'Other - Track 2.mp3']);
expect(plan.$1[plan.$2], endsWith('Other - Track 2.mp3'));
final shotKey = GlobalKey();
for (final (files, start, tag) in [(plan.$1, plan.$2, 'audio'), ([p.join(dir.path, 'ep1.mkv')], 0, 'video')]) {
final pl = MediaKitFullPlayer();
await t.pumpWidget(RepaintBoundary(
key: shotKey,
child: MaterialApp(
theme: buildTheme(), debugShowCheckedModeBanner: false, home: PlayerPage(c: c, player: pl, files: files, start: start)),
));
for (var i = 0; i < 100 && !(pl.state.value.playing && pl.state.value.position > const Duration(milliseconds: 300)); i++) {
await t.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 100)));
await t.pump();
}
expect(pl.state.value.playing, isTrue, reason: '$tag 재생 시작');
expect(pl.playlist.length, files.length, reason: '$tag 재생 목록');
for (final lang in ['ko', 'ja']) {
await t.runAsync(() => i18n.apply(lang, save: false));
for (final (w, h) in [(412, 900), (600, 800), (960, 600)]) {
t.view.physicalSize = Size(w.toDouble(), h.toDouble());
t.view.devicePixelRatio = 1;
for (var i = 0; i < 6; i++) {
await t.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 80)));
await t.pump();
}
if (out.isNotEmpty) {
final r = shotKey.currentContext!.findRenderObject()! as RenderRepaintBoundary;
final img = await t.runAsync(() => r.toImage());
final bytes = await t.runAsync(() => img!.toByteData(format: ui.ImageByteFormat.png));
Directory(out).createSync(recursive: true);
File(p.join(out, 'player_${tag}_${lang}_$w.png')).writeAsBytesSync(bytes!.buffer.asUint8List());
}
expect(t.takeException(), isNull, reason: '$tag $lang $w 넘침');
final full = t.getRect(find.byTooltip(tr('전체 화면 (F)')));
expect(full.right <= w + 0.5, isTrue, reason: '$tag $lang $w: [전체 화면] 이 화면 안 ($full)');
for (final tip in [tr('재생 속도'), tr('자막 (S)'), tr('재생 목록 (L)')]) {
final r = t.getRect(find.byTooltip(tip));
expect(r.right <= w + 0.5, isTrue, reason: '$tag $lang $w: $tip 화면 안 $r');
}
}
}
// PlayerPage 가 닫힐 때 플레이어를 정리한다
await t.pumpWidget(const SizedBox());
await t.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 500)));
}
t.view.reset();
await t.runAsync(() => i18n.apply('ko', save: false));
}, timeout: const Timeout(Duration(minutes: 3)));
} }

View File

@ -1271,7 +1271,7 @@ class AppController extends ChangeNotifier {
bool internal = false, bool internal = false,
Future<void> Function(String program, List<String> videos)? external}) async { Future<void> Function(String program, List<String> videos)? external}) async {
// 29: 음악도 내장 플레이어로 (탐색기 메뉴의 "내장 플레이어로 재생") // 29: 음악도 내장 플레이어로 (탐색기 메뉴의 "내장 플레이어로 재생")
final videos = files.where((f) => isVideoFile(f) || isAudioFile(f)).toList(); final videos = files.where(isPlayableFile).toList();
if (videos.isEmpty) return null; if (videos.isEmpty) return null;
final ext = p.extension(videos.first).replaceFirst('.', '').toLowerCase(); final ext = p.extension(videos.first).replaceFirst('.', '').toLowerCase();
final program = settings.externalPlayers[ext]; final program = settings.externalPlayers[ext];

View File

@ -24,6 +24,22 @@ bool isVideoFile(String path) =>
bool isAudioFile(String path) => bool isAudioFile(String path) =>
audioExtensions.contains(p.extension(path).replaceFirst('.', '').toLowerCase()); audioExtensions.contains(p.extension(path).replaceFirst('.', '').toLowerCase());
// ── 재생 목록 모듈 (관리자 지시 10/21): 무엇을 한 목록에 넣을지는 여기서만 정한다. 화면 · 컨트롤러는 부르기만 ──
/// 내장 플레이어로 틀 수 있는 파일 (동영상 · 소리)
bool isPlayableFile(String path) => isVideoFile(path) || isAudioFile(path);
/// [other] 를 [chosen] 과 같은 재생 목록에 넣을지: 같은 종류끼리 (동영상끼리 · 소리끼리).
/// 예전에는 형제를 동영상으로만 걸러 mp3 를 틀면 같은 폴더의 다른 곡이 늘 빠졌다 ("폴더 전체" 여도 1/1)
bool samePlayKind(String chosen, String other) => isAudioFile(chosen) ? isAudioFile(other) : isVideoFile(other);
/// 폴더 하나를 틀 때의 목록 (이름 순): 동영상이 있으면 동영상, 없으면 소리 파일. 틀 것이 없으면 빈 목록
List<String> folderPlaylist(Iterable<String> files) {
final videos = files.where(isVideoFile).toList();
final list = videos.isNotEmpty ? videos : files.where(isAudioFile).toList();
return list..sort((a, b) => naturalCompare(p.basename(a), p.basename(b)));
}
/// 시리즈 비교용 이름: 숫자를 모두 # 으로 바꾼다. /// 시리즈 비교용 이름: 숫자를 모두 # 으로 바꾼다.
/// file_001 ≡ file_0002, Show.S01E02 ≡ Show.S02E10, 드라마 3화 ≡ 드라마 12화 /// file_001 ≡ file_0002, Show.S01E02 ≡ Show.S02E10, 드라마 3화 ≡ 드라마 12화
String seriesKey(String path) => p String seriesKey(String path) => p
@ -53,13 +69,13 @@ int naturalCompare(String a, String b) {
return ma.length.compareTo(mb.length); return ma.length.compareTo(mb.length);
} }
/// 파일 하나 → 재생 목록 (선택한 파일이 들어 있고, 이름 순) /// 파일 하나 → 재생 목록 (선택한 파일이 들어 있고, 이름 순). 형제는 고른 파일과 같은 종류만 ([samePlayKind])
/// 돌려주는 값: (목록, 선택한 파일의 위치) /// 돌려주는 값: (목록, 선택한 파일의 위치)
(List<String>, int) buildPlaylist(String file, Iterable<String> filesInFolder, PlaylistMode mode) { (List<String>, int) buildPlaylist(String file, Iterable<String> filesInFolder, PlaylistMode mode) {
if (mode == PlaylistMode.single) return ([file], 0); if (mode == PlaylistMode.single) return ([file], 0);
final key = seriesKey(file); final key = seriesKey(file);
final list = filesInFolder final list = filesInFolder
.where(isVideoFile) .where((f) => samePlayKind(file, f))
.where((f) => mode == PlaylistMode.folder || seriesKey(f) == key) .where((f) => mode == PlaylistMode.folder || seriesKey(f) == key)
.toList(); .toList();
if (!list.any((f) => p.equals(f, file))) list.add(file); if (!list.any((f) => p.equals(f, file))) list.add(file);

View File

@ -18,7 +18,7 @@ import '../app/transfer_job.dart';
import '../core/secret_gate.dart'; import '../core/secret_gate.dart';
import '../core/sync_tools.dart'; import '../core/sync_tools.dart';
import '../core/file_ops.dart'; import '../core/file_ops.dart';
import '../core/playlist.dart' show isAudioFile, isVideoFile; import '../core/playlist.dart' show folderPlaylist, isAudioFile, isPlayableFile, isVideoFile;
import '../core/vfs.dart'; import '../core/vfs.dart';
import '../core/sftp.dart' show SftpHostKeyException, SftpRegistry; import '../core/sftp.dart' show SftpHostKeyException, SftpRegistry;
import '../core/ftp.dart' show FtpCertException, FtpRegistry; import '../core/ftp.dart' show FtpCertException, FtpRegistry;
@ -2472,7 +2472,7 @@ class _ExplorerPageState extends State<ExplorerPage> {
case ExplorerButton.play: case ExplorerButton.play:
final t = _targets(pane); final t = _targets(pane);
// 181: 강조한 것이 mp3 등 소리 파일이어도 그것을 (예전에는 동영상이 아니라고 빼고 폴더의 동영상을 틀었다) // 181: 강조한 것이 mp3 등 소리 파일이어도 그것을 (예전에는 동영상이 아니라고 빼고 폴더의 동영상을 틀었다)
final videos = t.where((x) => !vIsDirSync(x) && (isVideoFile(x) || isAudioFile(x))).toList(); final videos = t.where((x) => !vIsDirSync(x) && isPlayableFile(x)).toList();
if (videos.isNotEmpty) { if (videos.isNotEmpty) {
await _play(videos, keepOrder: pane.marked.isNotEmpty); await _play(videos, keepOrder: pane.marked.isNotEmpty);
} else { } else {
@ -2557,13 +2557,14 @@ class _ExplorerPageState extends State<ExplorerPage> {
Future<void> _playFolder(String dir) async { Future<void> _playFolder(String dir) async {
final List<String> list; final List<String> list;
try { try {
list = (await listEntries(dir)).where((e) => !e.isDir && isVideoFile(e.path)).map((e) => e.path).toList(); // 재생 목록 모듈: 동영상이 없는 폴더 (음악 폴더) 는 소리 파일을
list = folderPlaylist([for (final e in await listEntries(dir)) if (!e.isDir) e.path]);
} catch (e) { } catch (e) {
_snack(trf('읽을 수 없습니다: {0}', [explainFileError('$e', dav: isDav(dir)).$1])); _snack(trf('읽을 수 없습니다: {0}', [explainFileError('$e', dav: isDav(dir)).$1]));
return; return;
} }
if (list.isEmpty) { if (list.isEmpty) {
_snack(tr('이 폴더에 동영상이 없습니다.')); _snack(tr('이 폴더에 재생할 동영상 · 소리 파일이 없습니다.'));
return; return;
} }
if (!mounted) return; if (!mounted) return;

View File

@ -15,6 +15,7 @@ import '../services/media_player.dart';
import 'app_actions.dart'; import 'app_actions.dart';
import 'audio_now_playing.dart'; import 'audio_now_playing.dart';
import 'dav_external.dart'; import 'dav_external.dart';
import 'row_fit.dart';
import 'theme.dart'; import 'theme.dart';
import '../l10n/tr.dart'; import '../l10n/tr.dart';
@ -462,57 +463,72 @@ class _PlayerPageState extends State<PlayerPage> {
Text(formatSrtTime(s.duration).substring(0, 8), Text(formatSrtTime(s.duration).substring(0, 8),
style: const TextStyle(fontSize: 12, color: Colors.white70, fontFamily: 'Consolas')), style: const TextStyle(fontSize: 12, color: Colors.white70, fontFamily: 'Consolas')),
]), ]),
// 손가락: 재생 버튼 줄과 나머지 (음량 · 자막 · 목록 · 전체 화면) 줄을 나눠 넉넉하게 // 손가락: 재생 버튼 줄과 나머지 (음량 · 자막 · 목록 · 전체 화면) 줄을 나눠 넉넉하게.
if (touch) // P2 (관리자 지시 10/21, 28 찾음): Windows 창 폭 412 에서 한 줄이 184px 넘쳐 속도 · 자막 · 목록 · 전체 화면이 잘렸다 -
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ // 한 줄에 들지 않으면 마우스여도 두 줄로. 단추는 기본 크기 그대로, 소리 막대만 남는 폭만큼 (최대 100)
LayoutBuilder(builder: (context, box) {
final bw = touch ? 48.0 : 40.0;
final menus = compact ? 0 : 3 + (s.audioTracks.length > 1 ? 1 : 0);
final restButtons = 1 + menus + (Platform.isAndroid ? 0 : 1) + 1;
final playButtons = compact ? 4 : 6;
final fit = fitRow(
maxWidth: box.maxWidth,
first: List.filled(playButtons, bw),
second: List.filled(restButtons, bw),
gap: 8,
flexMin: compact ? 0 : 48,
flexMax: compact ? 0 : 100,
forceSplit: touch,
);
final twoRows = fit.split;
final sliderWidth = fit.flexWidth;
final play = [
btn(Icons.skip_previous, tr('이전 (P)'), () => pl.previous()), btn(Icons.skip_previous, tr('이전 (P)'), () => pl.previous()),
btn(Icons.replay_10, tr('10초 뒤로 (←)'), () => _seekBy(-10)), if (!compact) btn(Icons.replay_10, tr('10초 뒤로 (←)'), () => _seekBy(-10)),
btn(s.playing ? Icons.pause_circle_filled : Icons.play_circle_fill, tr('재생/일시정지 (Space)'), btn(s.playing ? Icons.pause_circle_filled : Icons.play_circle_fill, tr('재생/일시정지 (Space)'),
() => pl.playOrPause(), size: 40), () => pl.playOrPause(), size: touch ? 40 : 34),
btn(Icons.stop, tr('정지'), () => pl.stop()), btn(Icons.stop, tr('정지'), () => pl.stop()),
btn(Icons.forward_10, tr('10초 앞으로 (→)'), () => _seekBy(10)), if (!compact) btn(Icons.forward_10, tr('10초 앞으로 (→)'), () => _seekBy(10)),
btn(Icons.skip_next, tr('다음 (N)'), () => pl.next()), btn(Icons.skip_next, tr('다음 (N)'), () => pl.next()),
]), ];
Row(children: [ final rest = [
if (!touch) ...[ btn(s.volume == 0 ? Icons.volume_off : Icons.volume_up, tr('음소거 (M)'), _toggleMute),
btn(Icons.skip_previous, tr('이전 (P)'), () => pl.previous()), if (sliderWidth > 0)
if (!compact) btn(Icons.replay_10, tr('10초 뒤로 (←)'), () => _seekBy(-10)), SizedBox(
btn(s.playing ? Icons.pause_circle_filled : Icons.play_circle_fill, tr('재생/일시정지 (Space)'), width: sliderWidth,
() => pl.playOrPause(), size: 34), child: Slider(value: s.volume.clamp(0, 100), max: 100, onChanged: (v) => pl.setVolume(v)),
btn(Icons.stop, tr('정지'), () => pl.stop()), ),
if (!compact) btn(Icons.forward_10, tr('10초 앞으로 (→)'), () => _seekBy(10)), const Spacer(),
btn(Icons.skip_next, tr('다음 (N)'), () => pl.next()), if (!compact) ...[
const SizedBox(width: 8), _menuButton(Icons.speed, tr('재생 속도'), [
], for (final r in const [0.5, 0.75, 1.0, 1.25, 1.5, 2.0])
btn(s.volume == 0 ? Icons.volume_off : Icons.volume_up, tr('음소거 (M)'), _toggleMute), (label: '${r}x', checked: s.rate == r, onTap: () => pl.setRate(r)),
if (!compact)
SizedBox(
width: 100,
child: Slider(value: s.volume.clamp(0, 100), max: 100, onChanged: (v) => pl.setVolume(v)),
),
const Spacer(),
if (!compact) ...[
_menuButton(Icons.speed, tr('재생 속도'), [
for (final r in const [0.5, 0.75, 1.0, 1.25, 1.5, 2.0])
(label: '${r}x', checked: s.rate == r, onTap: () => pl.setRate(r)),
]),
_menuButton(Icons.subtitles, tr('자막 (S)'), [
(label: tr('끄기'), checked: s.subtitleId == null, onTap: () => _setSub(null)),
for (final t in _subtitleChoices())
(label: t.label, checked: s.subtitleId == t.id, onTap: () => _setSub(t)),
]),
if (s.audioTracks.length > 1)
_menuButton(Icons.audiotrack, tr('음성'), [
for (final t in s.audioTracks)
(label: t.label, checked: s.audioId == t.id, onTap: () => pl.setAudioTrack(t)),
]), ]),
btn(Icons.playlist_play, tr('재생 목록 (L)'), () => setState(() => _showList = !_showList)), _menuButton(Icons.subtitles, tr('자막 (S)'), [
], (label: tr('끄기'), checked: s.subtitleId == null, onTap: () => _setSub(null)),
if (!Platform.isAndroid) for (final t in _subtitleChoices())
btn(_popup ? Icons.close_fullscreen : Icons.picture_in_picture_alt, _popup ? tr('팝업 끄기') : tr('팝업 보기'), (label: t.label, checked: s.subtitleId == t.id, onTap: () => _setSub(t)),
_togglePopup), ]),
btn(_full ? Icons.fullscreen_exit : Icons.fullscreen, tr('전체 화면 (F)'), _toggleFull), if (s.audioTracks.length > 1)
]), _menuButton(Icons.audiotrack, tr('음성'), [
for (final t in s.audioTracks)
(label: t.label, checked: s.audioId == t.id, onTap: () => pl.setAudioTrack(t)),
]),
btn(Icons.playlist_play, tr('재생 목록 (L)'), () => setState(() => _showList = !_showList)),
],
if (!Platform.isAndroid)
btn(_popup ? Icons.close_fullscreen : Icons.picture_in_picture_alt, _popup ? tr('팝업 끄기') : tr('팝업 보기'),
_togglePopup),
btn(_full ? Icons.fullscreen_exit : Icons.fullscreen, tr('전체 화면 (F)'), _toggleFull),
];
return Column(mainAxisSize: MainAxisSize.min, children: [
if (twoRows) Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: play),
Row(children: [
if (!twoRows) ...[...play, const SizedBox(width: 8)],
...rest,
]),
]);
}),
]), ]),
); );
}, },

33
lib/ui/row_fit.dart Normal file
View File

@ -0,0 +1,33 @@
/// 한 줄 · 두 줄 배치 판단 (관리자 지시 10/21: 화면마다 따로 재지 않고 이것 하나를 부른다 - d3 설계의 AdaptiveRow 자리).
///
/// 약속
/// - 입력: [maxWidth] 쓸 수 있는 폭, [first] · [second] 앞 · 뒤 묶음 아이템의 최소 폭 (단추는 기본 누를 자리 그대로),
/// [gap] 한 줄일 때 두 묶음 사이, 줄일 수 있는 아이템 하나의 폭 범위 [flexMin] ~ [flexMax] (없으면 0 · 0).
/// - 출력: [RowFit.split] 이면 두 줄 (위 = first, 아래 = second + 줄일 수 있는 아이템), [RowFit.flexWidth] 줄일 수 있는 아이템의 폭
/// (0 이면 그 줄에 넣지 않는다 - 같은 일을 하는 다른 단추가 남아 있어야 한다).
/// - 오류: 없음. 두 줄로도 [second] 가 들지 않으면 split = true · flexWidth = 0 이고 [RowFit.overflow] 에 모자란 폭.
class RowFit {
final bool split;
final double flexWidth;
final double overflow;
const RowFit(this.split, this.flexWidth, this.overflow);
}
RowFit fitRow({
required double maxWidth,
required List<double> first,
required List<double> second,
double gap = 0,
double flexMin = 0,
double flexMax = 0,
bool forceSplit = false,
}) {
double sum(List<double> xs) => xs.fold(0.0, (a, b) => a + b);
final a = sum(first), b = sum(second);
final split = forceSplit || a + gap + b + flexMax > maxWidth;
final room = maxWidth - b - (split ? 0 : a + gap);
var flex = room.clamp(0.0, flexMax);
if (flex < flexMin) flex = 0;
final over = (split ? [a, b].reduce((x, y) => x > y ? x : y) : a + gap + b) - maxWidth;
return RowFit(split, flex, over > 0 ? over : 0);
}

View File

@ -122,6 +122,13 @@ void main() {
expect(j, 1); expect(j, 1);
final (all, _) = buildPlaylist(f, files, PlaylistMode.folder); final (all, _) = buildPlaylist(f, files, PlaylistMode.folder);
expect(all, hasLength(7)); // 자막·텍스트 제외 expect(all, hasLength(7)); // 자막·텍스트 제외
// 재생 목록 모듈 약속 (관리자 지시 10/21): 형제는 고른 파일과 같은 종류만 - 소리를 고르면 소리끼리, 동영상이면 동영상끼리
final music = [for (final n in ['b.mp3', 'a.flac', 'c.mp4', 'd.txt']) p.join(dir, n)];
final (songs, s) = buildPlaylist(music.first, music, PlaylistMode.folder);
expect([songs.map(p.basename), s], [['a.flac', 'b.mp3'], 1]);
expect(buildPlaylist(music[2], music, PlaylistMode.folder).$1.map(p.basename), ['c.mp4']);
expect(folderPlaylist(music).map(p.basename), ['c.mp4'], reason: '폴더를 틀 때 동영상이 있으면 동영상');
expect(folderPlaylist([music[0], music[1], music[3]]).map(p.basename), ['a.flac', 'b.mp3'], reason: '없으면 소리');
}); });
test('끌어다 놓기: 동영상만, 폴더 안쪽, jj_ 출력 폴더 제외', () async { test('끌어다 놓기: 동영상만, 폴더 안쪽, jj_ 출력 폴더 제외', () async {