-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* play MP3 file on record - hard coded file name - minimum error check - Update launch.json - playAtRecord.mp3 * sleep 5s for MP3 file to load * Read and play a WAV - delay on start with W10 computers might be cancelled * Refactoring with SoundPlayer Class * Add *.csv in gitignore (but keep them in repo) - git update-index --skip-worktree data.csv - git update-index --skip-worktree marker.csv * Delete playAtRecord.mp3 * v1.3.0
- Loading branch information
Showing
5 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,3 +85,6 @@ Temporary Items | |
|
||
old/ | ||
*.dylib | ||
|
||
# do not track output files | ||
*.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package fr.lgi2p.digit.output; | ||
|
||
import java.io.File; | ||
import javax.sound.sampled.*; | ||
|
||
public class SoundPlayer { | ||
String fname = "playAtRecord.wav"; | ||
Clip soundPlayer = null; | ||
File audioFile = null; | ||
|
||
public SoundPlayer() { | ||
this.audioFile = new File(fname); | ||
|
||
if(audioFile.exists() && !audioFile.isDirectory()) { | ||
System.out.println("playAtRecord.wav found... "); | ||
try { | ||
soundPlayer = AudioSystem.getClip(); | ||
AudioInputStream audioIn = AudioSystem.getAudioInputStream(this.audioFile); | ||
soundPlayer.open(audioIn); | ||
|
||
System.out.println("playAtRecord.wav is loading... "); | ||
double secondsInAudio = (double) soundPlayer.getMicrosecondLength() / 1000000.0; | ||
System.out.println("playAtRecord.wav lasts " + secondsInAudio + " seconds"); | ||
} catch (Exception e) { | ||
System.err.println(e.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
public void start(){ | ||
if (soundPlayer != null) { | ||
soundPlayer.setMicrosecondPosition(0); | ||
soundPlayer.start(); | ||
} | ||
} | ||
|
||
public void stop(){ | ||
if (soundPlayer != null) { | ||
soundPlayer.stop(); | ||
} | ||
} | ||
|
||
public void resume(){ | ||
if (soundPlayer != null) { | ||
soundPlayer.start(); | ||
} | ||
} | ||
} |