Skip to content

Commit

Permalink
Merge pull request #43 from enteraname74/develop
Browse files Browse the repository at this point in the history
v0.10.2
  • Loading branch information
enteraname74 authored Jan 3, 2025
2 parents 3eb1017 + 54c1e8a commit 71f4a3f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion desktopApp/io.github.enteraname74.soulsearching.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ modules:
- cp -ru * /app
sources:
- type: archive
path: build/distributions/soulsearching-0.10.0-linux.tar.gz
path: build/distributions/soulsearching-0.10.2-linux.tar.gz
- type: file
path: src/main/composeResources/drawable/app_icon_bg.png
- type: file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ import org.koin.core.component.inject
* Service used for the playback.
*/
class PlayerService : Service(), KoinComponent {
private val musicNotification: SoulSearchingAndroidNotification by inject()

override fun onBind(p0: Intent?): IBinder? {
return null
}

@SuppressLint("UnspecifiedRegisterReceiverFlag")
@Suppress("Deprecation")
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.i("Player service", "ON START COMMAND")
ServiceCompat.startForeground(
Expand Down Expand Up @@ -65,7 +62,8 @@ class PlayerService : Service(), KoinComponent {
}
}

companion object {
companion object : KoinComponent {
private val musicNotification: SoulSearchingAndroidNotification by inject()
const val RESTART_SERVICE = "RESTART_SERVICE"
const val SERVICE_BROADCAST = "SERVICE_BROADCAST"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import java.io.File

/**
Expand All @@ -30,6 +32,7 @@ class SoulSearchingAndroidPlayerImpl(
private var isOnlyLoadingMusic: Boolean = false
private var positionToReachWhenLoadingMusic: Int = 0
private val audioManager: PlayerAudioManager = PlayerAudioManager(context, this)
private val mutex = Mutex()
// private val normalizer: AndroidPlayerNormalizer = AndroidPlayerNormalizer()

private val _state: MutableStateFlow<Boolean> = MutableStateFlow(false)
Expand All @@ -55,20 +58,24 @@ class SoulSearchingAndroidPlayerImpl(
this.listener = listener
}

override fun setMusic(music: Music) {
override suspend fun setMusic(music: Music) {
try {
player.stop()
player.reset()
} catch (_: Exception) {
}
if (File(music.path).exists()) {
player.setDataSource(music.path)
if (File(music.path).exists()) {
mutex.withLock {
player.setDataSource(music.path)
}

// CoroutineScope(Dispatchers.IO).launch {
// val volumeMultiplier: Float = normalizer.getVolumeMultiplier(music = music) ?: return@launch
// println("Multiplier: $volumeMultiplier")
// val newVolume: Float = 0.5f * volumeMultiplier
// setPlayerVolume(newVolume)
// }
}
} catch (e: Exception) {
Log.e("PLAYER", "UNABLE TO SET MUSIC. GOT ERROR: ${e.message}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class PlaybackManager : KoinComponent, SoulSearchingPlayer.Listener {
* Load the current music of the player view model.
* The music will not be played.
*/
fun onlyLoadMusic(seekTo: Int = 0, music: Music) {
private suspend fun onlyLoadMusic(seekTo: Int = 0, music: Music) {
player.setMusic(music = music)
player.onlyLoadMusic(seekTo = seekTo)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface SoulSearchingPlayer {
/**
* Set a song to the player.
*/
fun setMusic(music: Music)
suspend fun setMusic(music: Music)

/**
* Load the current music without playing it.
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
accompanist = "0.28.0"
accompanist-system-ui-controller = "0.30.1"
agp = "8.5.2"
android-version-code = "26"
android-version-code = "27"
android-target-sdk = "34"
android-compile-sdk = "34"
android-min-sdk = "26"
Expand All @@ -11,7 +11,7 @@ androidx-core = "1.13.1"
androidx-lifecycle = "2.8.7"
annotation = "1.9.1"
appcompat = "1.7.0"
application-version-name = "0.10.1"
application-version-name = "0.10.2"
coil = "3.0.0-alpha01"
compose = "1.7.0"
coroutines-core = "1.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ actual object AppVersion {
""
}

actual val versionName = "0.10.1$suffix"
actual val versionName = "0.10.2$suffix"
}

0 comments on commit 71f4a3f

Please sign in to comment.