multiplatform: voice playing fix (#3046)

This commit is contained in:
Stanislav Dmitrenko 2023-09-11 22:32:31 +03:00 committed by GitHub
parent 5fddf64adb
commit 4b88a2abfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View File

@ -134,7 +134,7 @@ actual object AudioPlayer: AudioPlayerInterface {
// Returns real duration of the track
private fun start(fileSource: CryptoFile, seek: Int? = null, onProgressUpdate: (position: Int?, state: TrackState) -> Unit): Int? {
val absoluteFilePath = getAppFilePath(fileSource.filePath)
val absoluteFilePath = if (fileSource.isAbsolutePath) fileSource.filePath else getAppFilePath(fileSource.filePath)
if (!File(absoluteFilePath).exists()) {
Log.e(TAG, "No such file: ${fileSource.filePath}")
return null
@ -272,10 +272,10 @@ actual object AudioPlayer: AudioPlayerInterface {
}
}
override fun duration(filePath: String): Int? {
override fun duration(unencryptedFilePath: String): Int? {
var res: Int? = null
kotlin.runCatching {
helperPlayer.setDataSource(filePath)
helperPlayer.setDataSource(unencryptedFilePath)
helperPlayer.prepare()
helperPlayer.start()
helperPlayer.stop()

View File

@ -2089,6 +2089,10 @@ data class CryptoFile(
val filePath: String,
val cryptoArgs: CryptoFileArgs?
) {
val isAbsolutePath: Boolean
get() = File(filePath).isAbsolute
companion object {
fun plain(f: String): CryptoFile = CryptoFile(f, null)
}

View File

@ -29,7 +29,7 @@ interface AudioPlayerInterface {
fun stop(fileName: String?)
fun pause(audioPlaying: MutableState<Boolean>, pro: MutableState<Int>)
fun seekTo(ms: Int, pro: MutableState<Int>, filePath: String?)
fun duration(filePath: String): Int?
fun duration(unencryptedFilePath: String): Int?
}
expect object AudioPlayer: AudioPlayerInterface

View File

@ -42,7 +42,7 @@ actual object AudioPlayer: AudioPlayerInterface {
/*LALAL*/
}
override fun duration(filePath: String): Int? {
override fun duration(unencryptedFilePath: String): Int? {
/*LALAL*/
return null
}