public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (media_player_ye_state.get(index) == false) {
media_player_ye_state.set(index, true);
if (media_player_ye_filePath.get(index) == "") {
media_player_ye[index] = MediaPlayer.create(
mContext, raw);
} else {
media_player_ye[index] = new MediaPlayer();
try {
media_player_ye[index]
.setDataSource(media_player_ye_filePath
.get(index));
} catch (Exception e) {
e.printStackTrace();
}
}
media_player_ye[index]
.setOnPreparedListener(mPreparedListener);
media_player_ye[index].setVolume(
media_player_ye_Volume, media_player_ye_Volume);
media_player_ye[index].setLooping(true); // 반복재생
alButton.get(buttonNum).setPressed(true);
try {
media_player_ye[index].prepare();
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
case MotionEvent.ACTION_UP:
alButton.get(buttonNum).setPressed(false);
media_player_ye_state.set(index, false);
try {
media_player_ye[index].release();
} catch (Exception e) {
media_player_ye[index] = null;
e.printStackTrace();
}
return true;
}
return false;
}
'Programming > Android' 카테고리의 다른 글
Android Studio 1.4 and OpenCV 3.0.0 연동 (0) | 2015.12.19 |
---|---|
Media Player 토글 버튼 (Toggle 시 재생) (0) | 2015.11.16 |
MediaPlayer Source 선택 (0) | 2015.11.16 |
Android APK 추출 툴 (0) | 2014.03.07 |
Android 화면 크기 읽기, dpi, inch, cm (0) | 2014.03.02 |