This commit is contained in:
Thibault Deckers 2024-04-30 23:05:36 +02:00
parent 25598163a5
commit 2f8d870811

View file

@ -128,6 +128,7 @@ class MpvVideoController extends AvesVideoController {
if (path != null) { if (path != null) {
final videoBasename = _pContext.basenameWithoutExtension(path); final videoBasename = _pContext.basenameWithoutExtension(path);
// list subtitle files in the same directory // list subtitle files in the same directory
// some files may be visible to the app (e.g. SRT) while others may not (e.g. SUB, VTT)
_subscriptions.add(File(path).parent.list().where((v) => v is File && _isSubtitle(v.path)).listen((v) { _subscriptions.add(File(path).parent.list().where((v) => v is File && _isSubtitle(v.path)).listen((v) {
final subtitleBasename = _pContext.basename(v.path); final subtitleBasename = _pContext.basename(v.path);
if (subtitleBasename.startsWith(videoBasename)) { if (subtitleBasename.startsWith(videoBasename)) {
@ -403,12 +404,7 @@ class MpvVideoController extends AvesVideoController {
} }
} }
static bool _isSubtitle(String path) { static const Set<String> _subtitleExtensions = {'.srt', '.sub', '.vtt'};
switch (_pContext.extension(path)) {
case '.srt': static bool _isSubtitle(String path) => _subtitleExtensions.contains(_pContext.extension(path));
return true;
default:
return false;
}
}
} }