support seeking to end of live streams (#108)

* support seeking to end of live streams

suggested edit for #96

* fix type casting
This commit is contained in:
LKHO 2020-06-07 14:31:36 +08:00 committed by GitHub
parent ee0c4cd7cd
commit f66413c007
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 11 deletions

View file

@ -268,11 +268,13 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
break;
case "seek":
Object position = args.get(0);
long position2;
if (position instanceof Integer) {
seek((Integer)position, result);
position2 = (Integer)position;
} else {
seek((Long)position, result);
position2 = (Long)position;
}
seek(position2 == -2 ? C.TIME_UNSET : position2, result);
break;
case "dispose":
dispose();
@ -336,7 +338,7 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
private long getCurrentPosition() {
if (state == PlaybackState.none || state == PlaybackState.connecting) {
return 0;
} else if (seekPos != null) {
} else if (seekPos != null && seekPos != C.TIME_UNSET) {
return seekPos;
} else {
return player.getCurrentPosition();