izderadicka / audioserve-android

Android client for audioserve
67 stars 11 forks source link

Android app playback position not saved #12

Closed Phytophthora closed 4 years ago

Phytophthora commented 4 years ago

Using the android app I'm able to get the position from the web client. But when I use the web client after using the android app I'm not able to get the last position. In the server log I get entries like the following when using the android app: [2020-05-24T07:17:43Z ERROR audioserve::services::position] Position message error: Position is not a number [2020-05-24T07:17:45Z ERROR audioserve::services::position] Position message error: Position is not a number

I'm using the static build from release v0.12.1.1 as server. Android app version v. 0.8.4

izderadicka commented 4 years ago

Would it be possible to get debug log from server and logcat from android application? For server you will need to compile into debug release and run with RUST_LOG=audioserve=debug environment variable.

Phytophthora commented 4 years ago

logcat_05-24-2020_12-27-15.txt

I have a logcat log but compiling doesn't work for me. I wasn't able in the first place, thats why I sticked to the static build in the release until I figured out why.

izderadicka commented 4 years ago

From logcat this seem a bit relevant: [05-24 12:24:18.638 22261:22261 D/RecentAdapter] Updating audio/1Q84/Buch 1 & 2/1Q84.m4b/011 - 012$$3452412-3868560$$.m4b with zero position!

as handling of m4b is bit special could you please check if same problem happens for mp3, opus ?

Phytophthora commented 4 years ago

Same behaviour with a mp3 audiobook. Mai 24 15:02:20 audiobook audioserve[20790]: [2020-05-24T13:02:20Z ERROR audioserve::services::position] Position message error: Position is not a number Mai 24 15:02:24 audiobook audioserve[20790]: [2020-05-24T13:02:24Z ERROR audioserve::services::position] Position message error: Position is not a number

logcat_05-24-2020_15-02-46.txt

Phytophthora commented 4 years ago

short Update on this: I now managed to build audioserve now (server didn't have enough ram). However I don't know if I did right compiling into debug release. Still get the same messages (was running audioserve with -d option before and now).

Phytophthora commented 4 years ago

Finally I've got something usefull: audioserver_debug_20200524_17.txt logcat_05-24-2020_19-38-42.txt

When I compare for example line 18 (while using android app) with line 32 (while using web client) I cansee, that the message text from the android got an "," while the message from the web client got an "."

EDIT: Seems to be the German locale of my phone. If I set it from English (Germany) to English (United States) it send the message in the right format and playback position is safed correctly.

izderadicka commented 4 years ago

Thanks - yes it looks like locale problem, clearly bug in message formatting

izderadicka commented 4 years ago

This should be the problematic function

 private fun encodeMessage(filePath: String, position: Double):String =
        lastFile.let {
            fun fmt(p:Double) = "%.3f".format(p)
            return if (it == filePath) {
                "${fmt(position)}|"
            } else {
                lastFile = filePath
                val normedPath = mediaIdToPositionPath(filePath, group!!)
                "${fmt(position)}|${normedPath}"
            }
        }

Checking if format is locale dependent

izderadicka commented 4 years ago

Does this branch fix problem? https://github.com/izderadicka/audioserve-android/tree/fix-position-formating

Phytophthora commented 4 years ago

Could you provide the apk for testing? I have no build environment for android apps.

izderadicka commented 4 years ago

Released v0.8.5 with this fix - please confirm that it works now

Phytophthora commented 4 years ago

It's working now. Thank you.