Android 我正在尝试播放SD卡上的音乐

Android 我正在尝试播放SD卡上的音乐,android,media-player,kotlin,Android,Media Player,Kotlin,//我正在尝试播放SD卡上的音乐,一个接一个,但我想在第一首音乐编译后播放第二首音乐。它应该自动发生。我是android新手,任何帮助都将不胜感激。使用给定代码。我会演奏音乐 class Play : AppCompatActivity() { var play: ImageView? = null var stop: ImageView? = null var AudioSavePathInDevice = "Blesson" var mediaPlayer

//我正在尝试播放SD卡上的音乐,一个接一个,但我想在第一首音乐编译后播放第二首音乐。它应该自动发生。我是android新手,任何帮助都将不胜感激。使用给定代码。我会演奏音乐

class Play : AppCompatActivity() {


    var play: ImageView? = null
    var stop: ImageView? = null
    var AudioSavePathInDevice = "Blesson"
    var mediaPlayer: MediaPlayer? = null




    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_play)

         play = findViewById(R.id.play) as ImageView
         stop = findViewById(R.id.stop) as ImageView

        play!!.setOnClickListener {

            play!!.visibility = View.INVISIBLE
            stop!!.visibility = View.VISIBLE

            val file = intent.extras["file"]
            for (hello in 1..3) {

                AudioSavePathInDevice = File("$file/bless$hello.mp3").toString()


            Toast.makeText(this, AudioSavePathInDevice, Toast.LENGTH_LONG).show()

                mediaPlayer = MediaPlayer()
                try {
                    mediaPlayer!!.setDataSource(AudioSavePathInDevice)
                    mediaPlayer!!.prepare()

                } catch (e: IOException) {
                    Toast.makeText(this, "Recoring not found",
                            Toast.LENGTH_LONG).show()
                }

                mediaPlayer!!.start()

                Toast.makeText(this, "Recording Playing",
                        Toast.LENGTH_LONG).show()

                mediaPlayer!!.setOnCompletionListener{}

                try {
                    mediaPlayer!!.stop()
                    mediaPlayer!!.release()
                }catch (ex: Exception){ }
            }


        }
    }

}

不,可能是重复的,完全不同question@blessonSamuel你能在github上建立一个示例项目吗?