mediaPlayer error -38,0

后端 未结 5 1825
梦如初夏
梦如初夏 2020-12-01 07:18

I try to do simple online radio player. Here is adress of stream http://radio-electron.ru:8000/96 Here is my code.

MyActivity.java

package com.exampl         


        
5条回答
  •  情歌与酒
    2020-12-01 07:48

    -38 refers to ENOSYS error code from errno.h (see this explanation https://stackoverflow.com/a/15206308/768935)

    You seem to try to start the playing before the preparation is complete. Use the setOnPreparedListener() method to set a preparation listener and call the start() method only after the preparation is complete.

    mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
      public void onPrepared(MediaPlayer mp) {
          mp.start();
      }
    });
    mediaPlayer.prepareAsync();
    

    And remove the current mediaPlayer.start() invocation from the code.

提交回复
热议问题