Browse Source

update ExoPlayer

exoplayer 2.15.0 -> 2.17.1
develop
Jannik 3 months ago
parent
commit
7a860a7270
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 22
      app/src/main/java/org/mosad/teapod/ui/activity/player/PlayerViewModel.kt
  2. 2
      build.gradle

22
app/src/main/java/org/mosad/teapod/ui/activity/player/PlayerViewModel.kt

@ -31,11 +31,7 @@ import androidx.lifecycle.viewModelScope
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
import com.google.android.exoplayer2.source.hls.HlsMediaSource
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
import com.google.android.exoplayer2.util.Util
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.joinAll
import kotlinx.coroutines.launch
@ -60,8 +56,7 @@ import java.util.*
class PlayerViewModel(application: Application) : AndroidViewModel(application) {
private val classTag = javaClass.name
val player = SimpleExoPlayer.Builder(application).build()
private val dataSourceFactory = DefaultDataSourceFactory(application, Util.getUserAgent(application, "Teapod"))
val player = ExoPlayer.Builder(application).build()
private val mediaSession = MediaSessionCompat(application, "TEAPOD_PLAYER_SESSION")
val currentEpisodeChangedListener = ArrayList<() -> Unit>()
@ -196,7 +191,7 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
}
)
}
Log.i(classTag, "playback: ${currentEpisode.playback}")
Log.d(classTag, "playback: ${currentEpisode.playback}")
if (startPlayback) {
playCurrentMedia()
@ -226,16 +221,13 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
currentPlayback.streams.adaptive_hls.entries.first().value.url
}
}
Log.d(classTag, "stream url: $url")
Log.i(classTag, "stream url: $url")
// create the media source object
val mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(
MediaItem.fromUri(Uri.parse(url))
)
// the actual player playback code
player.setMediaSource(mediaSource)
// create the media item
val mediaItem = MediaItem.fromUri(Uri.parse(url))
player.setMediaItem(mediaItem)
player.prepare()
if (seekPosition > 0) player.seekTo(seekPosition)
player.playWhenReady = true
}

2
build.gradle

@ -2,7 +2,7 @@
buildscript {
ext.kotlin_version = "1.6.10"
ext.ktor_version = "1.6.8"
ext.exo_version = "2.15.0"
ext.exo_version = "2.17.1"
repositories {
google()
mavenCentral()

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close