Android Question Integer versus Long

mjcoon

Well-Known Member
Licensed User
I am getting the duration of a media file in ExoPlayer and writing it to an SQL d/b.

Originally I put the duration in an Int variable before writing it to the d/b via a Map (using DBUtils). It worked fine.

Then I noticed that "duration" in class SimpleExoPlayer is defined as "Long" (as is "position", naturally enough) so I changed my variables to Long.

But now I find when debugging my code I see the following:
Dim duration As Long
...
duration = player1.duration
with screen captures showing, while the project is paused just after the assignment:

player.duration=.png


and

duration=.png


I am baffled as to why an assignment without any casting is so wrong whereas with casting works fine...

Mike.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Are you sure you're looking at duration after the assignment?

- Colin.
 
Upvote 0

mjcoon

Well-Known Member
Licensed User
Are you sure you're looking at duration after the assignment?

- Colin.

Thanks for that thought Colin, but I am absolutely certain. I didn't initially discover the problem by single-stepping like that, but by the consequence. You can just see the following "sql.ExecuteNonQuery2("INSERT..." call that writes file detail, including the duration, into the d/b. It was by using a sqlite browser to look at the file that I discovered that records inserted after I made the code change had the anomalous field value whereas earlier records were OK. I didn't say all that because I expected readers to believe my assertions! ;-)

Mike.
 
Upvote 0

mjcoon

Well-Known Member
Licensed User
I still don't have a "cut-down" version that displays my problem, but found that my work-around is not reliable either!

The snippet of code concerned is:
Dim updateFields As Map = CreateMap("duration": Starter.player1.duration, "sequence": maxSeq, "inplaylist": 1)
rowId = rowMap.Get("rowid")
DBUtils.UpdateRecord2(Starter.sql, "FilesList", updateFields, CreateMap("rowid" : rowId))

Note: this code is not exactly the same as the earlier example of the problem. Earlier was an sql INSERT whereas this one is a different part of the same sub with DBUtils.UpdateRecord2 and no use of "Long" casting.

The observation is of what is written to the d/b for the "duration" field. Consistently, if free-running under control of the debugger the d/b field is set to the largest negative Long value as shown in my screen-shots above (though, strangely, that was single-stepping as I said). Whereas if I single-step through the code the field value is correct. I would be happier if the distinction was the other way round!

Mike.
 
Upvote 0
Top