'How to get audio value for implementing into ViewPager2?

I learn the Android development and now I deep diving into the RecyclerView. I've already created some simple project with it. But for now I decided create the alphabet grid. The idea:
we have the grid of the Alphabet and when user click to the letter ViewPager2 open new page. I wanna add play button on this page. But I do not understand how to get audio file data class.

To display additional information on the card, I use:

import android.content.Context
import android.os.Parcelable
import com.vicsothemes.recyclerview.R
import kotlinx.android.parcel.Parcelize

@Parcelize
data class Letters(
    val id: Int,
    val banner: Int,
    val title: String,
    val description: String,
    val sample: String
    //val sound: @RawValue Any? = null

) : Parcelable {

    companion object {
        fun lettersList(context: Context): List<Letters> {
            return listOf(
                Letters(0, R.drawable.a,
                    context.getString(R.string.letter_a),
                    context.getString(R.string.about_letter_a),
                    context.getString(R.string.sample_apple)
                    //MediaPlayer.create(context, R.raw.a)
                ),
                Letters(1, R.drawable.bet,
                    context.getString(R.string.letter_b),
                    context.getString(R.string.about_letter_b),
                    context.getString(R.string.sample_beard)
                    //MediaPlayer.create(context, R.raw.a)
                )
           
            )
        }
    }
}

As you can see I tried to get audio already

MediaPlayer.create(context, R.raw.alef)

But as result I have the error. Please help me to figure out with this issue I can not get it by myself.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source