当我更改音频流站时,Android应用程序会变慢

当我更改音频流站时,Android应用程序会变慢,android,performance,audio,stream,media-player,Android,Performance,Audio,Stream,Media Player,我希望有人能帮我 这里有一个很棘手的问题:我有一个带有两个频道的icecast服务器。我开发了一个应用程序来收听这些电台,但当我从一个电台切换到另一个电台时,应用程序变得非常慢 以下是更改电台的代码: public static void setAndPlay(MediaPlayer player, String source) { player.reset(); try { player.setDataSource(source);

我希望有人能帮我

这里有一个很棘手的问题:我有一个带有两个频道的icecast服务器。我开发了一个应用程序来收听这些电台,但当我从一个电台切换到另一个电台时,应用程序变得非常慢

以下是更改电台的代码:

public static void setAndPlay(MediaPlayer player, String source) {
        player.reset();
        try {
            player.setDataSource(source);
            player.prepare();
        } catch (IOException e) {
            //TODO: handle exception
        }
}
下面是mediaPlayer启动的时间:

player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            public void onPrepared(MediaPlayer player) {
                player.start();
            }
        });
main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <Button
  android:text="Play"
  android:id="@+id/play"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"></Button>
 <Button
  android:text="Pause"
  android:id="@+id/pause"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"></Button>
 <Button
  android:text="Stop"
  android:id="@+id/stop"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"></Button>
</LinearLayout>

player.reset()的作用是什么?reset()之后,对象就像刚刚创建的一样。也许这会有帮助,您可以在这里找到它:谢谢,它解决了部分问题。现在应用程序不会变慢,但我需要音乐更快地启动。我该怎么做?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <Button
  android:text="Play"
  android:id="@+id/play"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"></Button>
 <Button
  android:text="Pause"
  android:id="@+id/pause"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"></Button>
 <Button
  android:text="Stop"
  android:id="@+id/stop"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"></Button>
</LinearLayout>