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
1 changed files with 13 additions and 1 deletions

View File

@ -19,7 +19,9 @@ import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.media3.common.MediaItem
import androidx.media3.exoplayer.DefaultLoadControl
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.upstream.DefaultAllocator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
@ -114,9 +116,19 @@ class ReproductorActivity : AppCompatActivity() {
AsyncTask.execute {
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 {
try {
player = ExoPlayer.Builder(this.baseContext).build()
player = ExoPlayer.Builder(this.baseContext)
.setSeekBackIncrementMs(10000)
.setSeekForwardIncrementMs(10000)
.setLoadControl(loadControl).build()
exoPlayer.player = player
println("----- video --------")