I'm trying to fix a problem with Media Player seekTo() method which is called on a Forward/Rewind remote button press event, but I'm getting this error:
with the following edited smali trying to convert long parameter to int:
.method private static synthetic a(JLandroid/media/MediaPlayer;)V
.locals 1
long-to-int v0, p1
.line 317
invoke-virtual {p2, v0}, Landroid/media/MediaPlayer;->seekTo(I)V
return-void
.end method
How can I fix the error or is there any other way to make it work?
This is the original code (but when I press Forward or Rewind it just stops/pauses the video):
long-to-int p1, p0
.line 317
invoke-virtual {p2, p1}, Landroid/media/MediaPlayer;->seekTo(I)V
My temporary fix was this:
.method private static synthetic a(JLandroid/media/MediaPlayer;)V
.locals 3
#get current position
invoke-virtual {p2}, Landroid/media/MediaPlayer;->getCurrentPosition()I
move-result v0
#add some ms to current position register
const/16 v1, 0x6978
add-int v2,v0,v1
add-int v2,v2,v1
add-int v2,v2,v1
add-int v2,v2,v1
add-int v2,v2,v1
#seek to calculated position
.line 317
invoke-virtual {p2, v2}, Landroid/media/MediaPlayer;->seekTo(I)V
return-void
.end method
But it only seeks Forward even when I press Rewind (because I only add time to current position).
I couldn't find/create custom method for Rewind event, source is quite large and obfuscated.
Following the chain of error and chain of method call didn't lead me anywhere.
Since this is a static method, there is no implicit "this" argument, and the parameter registers start at p0
. So the first long argument is p0
,p1
, and the MediaPlayer
argument is p2
.
For the long-to-int
instruction (and most instructions that work with long values), you specify the wide value for it to work on by passing the first register in the wide register pair. In this case, that is p0
, not p1
.
The error is referring to the fact that you're passing the upper half of the wide register pair, instead of the lower half.
So, long-to-int v0, p0
is probably what you want.