Web サイトからストリーミングするメディア プレーヤーを起動しようとしています。現在、「開始」を押すと、ストリームが接続されている間、アクティビティ全体が 5 ~ 20 秒間フリーズします。「player.start();」を取得しようとしています ストリームが接続している間にアクティビティを解放するためにスレッドで実行するように呼び出しますが、動作していません。誰にもアイデアはありますか?
private void startplayer() {
try {
stream_player = new MediaPlayer();
stream_player.setAudioStreamType(AudioManager.STREAM_MUSIC);
stream_player = MediaPlayer.create(this, Uri.parse("http://stream-address"));
Thread thread = new Thread(new Runnable() {
public void run() {
stream_player.start();
}
});
thread.start();
SetNotification(1, "live");
liveON = true;
} catch (Exception e) {
Log.e(getClass().getName(), "Error starting to stream audio.", e);
Toast.makeText(this, "Stream seems to be offline", Toast.LENGTH_LONG).show();
}
}