Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed an issue where removing a track from a playlist removed it from all playlists ([#69])
- Fixed playing files from directory with ".nomedia" ([#114])

## [1.6.0] - 2025-11-09
### Changed
Expand Down Expand Up @@ -99,6 +100,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#65]: https://github.com/FossifyOrg/Music-Player/issues/65
[#69]: https://github.com/FossifyOrg/Music-Player/issues/69
[#97]: https://github.com/FossifyOrg/Music-Player/issues/97
[#114]: https://github.com/FossifyOrg/Music-Player/issues/114
[#179]: https://github.com/FossifyOrg/Music-Player/issues/179
[#206]: https://github.com/FossifyOrg/Music-Player/issues/206
[#209]: https://github.com/FossifyOrg/Music-Player/issues/209
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ abstract class SimpleControllerActivity : SimpleActivity(), Player.Listener {

fun withPlayer(callback: MediaController.() -> Unit) = controller.withController(callback)

fun prepareAndPlay(tracks: List<Track>, startIndex: Int = 0, startPositionMs: Long = 0, startActivity: Boolean = true) {
fun prepareAndPlay(tracks: List<Track>, startIndex: Int = 0, startPositionMs: Long = 0, startActivity: Boolean = true, thirdPartyIntent: Boolean = false) {
withPlayer {
if (startActivity) {
startActivity(
Intent(this@SimpleControllerActivity, TrackActivity::class.java)
)
}

prepareUsingTracks(tracks = tracks, startIndex = startIndex, startPositionMs = startPositionMs, play = true) { success ->
prepareUsingTracks(tracks = tracks, startIndex = startIndex, startPositionMs = startPositionMs, play = true, thirdPartyIntent = thirdPartyIntent) { success ->
if (success) {
updatePlaybackInfo(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {
getTrackFromUri(intent.data) { track ->
runOnUiThread {
if (track != null) {
prepareAndPlay(listOf(track), startActivity = false)
prepareAndPlay(listOf(track), startActivity = false, thirdPartyIntent = isThirdPartyIntent)
} else {
toast(org.fossify.commons.R.string.unknown_error_occurred)
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.Player
import org.fossify.commons.helpers.ensureBackgroundThread
import org.fossify.musicplayer.helpers.FLAG_MANUAL_CACHE
import org.fossify.musicplayer.helpers.PlaybackSetting
import org.fossify.musicplayer.helpers.RESTART_ON_PREVIOUS_THRESHOLD
import org.fossify.musicplayer.models.Track
import org.fossify.musicplayer.models.toMediaItems
import org.fossify.musicplayer.models.toMediaItemsFast

val Player.isReallyPlaying: Boolean
Expand Down Expand Up @@ -138,6 +140,7 @@ fun Player.prepareUsingTracks(
startIndex: Int = 0,
startPositionMs: Long = 0,
play: Boolean = false,
thirdPartyIntent: Boolean = false,
callback: ((success: Boolean) -> Unit)? = null
) {
if (tracks.isEmpty()) {
Expand All @@ -147,7 +150,16 @@ fun Player.prepareUsingTracks(
return
}

val mediaItems = tracks.toMediaItemsFast()
val mediaItems = if(thirdPartyIntent) {
tracks.map { track ->
if (track.mediaStoreId == 0L) {
track.flags = track.flags or FLAG_MANUAL_CACHE
}
track.toMediaItem()
}
} else {
tracks.toMediaItemsFast()
}
runOnPlayerThread {
setMediaItems(mediaItems, startIndex, startPositionMs)
playWhenReady = play
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.fossify.musicplayer.R
import org.fossify.musicplayer.databinding.ViewCurrentTrackBarBinding
import org.fossify.musicplayer.extensions.*
import androidx.core.graphics.drawable.toDrawable
import org.fossify.musicplayer.helpers.FLAG_MANUAL_CACHE

class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
private val binding by viewBinding(ViewCurrentTrackBarBinding::bind)
Expand All @@ -33,7 +34,7 @@ class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLa

fun updateCurrentTrack(mediaItem: MediaItem?) {
val track = mediaItem?.toTrack()
if (track == null) {
if (track == null || track.flags == FLAG_MANUAL_CACHE) {
fadeOut()
return
} else {
Expand Down
Loading