我创建了这个函数来使按钮在我点击它时发出声音,声音文件是位于
raw/button_click.mp3
目录下的MP3。
fun play_sound(which_one:Int) {
if(which_one == 1){
val mediaPlayer:MediaPlayer? = MediaPlayer.create(Context,R.raw.button_click)
mediaPlayer?.start()
But i get the following error when i run it Unresolved reference: Context
How should I edit my code to solve this problem?
顺便说一下,现在先忽略if语句,它在这个发展阶段总是变成真的。