[help]ABOUT play sound
CFURLRef myURLRef;
myURLRef = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
CFSTR("/aif.aif") ,
kCFURLPOSIXPathStyle,
FALSE);
OSStatus error = AudioServicesCreateSystemSoundID (myURLRef, &mySSID);
this code can play sound in the root directory.
but how can I play the sound in the resource Bundle?
thanks a lot
OK, I find it
CFBundleRef mainBundle = CFBundleGetMainBundle();
// Look for a resource in the main bundle by name and type.
myURLRef = CFBundleCopyResourceURL( mainBundle,
CFSTR("fun"),
CFSTR("aif"),
NULL );
if you have some question, MSN me: [email protected]
Similar Messages
-
Help with playing sound in applications
im new to java and i was practicing playing sound in a swing application but the problem is that when i press the play button no sound is played...here is my code
import javax.swing.*;
import java.applet.AudioClip;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.io.File;
public class JukeBox extends JFrame {
private JLabel label;
private JPanel panel, buttonPanel;
private JComboBox playList;
private JButton play, stop;
private URL url1, url2, url3, url4, url5, url6;
private AudioClip[] musicList;
private AudioClip current ;
public JukeBox() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 120);
setLocation(50, 50);
setTitle("JAVA JukeBox");
url1 = url2 = url3 = url4 = url5 = url6 = null;
current = null;
try {
url1 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\bottle-open.wav");
url2 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\BP2.mp3");
url3 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\fhm.aiff");
url4 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\jungle.rmf");
url5 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\spacemusic.au");
url6 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\trippygaia.mid");
} catch (MalformedURLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
musicList = new AudioClip[7];
musicList[0] = null;
musicList[1] = JApplet.newAudioClip(url1);
musicList[2] = JApplet.newAudioClip(url2);
musicList[3] = JApplet.newAudioClip(url3);
musicList[4] = JApplet.newAudioClip(url4);
musicList[5] = JApplet.newAudioClip(url5);
musicList[6] = JApplet.newAudioClip(url6);
label = new JLabel("JAVA JukeBox", JLabel.CENTER);
String[] musicList = {"select a track..."
, "bottle open"
, "bitch please II"
, "flutte, harmonica, mambo"
, "jungle"
, "spacemusic"
, "trippygaia"};
playList = new JComboBox(musicList);
playList.addActionListener(new ListListener());
play = new JButton("Play");
play.setActionCommand("play");
play.addActionListener(new ButtonListener());
stop = new JButton("Stop");
stop.addActionListener(new ButtonListener());
buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.add(play);
buttonPanel.add(stop);
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(label);
panel.add(Box.createRigidArea(new Dimension(0, 5)));
panel.add(playList);
panel.add(Box.createRigidArea(new Dimension(0, 5)));
panel.add(buttonPanel);
getContentPane().add(panel);
private class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if(current != null){
current.stop();
if(e.getActionCommand().equalsIgnoreCase("play")){
if(current != null){
current.play();
private class ListListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (current != null) {
current.stop();
current = musicList[playList.getSelectedIndex()];
public static void main(String[] args) {
setDefaultLookAndFeelDecorated(true);
JukeBox jb = new JukeBox();
jb.setVisible(true);
jb.setResizable(false);
}can u please tell me whats wrong with my code coz i cant hear no sound when i press the play button and can u please tell me why i cant simply put the file name in the URL instead of the complete path although the files are in the same directory of the source code and can i play mp3 using this little program ???
plz help...im a newbie so plz explain as much as u can...After
musicList = new AudioClip[7];
musicList[0] = null;
musicList[1] = JApplet.newAudioClip(url1);
musicList[2] = JApplet.newAudioClip(url2);
musicList[3] = JApplet.newAudioClip(url3);
musicList[4] = JApplet.newAudioClip(url4);
musicList[5] = JApplet.newAudioClip(url5);
musicList[6] = JApplet.newAudioClip(url6);initialise the variable current with
current = musicList[1];or similar because the AudioClip current always == null in your code so your listener blocks don`t execute.
regards -
Help on Play Sound File.vi - file format
Hello,
My request is quiet simple but I don't understand why it doesn't work.
I want read a .wav sound file with the Play Sound File vi. But when I run the vi, an error message appears " Cannot recognize sound format"
I have tried with different .wav sound files but nothing works.
Do you know why this error happens ?
Thanks
Attachments:
Sound_Labview.png 142 KBOk thanks.
Since the last time I posted I've tried many other wav sounds but nothing works I still had the same Labview error.
I join you few of my wav files and maybe you can try it.
Thanks
Attachments:
wav.zip 160 KB -
Help about Creative SOUND BLASTER AWE 64 & video card Creative 3D BLASTER VooDoo2 12
Hi All. I really need your help!
I am hoping you can help me out with these problems.
My PC configuration is: ) Pentium II 266 Mhz; 2) OS Windows98 SE; 3) Creative SOUND BLASTER AWE 64; 4) video card TRIDENT 3D IMAGE 9850 AGP; 5) video card Creative 3D BLASTER VooDoo2 2 MB 3DFX; 6) external modem Creative BLASTER FLASH 56K DE5720 V.90.
I reformatted my pc but now:
. I have NO Sound at all and the Icon for sound is missing from the system tray. When I go to control panel and system properties I have this message: "BIOS reports pheripherial resources wrongly (error code 9)", but I have original drivers on Creative cd!!
2. Modem doesn't work and when I go to control panel and system properties I have this message: "modem drivers are NOT installed (error code 28). Reinstall drivers". I have reinstalled the original drivers (Creative cd!!) but it doesn?t work at all.
3. System doesn?t recognize Creative 3D BLASTER VooDoo 2; it doesn't exist for my pc!!
Thank you for your time.He has got an PCI system, so it should be PNP compatible. Migth be Interupt sharing. Try to stick that card into another slot. First only Graphic card. Reinstall Win98SE. Then install !ALL! updates for win98. install the AWE card. Download VXD drivers (NOT WDM!!!) and install them. VXD drivers can be found under windows updates /?Windows ME / driver section. Yeah, i hope this is right : WinME!! (had an AWE32, but its a?few years after i had downloaded these drivers.
Put in your Voodoo card. maybe this card is dead, but it might work if you try it in every slot? (dont move your graphic- card). Good luck. If finished, do the same with your modem, what you did on your Voodoo card. Maybe some parts wont work anymore, because these things are really old and some components on them (capacitors) may have running dead meanwhile.Modem issues: i know that com/3 or com2/4 isnt working on Pentium PC's so try beetween them.
Message Edited by fffcmad on 02-23-200709:5 PM -
Hi there,
I want to play a sound file without the dependence
on any web browser. Below is my simple Java code.
When I test it on DOS prompt, it can play the desired
sound file. However, the system keep hanging after
the play of the sound. Can anyone tell me what's
the problem of my code? Alternatively, is there any
better Java code (not applet) to play a sound file?
import java.io.*;
import java.net.*;
import java.applet.*;
public class testAudio{
public static void main(String args[]){
try{
URL baseURL = new URL("file:" + System.getProperty("user.dir") + "/");
String relativeURL = "spacemusic.au"; // any audio file you want to play
URL completeURL = new URL(baseURL, relativeURL);
System.out.println(completeURL);
AudioClip sound = Applet.newAudioClip(completeURL);
if (sound == null) {
System.out.println("Sound " + relativeURL + " not loaded yet.");
sound.play();
catch (MalformedURLException e){
System.err.println(e.getMessage());
Thanks a bunch,
- JohnUsing this method to play a sound spawns a thread that plays the sound (so the app isn't blocked until the sound finishes). Doing this stops the app from terminating (much like if you created a Frame object). You can use System.exit(0); to force an application termination. I've found using AudioClip to very bug-prone. Its much better to use the javax.swing packages:
http://java.sun.com/products/java-media/sound/index.html -
[help] about iMac Sound device
I want to know how can i setting up in Window 7 and my Osx to recording sound and my voice in the same time
in Window 7 it doesnt have a recording too .. and how iMac setting pls help meWhat is the model of your notebook? Have you tried updating the latest Audio driver from www.hp.com?
Although I am an HP Employee, I am speaking for myself and not for HP.
Make it easier for other people to find solutions, by marking my answer “Accept as Solution” if it solves your problem. -
Help! My phone will not play sound when an app is open?!
Seemingly out of the blue, my iPhone stopped playing sound through the external speaker. This began about a month or two ago and I have been unable to fix the problem. The sound will play through the external speaker until I open another app (safari, camera, etc.). The sound used to work through headphones until this morning. Now the sound won't work... At all! I brought my phone to an apple store a week ago and the first guy checked my phone with a flashlight and told me first that there didn't seem to be any water damage. Then, some other technician helped me. He opened iTunes and miraculously, the song played! I couldn't believe it was magically working. He explained that it looked like my dock connector was looking a little eroded and that is why the sound doesn't work. He said he could try to brush it out and that should fix the problem. Tried my phone later... Volume doesn't work anymore! The dock connector works fine otherwise, I am still able to charge my phone. My phone will not play music via bluetooth speaker. I talked to multiple people on the phone who all seem to think it's a software problem... I am really not understanding what is going on with my phone! I have googled this problem many times in the last few months and most people say that it turned out to be a software issue. I have checked both water indicators (in the dock connector and the headphone plug, right?) with a flashlight and I don't see any red... Any insight or ways to fix this would be very appreciated! The whole thing makes no sense to me.
Are you using an APple charger or a thrid-party one? I ask because if you are using a third party charger, it may not be wired properly and it may be telling your iPhone that the cable connected is also an audio interface so your iPhone may be sending the audio signals through the cable to the charger. I have a charger in my truck that also doubles as an FM transmitter so I can play my iPhone audio through the truck radio. Your charger may be doing something similar, especially if it is not an Apple charger.
-
Multimedia Speaker System will not play sound.. Please help me!!!
Hello every body. (I'm not so good at english) I has a problem. My Creative Inspire 4.1 4400 will not play sound. Only at of 4, I can hear musik(or sound). Yesterday I tryed to do it good again, but not the problem is therenow. Some time, the computer will not play music or DVDs, but it can play MSN sounds, and I must re-start the computer, and so it will play music and DVD... What is the problem? What can I do? Please help me! I hobe you understand my english. If not, ask me and I can try again. Have a nice evening!
If you can help me, please write on easy english.
-
Please.. need help!! Problem with playing sounds
Hello, any help at all greatly appreciated.
I need a dead-certain way of playing sounds with my java application.
Java media player doesn't seem to be working with sound files with a duration of longer than 30 seconds.
I need a way of accessing the windows sound API from inside my java app.
Anyone have any ideas??????Hello, any help at all greatly appreciated.
I need a dead-certain way of playing sounds with my java application.
Java media player doesn't seem to be working with sound files with a duration of longer than 30 seconds.
I need a way of accessing the windows sound API from inside my java app.
Anyone have any ideas?????? -
what do i do about my Iphone not playing sound when it plays it only vibrates.... HHEELLPPP!!!!!
You have a dead phone. Call one of the numbers on
this page for the country you live in:
http://support.apple.com/kb/HE57
or use the Express Lane for iPhone to find out
what your options are. -
My iPhone 4s refuses to play sound when the headphones are not in. When the headphones are in however, it works perfectly fine! This is most annoying, could someone please help me I have not dropped it and it has not been in any contact with liquid.
I just tried both of those things and to no avail. Here are some pictures if that will help
-
My Pavillon Dv6 Only plays Sound out of the built in speakers if headphones are plugged in. It plays sound from both when there plugged in. Please hep me.
Step 1:
In troublshooting the problem you may follow the steps provided below.
a. Click Start, type Sound in the Start Search box.
b. Click Sound in the search results at the top of the Start menu.
c. Click the Playback tab. Notice the check mark next to the default device. For most users,the default device is speaker, change it to headphones. Make sure that your audio settings are configured as expected.
Step 2:
On the Playback tab, select the playback device, click Properties, click the Advanced tab, and make sure that the Default Format is set to the value that you expect. When you finish, close this window to return to the previous window.
Step 3:
On the Playback tab, select the playback device, click Configure, and then make sure the configurations are set correctly.
Method 2:
If the issue persists then I suggest you to follow these below mentioned steps to mute all other sounds when windows detects any communications activity.
a. Click Start, type Sound in the Start Search box.
b. Click Sound in the search results at the top of the Start menu.
c. Click the Communications tab.
d. Click on the radio button according to your convenience, under When Windows detects communications activity.
After performing the above steps you may check for the issue.
For more troubleshooting you may visit this below mentioned link.
Tips for fixing common sound problems
http://windows.microsoft.com/en-us/windows7/Tips-for-fixing-common-sound-problems
Let us know how it goes!
"I work for HP."
****Click the (purple thumbs up icon in the lower right corner of a post) to say thanks****
****Please mark Accept As Solution if it solves your problem****
Regards
Manjunath -
JMStudio locks up playing sound file - using java 1.5.0_02 - HELP!
I'm using the jmf 2.1.1e cross platform version on Windows XP SP2. I have java 1.5.0_02 installed.
When I open the sound file using JMStudio it locks up. It plays videos that don't have sound fine, so it's not the video. It's the sound that is killing it.
Does anyone have any suggestions?Hi,
yeah it's possible to play sound on Windows but you have to use the Windows Performance Pack instead of the crossplatform-version of JMF.
This has to do with the JavaSound Architecture of Java 5.0. They made changes and now the JavaSound Renderer didn't work under Windows but the DircetSound Renderer works fine.
So be sure that your application uses the DirectSound Renderer!
This is one of the main problems of JMF but now Sun gets interested in JMF and they would build a new version of JMF. If this is true they have to fix this problem!
Best regards, thomas -
i dropped my phone in water and now it wont play sound except in headphones and i even dried it!
You'll have to buy an out of warranty phone at the apple store.
Just because you dried doesn't mean that there wasn't any damage done. -
Please help me make my Macbook air play sound?
Hello all!
My Macbook air doesn't play sound anymore. It originally started with when I plugged in my HDMI cord to play on my LCD TV and it wouldn't work. Then I started fiddling with the settings and got it to work for a second. Then with a little more fiddling, somehow managed to turn off internal speakers. The volume is grey with no controls. If I adjust volume with keyboard, the cross out sign shows. I just would love to get some music coming out of my laptop again, and if I could get the HDMI to work too, that would be bonus!!Try doing an SMC reset http://support.apple.com/kb/HT3964 Then go into system prefs/sound/output and makes sure internal speakers are highlighted, if they aren't click on them
Maybe you are looking for
-
I just bought the Zen Touch, I love it. I cant figure out thow to use the software it came with called Creative Media Source so I can been using Windows Medis Player 0 instead. How do I name files? How do I transfer songs from the Creative Media Sour
-
Can Java Query An Access Database?
Is it possible to write a Java program that can retrieve data from Microsoft Access tables? If so, how is this accomplished? Are there any tutorials on the subject?
-
I have 3 tabs each tab has a ADG, when a tab is pressed I load the data from a RO. When my app starts I load the first tab with data, works great. when I press on the next tab the ADG shows but does not show the data, if I tab away then back on the d
-
I had to change my password on my email password, but went to my setting under mail accounts and it is grey and I am unable to update it there. Can someone tell what I can do? This on an iPad2.
-
Reading data which was wrote using fm BAL_LOG_MSG_ADD
I have two queries: 1) My z program is writing logs Using fn modules BAL_LOG_CREATE and BAL_LOG_MSG_ADD <b>Where can I view the log. Which tcode?</b> I have seen <b>SM21</b> but there is no entry for my transaction. 2) What is the suitable way of wri