Skip to content

Commit

Permalink
Merge pull request #27 from enteraname74/develop
Browse files Browse the repository at this point in the history
v0.5.0-1
  • Loading branch information
enteraname74 authored May 1, 2024
2 parents a354403 + 00b0fad commit c7cb8b7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The color palette used for the application is based on the theme of your device

<div align="center">
<img title="" src="screenshots/theme_settings_system.png" alt="" data-align="center" width="270">
    <img title="" src="screenshots/main_dark_theme.png" alt="" data-align="center" width="270">
<img title="" src="screenshots/main_dark_theme.png" alt="" data-align="center" width="270">
<img title="" src="screenshots/main_light_theme.png" alt="" data-align="center" width="270">
</div>

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ accompanist = "0.28.0"
accompanist-system-ui-controller = "0.30.1"
agp = "8.2.1"
android-version-name = "0.5.0"
android-version-code = "14"
android-version-code = "15"
android-target-sdk = "34"
android-compile-sdk = "34"
android-min-sdk = "26"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PlaybackManagerAndroidImpl(
}

override fun setAndPlayMusic(music: Music) {
if (shouldInit) init()

if (shouldLaunchService) launchService()

super.setAndPlayMusic(music)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ class SoulSearchingAndroidPlayerImpl(
}

override fun setMusic(music: Music) {
player.stop()
player.reset()
try {
player.stop()
player.reset()
} catch (_: Exception) {}
if (File(music.path).exists()) {
player.setDataSource(music.path)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,24 @@ abstract class PlaybackManager(
removeSongFromPlayedPlaylist(musicId = musicId)
}

/**
* Make the initial list the same as the played list.
* The match will only occurs if the player mode is set to NORMAL.
*/
private fun matchInitialListToPlayedListIfNormalPlayerMode() {
if (_playerMode == PlayerMode.NORMAL) {
initialList = playedList.map { it.copy() } as ArrayList<Music>
}
}

/**
* Remove a song from the current playlist.
* If no songs are left in the played list, the playback will stop.
*/
fun removeSongFromPlayedPlaylist(musicId: UUID) {
val actualIndex = currentMusicIndex
playedList.removeIf { it.musicId == musicId }
matchInitialListToPlayedListIfNormalPlayerMode()

// If no songs is left in the queue, stop playing :
if (playedList.isEmpty()) {
Expand Down Expand Up @@ -447,23 +458,28 @@ abstract class PlaybackManager(
return
}
}

// We make sure to remove the music if it's already in the playlist :
playedList.removeIf { it.musicId == music.musicId }

// If the current playlist is empty, we load the music :
if (playedList.isEmpty()) {
playedList.add(music)
callback.onPlayedListUpdated(
playedList = playedList
)
init()
setNewCurrentMusicInformation(music)
onlyLoadMusic()
} else {
// Finally, we add the new next music :
playedList.add(currentMusicIndex + 1, music)
callback.onPlayedListUpdated(
playedList = playedList
)
}

// We make sure to remove the music if it's already in the playlist :
playedList.removeIf { it.musicId == music.musicId }

// Finally, we add the new next music :
playedList.add(currentMusicIndex + 1, music)

callback.onPlayedListUpdated(
playedList = playedList
)

matchInitialListToPlayedListIfNormalPlayerMode()
savePlayedList()
settings.saveCurrentMusicInformation(
currentMusicIndex = currentMusicIndex,
Expand Down Expand Up @@ -578,6 +594,8 @@ abstract class PlaybackManager(
* Set and play a Music.
*/
open fun setAndPlayMusic(music: Music) {
if (shouldInit) init()

currentMusic = music

settings.setInt(
Expand Down

0 comments on commit c7cb8b7

Please sign in to comment.