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

How to fix Invalid Content-Type:text/html in SOAP client using Java
How to setup log4j 2 in Net Beans?
how do I solve this error Exception in thread “main” java.lang.NoClassDefFoundError: javax/crypto/SecretKey
MapFish print error
Active Directory Password without SSL java
ListView not returning to exact scroll position
Can I attach to Apache HttpClient cookies from Google Chrome or Firefox?
Java hasNext() and element() Implementation in While Loop
Rules due to Annotations with JSON and Spring
Reading data from file at start to use in controller in Spring Boot
How do I choose an specific file of my file Array List?
Migrating setLibraryPaths method from 0.6.8 version
Save pdf report on database using BIRT
I want solution regarding twitter4j ads api. I searched it over stackoverflow and other sites but I unabled to get solution
Why does my Jose4j JSON Web Key cause this InvalidKeyException?
Can apache Heron be run on windows

Categories

HOME
isabelle
c#-4.0
razor
analysis
tizen-web-app
rdf
ip
session-variables
user-input
etl
resize
vb.net-2010
zebra-printers
tostring
jsdoc
propel
dcevm
emgucv
opennlp
microsoft-sync-framework
traffic
strncpy
ping
msys2
create-table
jspresso
wpf-controls
file-format
hot-module-replacement
mixture-model
impersonation
dynamic-reports
jvm-languages
node-gyp
botbuilder
eigenvalue
total-commander
s
node-sass
jsch
smartcontracts
git-diff
brightcove
carrot
slickedit
directory-structure
libusb-win32
namecoin
removechild
intrusion-detection
hill-climbing
hover-over
uid
responsive-images
twirl
sailfish-os
apache-commons-fileupload
generic-programming
unity3d-gui
block-device
jscript.net
codeigniter-url
tt-news
winddk
java.util.concurrent
onactivityresult
wp-query
industrial
quantlib-swig
inbox
google-cloud-save
odata4j
ora-00911
type-equivalence
coderush
datawindow
blackberry-playbook
gin
exchange-server-2003
zune
ubuntu-9.04
document-conversion

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