joaco bona
joaco bona

Reputation: 1

Animation while playing media with ExoPlayer

so im trying to make a video player that plays media on a fraction of the screen while the remaining fraction of the screen shows different images. I am trying to tackle this using animation list:

<?xml version="1.0" encoding="utf-8"?>
<animation-list android:id="@+id/sequence"
    android:oneshot="false"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/folder_icon" android:duration="200" />
    <item android:drawable="@drawable/play_icon" android:duration="200" />

</animation-list>

I was able to set the layout so that I can see a single image and the exoplayer view, but im not being able to play the animation. Im not sure where (and how) should I put the command animation.start() and where should I declare the variable sequenceanimation: AnimationDrawable

I´ve tried declaring the variable as a companion object and as a private lateinit var in my activity. Also I tried setting the animation.start() command in onCreate but it's not working. When I try something along the lines, it messes up my entire code, it stops showing you the list of videos in your local storage and it jumps directly to the exoplayer/animation activity without working.

Upvotes: 0

Views: 210

Answers (1)

joaco bona
joaco bona

Reputation: 1

I don´t know if someone is having the same problem but I was able to solve it by placing the line animation.start() on onStart.

override fun onStart() {
    super.onStart()
    val rocketImage = findViewById<ImageView>(R.id.animacion).apply {
        setBackgroundResource(R.drawable.prueba_animacion)
        secuenciaAnimation = background as AnimationDrawable
    }
    secuenciaAnimation.start()
}

Upvotes: 0

Related Questions