Я пытаюсь получить URL из firebase и передать его mediaplayer.setDataSource, но я получаю сообщение об ошибке: - `
java.lang.IllegalStateException
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:991)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:944)
at mks.master.musest.home$onCreateView$16$1$1.onDataChange(home.kt:425)
at com.firebase.client.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:45)
at com.firebase.client.core.view.DataEvent.fire(DataEvent.java:45)
at com.firebase.client.core.view.EventRaiser$1.run(EventRaiser.java:38)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5019)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
`
вот мой код: -
`var mediaplayer:MediaPlayeria
mediaplayer=MediaPlayer()
firebase= Firebase(link+"song2song")
firebase.addValueEventListener(object:ValueEventListener{
override fun onCancelled(p0: FirebaseError?) {
}
override fun onDataChange(p0: DataSnapshot) {
mediaplayer.setDataSource(p0.getValue(String()::class.java))
mediaplayer.prepareAsync()
}
})`
и основная ошибка в этой части mediaplayer.setDataSource(p0.getValue(String()::class.java))