fix(music): convert SAF content:// downloads for gapless arming
setNext() appended raw content:// URIs that mpv cannot open, stalling playback at the SD-card-download track boundary. Convert to fdclose:// like open(), track the armed fd, and reclaim it via a new closeContentFd method when the entry is dropped unplayed (close only when provably unconsumed — playlist-pos 0 before and after the remove; leak on doubt). The playlist-pos pre-check also keeps the clear path from removing the playing entry when mpv rolls into the armed track mid-clear. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4de38f4b17
commit
73be8ab1c8
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
/// Installs mock method/event channel handlers for a native player for the
|
||||
/// duration of [testBody], then removes them.
|
||||
Future<void> withMockPlayerChannels({
|
||||
required String methodChannelName,
|
||||
required String eventChannelName,
|
||||
Future<Object?> Function(MethodCall call)? methodHandler,
|
||||
Future<Object?> Function(MethodCall call)? eventHandler,
|
||||
required Future<void> Function() testBody,
|
||||
}) async {
|
||||
final messenger = TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
final methodChannel = MethodChannel(methodChannelName);
|
||||
final eventChannel = MethodChannel(eventChannelName);
|
||||
|
||||
messenger.setMockMethodCallHandler(
|
||||
methodChannel,
|
||||
methodHandler ??
|
||||
(call) async {
|
||||
switch (call.method) {
|
||||
case 'initialize':
|
||||
return true;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
);
|
||||
messenger.setMockMethodCallHandler(eventChannel, eventHandler ?? (call) async => null);
|
||||
|
||||
try {
|
||||
await testBody();
|
||||
} finally {
|
||||
messenger.setMockMethodCallHandler(methodChannel, null);
|
||||
messenger.setMockMethodCallHandler(eventChannel, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user