Add option to display extended episode title (SXX:EXX - Title) in player (#78)

* Add option to display extended episode title (SXX:EXX - Title) in player

* ocd fix

* add null check condition

* Move setting to player category

Yeah this would fit in either Appearance or Player. But I lean more towards Player.

Co-authored-by: Jarne Demeulemeester <jarnedemeulemeester@gmail.com>
This commit is contained in:
NIK679 2022-02-12 21:45:05 +05:30 committed by GitHub
parent f2b090d09b
commit 3f37318c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 4 deletions

View file

@ -11,5 +11,7 @@ data class PlayerItem(
val mediaSourceId: String,
val playbackPosition: Long,
val mediaSourceUri: String = "",
val parentIndexNumber: Int? = null,
val indexNumber: Int? = null,
val item: DownloadItem? = null
) : Parcelable

View file

@ -70,6 +70,8 @@ fun loadDownloadedEpisodes(downloadDatabase: DownloadDatabaseDao): List<PlayerIt
mediaSourceId = "",
playbackPosition = it.playbackPosition ?: 0,
mediaSourceUri = File(defaultStorage, it.id.toString()).absolutePath,
parentIndexNumber = it.parentIndexNumber,
indexNumber = it.indexNumber,
item = it
)
}
@ -95,6 +97,8 @@ fun getDownloadPlayerItem(downloadDatabase: DownloadDatabaseDao, itemId: UUID):
"",
metadata.playbackPosition!!,
file.absolutePath,
metadata.parentIndexNumber,
metadata.indexNumber,
metadata
)
}

View file

@ -185,7 +185,15 @@ constructor(
try {
for (item in items) {
if (item.itemId.toString() == player.currentMediaItem?.mediaId ?: "") {
_currentItemTitle.value = item.name.orEmpty()
if (sp.getBoolean(
"display_extended_title",
false
) && item.parentIndexNumber != null && item.indexNumber != null && item.name != null
)
_currentItemTitle.value =
"S${item.parentIndexNumber}:E${item.indexNumber} - ${item.name}"
else
_currentItemTitle.value = item.name.orEmpty()
}
}
jellyfinRepository.postPlaybackStart(UUID.fromString(mediaItem?.mediaId))

View file

@ -171,20 +171,26 @@ class PlayerViewModel @Inject internal constructor(
name = name,
itemId = id,
mediaSourceId = mediaSource.id!!,
playbackPosition = playbackPosition
playbackPosition = playbackPosition,
parentIndexNumber = parentIndexNumber,
indexNumber = indexNumber
)
MediaProtocol.HTTP -> PlayerItem(
name = name,
itemId = id,
mediaSourceId = mediaSource.id!!,
mediaSourceUri = mediaSource.path!!,
playbackPosition = playbackPosition
playbackPosition = playbackPosition,
parentIndexNumber = parentIndexNumber,
indexNumber = indexNumber
)
else -> PlayerItem(
name = name,
itemId = id,
mediaSourceId = mediaSource.id!!,
playbackPosition = playbackPosition
playbackPosition = playbackPosition,
parentIndexNumber = parentIndexNumber,
indexNumber = indexNumber
)
}
}

View file

@ -118,4 +118,6 @@
<string name="player_controls_skip">Skip</string>
<string name="track_selection">[%1$s] %2$s (%3$s)</string>
<string name="add_server_empty_error">Empty server address</string>
<string name="display_extended_title_summary">Display extended episode title including season and episode information (SXX:EXX - EpisodeName).</string>
<string name="display_extended_title">Display extended title</string>
</resources>

View file

@ -53,6 +53,10 @@
app:key="mpv_disable_hwdec"
app:summary="@string/force_software_decoding_summary"
app:title="@string/force_software_decoding" />
<SwitchPreference
app:key="display_extended_title"
app:summary="@string/display_extended_title_summary"
app:title="@string/display_extended_title" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/settings_category_device">