M mjcoon Well-Known Member Licensed User Feb 18, 2020 #1 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 Click to expand... with screen captures showing, while the project is paused just after the assignment: and I am baffled as to why an assignment without any casting is so wrong whereas with casting works fine... Mike.
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 Click to expand... with screen captures showing, while the project is paused just after the assignment: and 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 Feb 18, 2020 #2 Are you sure you're looking at duration after the assignment? - Colin. Upvote 0
M mjcoon Well-Known Member Licensed User Feb 19, 2020 #3 Computersmith64 said: Are you sure you're looking at duration after the assignment? - Colin. Click to expand... 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
Computersmith64 said: Are you sure you're looking at duration after the assignment? - Colin. Click to expand... 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.
Erel B4X founder Staff member Licensed User Longtime User Feb 19, 2020 #4 Hard to say without a small project that demonstrates it. Upvote 0
M mjcoon Well-Known Member Licensed User Feb 19, 2020 #5 Erel said: Hard to say without a small project that demonstrates it. Click to expand... It's not high priority because I have one or more work-arounds. But I will try to prepare a cut-down version that demonstrates the phenomenon. Mike. Upvote 0
Erel said: Hard to say without a small project that demonstrates it. Click to expand... It's not high priority because I have one or more work-arounds. But I will try to prepare a cut-down version that demonstrates the phenomenon. Mike.
M mjcoon Well-Known Member Licensed User Feb 23, 2020 #6 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)) Click to expand... 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
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)) Click to expand... 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.
Erel B4X founder Staff member Licensed User Longtime User Feb 24, 2020 #7 Please use [code]code here...[/code] tags when posting code. First step is to make the query yourself instead of using UpdateRecord2. Also add some log message to see where the value is "lost". Upvote 0
Please use [code]code here...[/code] tags when posting code. First step is to make the query yourself instead of using UpdateRecord2. Also add some log message to see where the value is "lost".