minor fixes
* fix current language is set to preferred and not to actual language * fix player episodes lists sometimes missing the play icon
This commit is contained in:
parent
489ef02a35
commit
31197a5d44
@ -10,8 +10,8 @@ android {
|
||||
applicationId "org.mosad.teapod"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 2100 //00.02.100
|
||||
versionName "0.2.92"
|
||||
versionCode 2900 //00.02.900
|
||||
versionName "0.3.0-RC1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
resValue "string", "build_time", buildTime()
|
||||
|
@ -33,6 +33,7 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||
val dataSourceFactory = DefaultDataSourceFactory(application, Util.getUserAgent(application, "Teapod"))
|
||||
|
||||
val currentEpisodeChangedListener = ArrayList<() -> Unit>()
|
||||
val preferredLanguage = if (Preferences.preferSecondary) Locale.JAPANESE else Locale.GERMAN
|
||||
|
||||
var media: Media = Media(-1, "", DataTypes.MediaType.OTHER)
|
||||
internal set
|
||||
@ -56,8 +57,8 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
|
||||
currentEpisode = media.getEpisodeById(episodeId)
|
||||
currentLanguage = if (Preferences.preferSecondary) Locale.JAPANESE else Locale.GERMAN
|
||||
nextEpisode = selectNextEpisode()
|
||||
currentLanguage = currentEpisode.getPreferredStream(preferredLanguage).language
|
||||
}
|
||||
|
||||
fun setLanguage(language: Locale) {
|
||||
@ -94,12 +95,14 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
||||
* updateWatchedState for the next (now current) episode
|
||||
*/
|
||||
fun playEpisode(episode: Episode, replace: Boolean = false, seekPosition: Long = 0) {
|
||||
val preferredStream = episode.getPreferredStream(currentLanguage)
|
||||
currentLanguage = preferredStream.language // update current language, since it may have changed
|
||||
currentEpisode = episode
|
||||
nextEpisode = selectNextEpisode()
|
||||
currentEpisodeChangedListener.forEach { it() } // update player gui (title)
|
||||
|
||||
val mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(
|
||||
MediaItem.fromUri(Uri.parse( episode.getPreferredStream(currentLanguage).url))
|
||||
MediaItem.fromUri(Uri.parse(preferredStream.url))
|
||||
)
|
||||
playMedia(mediaSource, replace, seekPosition)
|
||||
|
||||
|
@ -40,8 +40,10 @@ class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerVi
|
||||
}
|
||||
|
||||
// hide the play icon, if it's the current episode
|
||||
if (currentSelected == position) {
|
||||
holder.binding.imageEpisodePlay.visibility = View.GONE
|
||||
holder.binding.imageEpisodePlay.visibility = if (currentSelected == position) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user