java


Java audio doesn't play in jar file


with netbeans i've created a JFrame with 3 buttons wich let me start a wav sound file loop it or stop it. If i launch it from netbeans it works perfectly but if i launch jar file it doesn't work
What's wrong?
Here the code
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
private AudioData audiodata;
private AudioDataStream audiostream;
private ContinuousAudioDataStream continuousaudiostream;
public NewJFrame() throws FileNotFoundException, IOException {
initComponents();
FileInputStream fis = new FileInputStream("boing.wav");
AudioStream audioStream = new AudioStream(fis);
audiodata = audioStream.getData();
audiostream = null;
continuousaudiostream = null;
}
public void play() {
audiostream = new AudioDataStream(audiodata);
AudioPlayer.player.start(audiostream);
}
public void loop() {
continuousaudiostream = new ContinuousAudioDataStream(audiodata);
AudioPlayer.player.start(continuousaudiostream);
}
public void stop() {
if (audiostream != null)
AudioPlayer.player.stop(audiostream);
if (continuousaudiostream != null)
AudioPlayer.player.stop(continuousaudiostream);
}
}
The play(), loop() and stop() methods are invoked by my 3 buttons. My "boing.wav" file is inside my project folder, i tried also put it into /src/"boing.wav" but never works launching jar file.
What should i do?
This might be something to do with your jdk or sound card. The code looks ok, tho. Try uninstalling and reinstalling the jdk. Also, test the app on a different system and let's know what the response is.

Related Links

winrun4j auto detect JVM
My switch statement s not compiling [closed]
Spring autowire multiple service Implementations
Can't connect to jboss server - Operation failed with status WAITING
How to implement websocket with Struts 2
How many memory copies do object variables in Python have? [duplicate]
Android- ActionBar AutoCompleteTextview
Alternative to Font.createFont()?
Java BufferedReader.readLine() returning null when reading file
Class<T> and class keyword in Java
Changing an array input to a display a letter such as “X” or “O”
About java Timer
In spring mvc, how to link to another jsp using #RequestMapping?
Java Triangle class, getArea method constantly returning 0.0? [duplicate]
While loop printing incorrectly
Java Concurrency Issues concerning Listeners

Categories

HOME
atom-editor
webpack
reflection
tizen
drivers
comparison
gis
graphql
rdf
sqlite3
webpack-2
facebook-messenger-bot
amazon-cloudformation
nstableview
jplayer
alignment
leiningen
fortumo
percona
jsprit
http-status-code-504
text-rendering
ehcache
graphicsmagick
language-agnostic
php-openssl
hammerspoon
dynamic-featured-image
ping
file-rename
r-raster
code-contracts
perlin-noise
webtest
mozilla
http-referer
cloud-code
mpmediaquery
bytecode-manipulation
x11-forwarding
hockeyapp
streamsets
twitch
az-application-insights
ensembles
reportingservices-2005
janrain
nxlog
termination
veracode
mplayer
forever
slickedit
np-complete
zendesk-app
topbeat
wdf
static-ip-address
color-picker
probability-density
url-masking
pcf
jwplayer7
testng-dataprovider
itextpdf
hsv
vhd
ora-00900
t4mvc
pundit
twirl
splash
createprocessasuser
fluid-dynamics
p2
codeigniter-url
preferences
googlemock
terminfo
has-many-through
mysqltuner
inbox
blending
qt-faststart
ocunit
cassini-dev
e4x
hamiltonian-cycle
propertyeditor
appconkit
regsvr32
assembly-loading
work-stealing
nsdatecomponents
gnu-prolog
hirefire
pyinotify
iphone-web-app
phonon
data-acquisition
paul-graham

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App