Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ data class BaseItem(

override val gridId get() = id.toString()

/**
* Whether the remote's play button plays this item from a grid. Playlists play as a whole, like
* the Play option in their context menu.
*/
override val playable: Boolean
get() = type.playable
get() = type.playable || type == BaseItemKind.PLAYLIST

override val sortName: String
get() = data.alphabetSortName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class PlaylistCreator
startIndex: Int?,
sortAndDirection: SortAndDirection,
filter: GetItemsFilter,
startAtNextUnwatched: Boolean = false,
): Playlist {
val request =
filter.applyTo(
Expand All @@ -103,7 +104,14 @@ class PlaylistCreator
),
)
val items = GetItemsRequestHandler.execute(api, request).content.items
return Playlist(items.convertAndAddParts())
// Skip items already watched, unless everything has been watched
val firstUnwatched =
if (startAtNextUnwatched) {
items.indexOfFirst { it.userData?.played != true }.coerceAtLeast(0)
} else {
0
}
return Playlist(items.drop(firstUnwatched).convertAndAddParts())
}

private suspend fun createFromCollection(
Expand Down Expand Up @@ -161,6 +169,7 @@ class PlaylistCreator
shuffled: Boolean = false,
recursive: Boolean = false,
filter: GetItemsFilter = GetItemsFilter(),
startAtNextUnwatched: Boolean = false,
): PlaylistCreationResult =
when (item.type) {
BaseItemKind.BOX_SET,
Expand Down Expand Up @@ -284,6 +293,7 @@ class PlaylistCreator
)
},
filter = filter,
startAtNextUnwatched = startAtNextUnwatched && !shuffled,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import com.github.damontecres.wholphin.services.RefreshRateService
import com.github.damontecres.wholphin.services.ScreensaverService
import com.github.damontecres.wholphin.services.StreamChoiceService
import com.github.damontecres.wholphin.services.UserPreferencesService
import com.github.damontecres.wholphin.ui.data.SortAndDirection
import com.github.damontecres.wholphin.ui.formatBitrate
import com.github.damontecres.wholphin.ui.gt
import com.github.damontecres.wholphin.ui.isNotNullOrBlank
Expand Down Expand Up @@ -358,6 +359,10 @@ class PlaybackViewModel
item = queriedItem,
recursive = true,
shuffled = shuffled,
// Play server playlists in their own order instead of sorted by name
sortAndDirection =
if (queriedItem.type == BaseItemKind.PLAYLIST) null else SortAndDirection.DEFAULT,
startAtNextUnwatched = true,
)
}
when (val r = playlistResult) {
Expand Down