1
0
mirror of https://gitlab.com/agosto182/p2play synced 2024-12-12 08:56:20 +01:00

Fix buffer, forward and rewind video

This commit is contained in:
Ivan Agosto 2024-04-05 21:44:56 -06:00
parent 8856984dc3
commit 96d8ae19c6

View File

@ -19,7 +19,9 @@ import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.media3.common.MediaItem import androidx.media3.common.MediaItem
import androidx.media3.exoplayer.DefaultLoadControl
import androidx.media3.exoplayer.ExoPlayer import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.upstream.DefaultAllocator
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
@ -114,9 +116,19 @@ class ReproductorActivity : AppCompatActivity() {
AsyncTask.execute { AsyncTask.execute {
val video = this.clientVideo.getVideo(this.video.uuid) val video = this.clientVideo.getVideo(this.video.uuid)
// TODO: Make this configurable
val bufferSize = 1024 * 1024 // 1mb
val allocator = DefaultAllocator(true, bufferSize)
val loadControl = DefaultLoadControl.Builder()
.setAllocator(allocator)
.build()
runOnUiThread { runOnUiThread {
try { try {
player = ExoPlayer.Builder(this.baseContext).build() player = ExoPlayer.Builder(this.baseContext)
.setSeekBackIncrementMs(10000)
.setSeekForwardIncrementMs(10000)
.setLoadControl(loadControl).build()
exoPlayer.player = player exoPlayer.player = player
println("----- video --------") println("----- video --------")