Use null seek parameter on method channel
This commit is contained in:
parent
c0f7feeee8
commit
841bd10822
|
@ -267,14 +267,8 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
|
|||
result.success(null);
|
||||
break;
|
||||
case "seek":
|
||||
Object position = args.get(0);
|
||||
long position2;
|
||||
if (position instanceof Integer) {
|
||||
position2 = (Integer) position;
|
||||
} else {
|
||||
position2 = (Long) position;
|
||||
}
|
||||
seek(position2 == -2 ? C.TIME_UNSET : position2, result);
|
||||
Long position = getLong(args.get(0));
|
||||
seek(position == null ? C.TIME_UNSET : position, result);
|
||||
break;
|
||||
case "dispose":
|
||||
dispose();
|
||||
|
@ -533,6 +527,10 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
|
|||
sendError("abort", "Connection aborted");
|
||||
}
|
||||
|
||||
public static Long getLong(Object o) {
|
||||
return (o == null || o instanceof Long) ? (Long)o : new Long(((Integer)o).intValue());
|
||||
}
|
||||
|
||||
enum PlaybackState {
|
||||
none,
|
||||
stopped,
|
||||
|
|
|
@ -74,7 +74,8 @@
|
|||
[self setAutomaticallyWaitsToMinimizeStalling:(BOOL)[args[0] boolValue]];
|
||||
result(nil);
|
||||
} else if ([@"seek" isEqualToString:call.method]) {
|
||||
[self seek:[args[0] intValue] result:result];
|
||||
int position = args[0] == [NSNull null] ? -2 : [args[0] intValue];
|
||||
[self seek:position result:result];
|
||||
result(nil);
|
||||
} else if ([@"dispose" isEqualToString:call.method]) {
|
||||
[self dispose];
|
||||
|
|
|
@ -441,8 +441,7 @@ class AudioPlayer {
|
|||
/// any state except for [AudioPlaybackState.none] and
|
||||
/// [AudioPlaybackState.connecting].
|
||||
Future<void> seek(final Duration position) async {
|
||||
await _invokeMethod(
|
||||
'seek', [position != null ? position.inMilliseconds : -2]);
|
||||
await _invokeMethod('seek', [position?.inMilliseconds]);
|
||||
}
|
||||
|
||||
/// Release all resources associated with this player. You must invoke this
|
||||
|
|
Loading…
Reference in New Issue