-1

我用了:

player = new MediaPlayer();
    try {
        player.setDataSource(str_stream_url);
        // player.setDataSource("http://cdn.concreteloop.com/wp-content/uploads/2011/01/Jennifer-Lopez-feat.-Pitbull-On-the-Floor.mp3");
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    player.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {

        public void onBufferingUpdate(MediaPlayer mp, int percent) {
            playSeekBar.setSecondaryProgress(percent);
            Log.i("Buffering", "" + percent);
        }
    });

它适用于 Android v4.0,但不适用于 Android 2.3.3 ..

我能做些什么??

谢谢。

4

1 回答 1

1

我也在 Android 2.3.3 中尝试过这段代码,但它没有用。最后你可以看到错误。

Uri myUri = Uri
            .parse("http://46.137.18.79:8000/;stream.nsv&type=mp3&autostart=true");

    player = new MediaPlayer();
    try {
        if (player == null) {
            this.player = new MediaPlayer();
        } else {
            player.stop();
            player.reset();
        }
        player.setDataSource(this, myUri); // Go to Initialized state
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.setOnPreparedListener(this);
        player.setOnBufferingUpdateListener(this);

        player.setOnErrorListener(this);
        player.prepareAsync();

        Log.d(TAG, "LoadClip Done");
    } catch (Throwable t) {
        Log.d(TAG, t.toString());
    }

02-06 13:49:03.730: E/MediaPlayer(2718): stop 在状态 1 中调用

02-06 13:49:03.730: E/MediaPlayer(2718): 错误 (-38, 0)

02-06 13:49:03.730: D/MediaPlayer(2718): 无法在客户端打开文件,正在尝试服务器端

02-06 13:49:03.870: D/MyMain(2718): LoadClip 完成

谢谢。

于 2013-02-06T11:52:04.703 回答