어디가 문젠지... 다윈서버를 어떤식으로 사용해야되는지도 잘 모르겠고..(구축은 잘 되었는데 지정된 디렉토리에 음악 파일을 넣으려니까 음악파일이 안들어갑니다... 헤더부분을 어떻게 해야된다는데..)
감사합니다.
package com.example.mstest;
import java.io.IOException;
import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
MediaPlayer mPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.play).setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
mPlayer = new MediaPlayer();
String music_uri = "rtsp://192.168.0.2/sample.mp3";
Uri uri = Uri.parse(music_uri);
// mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(getApplicationContext(), uri);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
}
mPlayer.start();
}
});
}
public void onDestroy() {
super.onDestroy();
if (mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
}
}