4

这是我试图播放音频但没有运气的链接。

我的代码是:

MediaPlayer player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
    player.setDataSource("http://www.nomadicsmart.com/co-notes/files/testsong_20_sec.mp3");
    //   player .prepare();
    player.prepareAsync();
    player.setOnPreparedListener(new OnPreparedListener() { 
        public void onPrepared(MediaPlayer mp) {
            Log.d("f","media3");
            mp.seekTo(0);
            mp.start();
        }
    });
    //  player .seekTo(0);
    } catch (IllegalArgumentException e1) {
        e1.printStackTrace();
    } catch (SecurityException e1) {
        e1.printStackTrace();
    } catch (IllegalStateException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }
4

0 回答 0