diff --git a/app/src/main/java/org/ntlab/amaryllis/client/VoiceTest.java b/app/src/main/java/org/ntlab/amaryllis/client/VoiceTest.java index 5f9937c..983812a 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/VoiceTest.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/VoiceTest.java @@ -40,7 +40,7 @@ //}; //再生開始&再生中止 - private void startPlay(){ + private void startPlay() { ImageView Stoping = findViewById(R.id.Stoping); ImageView Playing = findViewById(R.id.Playing); float Tmin = 0; @@ -48,19 +48,19 @@ //mp = new MediaPlayer(); //mp = MediaPlayer.create(this,R.raw.bgm); - if(mp.isPlaying()){ + if (mp.isPlaying()) { mp.stop();//再生を中断 //mp.pause();//途中から再生を再開したい時はこっちを使う必要があるかも Stoping.setAlpha(1.0f);//画像が見えるようにする処理 Playing.setAlpha(0.0f);//画像が見えないようにする処理 //try{ - //mp.prepare(); + //mp.prepare(); //}catch(IllegalStateException e){ - //e.printStackTrace(); + //e.printStackTrace(); //}catch(IOException e){ - //e.printStackTrace(); + //e.printStackTrace(); //} - }else { + } else { try { //mp = new MediaPlayer(); mp.setDataSource(file.getAbsolutePath());//再生するファイルを持ってくる @@ -68,7 +68,7 @@ //OutputStream filePath = openFileOutput("a",MODE_PRIVATE); //mp.setDataSource(filePath); mp.prepare(); - }catch(IllegalStateException e){ + } catch (IllegalStateException e) { e.printStackTrace(); //if(StartChange == 1){ @@ -103,7 +103,7 @@ } totalTime = mp.getDuration(); String S_totalTime = createTimeLabel(totalTime);//createTimeLabelにtotalTimeを渡す。 - TextView voiceTime = (TextView)findViewById(R.id.voiceTime); + TextView voiceTime = (TextView) findViewById(R.id.voiceTime); voiceTime.setText(S_totalTime); mp.seekTo(0); mp.start();//再生スタート @@ -113,21 +113,21 @@ } //totalTimeを分、秒に変換 - public String createTimeLabel(int time){ + public String createTimeLabel(int time) { String timeLabel = ""; - int min = time/1000/60; - int sec = time/1000%60; + int min = time / 1000 / 60; + int sec = time / 1000 % 60; timeLabel = min + ":"; - if(sec < 10) timeLabel += "0"; + if (sec < 10) timeLabel += "0"; timeLabel += sec; return timeLabel; } //録音開始&録音終了 - private void startRecord(){ + private void startRecord() { - if(StartChange == 0) { + if (StartChange == 0) { try { mr.stop(); mr.reset(); @@ -136,7 +136,7 @@ } catch (Exception e) { e.printStackTrace(); } - }else { + } else { try { mr = new MediaRecorder(); mr.setAudioSource(MediaRecorder.AudioSource.MIC); @@ -159,95 +159,94 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_voice_test); - file = new File(getFilesDir(),"Sample.3gp"); + file = new File(getFilesDir(), "Sample.3gp"); mp = new MediaPlayer(); - - Button Rokuon = (Button)findViewById(R.id.button2); - Rokuon.setOnClickListener(new View.OnClickListener(){ - public void onClick(View x){ - TextView textView1 = (TextView)findViewById(R.id.text); + Button Rokuon = (Button) findViewById(R.id.button2); + Rokuon.setOnClickListener(new View.OnClickListener() { + public void onClick(View x) { + TextView textView1 = (TextView) findViewById(R.id.text); textView1.setText("Rokuon Start!"); startRecord(); } }); - Button RTeisi = (Button)findViewById(R.id.button3); - RTeisi.setOnClickListener(new View.OnClickListener(){ - public void onClick(View x){ - TextView textView1 = (TextView)findViewById(R.id.text); - textView1.setText("Rokuon Stop!"); - //stopRecord(); - } - }); + //Button RTeisi = (Button)findViewById(R.id.button3); + //RTeisi.setOnClickListener(new View.OnClickListener(){ + //public void onClick(View x){ + //TextView textView1 = (TextView)findViewById(R.id.text); + //textView1.setText("Rokuon Stop!"); + //stopRecord(); + //} + //}); - Button Saisei = (Button)findViewById(R.id.button4); + Button Saisei = (Button) findViewById(R.id.button4); //Saisei.setAlpha(0); - Saisei.setOnClickListener(new View.OnClickListener(){ - public void onClick(View x){ - TextView textView1 = (TextView)findViewById(R.id.text); + Saisei.setOnClickListener(new View.OnClickListener() { + public void onClick(View x) { + TextView textView1 = (TextView) findViewById(R.id.text); textView1.setText("Saisei Start!"); startPlay(); } }); - Button STeisi = (Button)findViewById(R.id.button5); - STeisi.setOnClickListener(new View.OnClickListener(){ - public void onClick(View x){ - TextView textView1 = (TextView)findViewById(R.id.text); - textView1.setText("Saisei Stop!"); - //stopPlay(); - } - }); - } + //Button STeisi = (Button)findViewById(R.id.button5); + //STeisi.setOnClickListener(new View.OnClickListener(){ + //public void onClick(View x){ + //TextView textView1 = (TextView)findViewById(R.id.text); + //textView1.setText("Saisei Stop!"); + //stopPlay(); + //} + //}); + //} - //private Handler handler = new Handler(){ + //private Handler handler = new Handler(){ //@Override //public void handleMessage(Message msg){ - //int currentPosition = msg.what; + //int currentPosition = msg.what; - //再生位置を更新 - //positionBar.setProgress(currentPositon); + //再生位置を更新 + //positionBar.setProgress(currentPositon); - //経過時間ラベル更新 - //String elapsedTime = createTimeLabel(currentPosition); - //elapseTimeLabel.setText(elapsedTime); + //経過時間ラベル更新 + //String elapsedTime = createTimeLabel(currentPosition); + //elapseTimeLabel.setText(elapsedTime); - //残り時間ラベル更新 - //String remainingTime = createTimeLabel(totalTime - currentPosition); - //remainingTimeLabel.setText("-" + remainingTime); + //残り時間ラベル更新 + //String remainingTime = createTimeLabel(totalTime - currentPosition); + //remainingTimeLabel.setText("-" + remainingTime); //} - //}; + //}; - - //再生停止 - //private void stopPlay(){ + //再生停止 + //private void stopPlay(){ //try{ - //mp.stop(); - //mp.prepare(); - //mp.release(); + //mp.stop(); + //mp.prepare(); + //mp.release(); //}catch(IllegalStateException e){ - //e.printStackTrace(); + //e.printStackTrace(); //}catch(Exception e){ - //e.printStackTrace(); + //e.printStackTrace(); //} - //} + //} - //録音終了 - //private void stopRecord(){ + //録音終了 + //private void stopRecord(){ //try{ - //mr.stop(); - //mr.reset(); - //mr.release(); + //mr.stop(); + //mr.reset(); + //mr.release(); //}catch(Exception e){ - //e.printStackTrace(); + //e.printStackTrace(); //} - //} + //} + } }