Problem with playing a sound file.

Hi,
I simply want to play a sound by a button click. I imported
<AVFoundation/AVAudioPlayer.h>. The code block is here:
In .h file:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVAudioPlayer.h>
@interface PlaySoundViewController : UIViewController <AVAudioPlayerDelegate>
in .m file:
-(IBAction)btnPlay:(id)sender
    //Get the filename of the sound file:
    NSString *path = [[NSBundle mainBundle] pathForResource:@"REC001" ofType:@"MP3"];
    AVAudioPlayer* thePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];//error here as it will compile if I commented it (and two line after) out.
    thePlayer.delegate = self;
    [thePlayer play];   
Everything looks fine but it failed when I tried to run it. Looks like it cannot find my sound file "REC001.MP3". I put it in folder ".../PlaySound/Resource Files/SoundFiles/REC001.MP3", and "PlaySound" is my project name. However the path returned is ".../PlaySound/REC001.MP3". I guess this is why it cannot find the object. But it didn't work even I put the sound file under "PlaySound" directly. Anyone has a solution?
Thanks.
Regards,
Taizhi

Hi Mark,
Thanks for the reply. Based on your instruction, I checked and I can see the sound files in Build Phases. The location is ".../PlaySound/SoundFiles/REC001.MP3". I don't know why it ignores folder "Resource Files". I guess that is the way it is as I also can see other images in different folders which are shown properly in the project.
The detailed error message is here:
Ld "/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpxz lqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator/PlaySound.app/PlaySound" normal i386
    cd "/Users/greatzhi2001/Desktop/iProjects/PlaySound"
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr /bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3 .sdk -L/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpx zlqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator -F/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpx zlqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator "-F/Users/greatzhi2001/Desktop/iProjects/PlaySound" -filelist "/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpxz lqfodwbuqqjwjzcd/Build/Intermediates/PlaySound.build/Debug-iphonesimulator/PlayS ound.build/Objects-normal/i386/PlaySound.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpxz lqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator/PlaySound.app/PlaySound"
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_AVAudioPlayer", referenced from:
      objc-class-ref in PlaySoundViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Is the framework AVFoundation I added wrong? Thanks.
Regards,
Taizhi

Similar Messages

  • Problem with loading a sound file

    Hello, I am trying to play a sound file (located in same dir as the class files) from a swing app using this line.
    AudioClip clip = Applet.newAudioClip(new URL("sound.au"));When I run the program, I always get a MalformedURL Exception.
    Could someone please tell me the correct way to load a sound file in swing.
    Thanks

    "sound.au" is no valid URL, hence the exception.
    How about "file:///c/myfiles/sound.au" or something?

  • Having problem with playing audiobook .mp3 files

    I have downloaded some audiobook mp3 files. I can transfer them fine to the Ipod, but when I choose the file to play, it goes through all the steps right up to the playing of the mp3 file, then the backlight shuts off, the screen wipes out and the white apple logo comes on and reboots into the main menu screen list.
    As long as I continue to choose these audiobook mp3 files the Ipod will continue to reboot and not play the file.
    I have downloaded the same audiobooks on 2 different occasions, and the same thing happens. The files do play through the iTunes library list from my computer.
    Any ideas on how to solve this?? I don't have any problems playing any of the other audio book mp3 files that I have dragged and dropped onto the Ipod.

    http://docs.info.apple.com/article.html?artnum=304490

  • I have problem with playing stream  fullscreen. it goes black but with sound

    i have problem with playing stream fullscreen. it goes black but with sound. i have to wait 10-15 minutes then i can press fullscreen. what to do?
    s

    Thanks!! but i been fixing now for 10 minute ago by restart my macbook pro. My case is it show normal with Intenal-speakers and nothing mark with red light or mult so i tried to restart that it working again

  • I have a problem with the external sound of my ipod, when I take the headphones the music keeps playing and the ipod recognizes still have a headset connected. how do I get external sound out?

    I have a problem with the external sound of my iPod, when I take the headphones the music keeps playing and the ipod recognizes still have a headset connected. how do I get external sound out?

    - Try insering and removing the headphone plug a dozen times or so.
    - Try cleaning out the headphone jack in the iPod.
    - Resett he iPod. Nothing is lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup
    - Restoe to factory defaults/new iPod
    If yu still have the problem that indicates a hardware problem, likely a bad headphone jack. Yu can make an appointment at the Genius Bar of an Apple store to confirm.
    If not underwarranty Apple will only exchange your iPod for a refurbished one for:
    Apple - Support - iPod - Repair pricing
    A third-party place like the following is less expensive. Here is one. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens

  • Problems with playing songs in iTunes

    as the subject says. I have som problems with playing songs. not everyone just a some..
    If we take for example that a song is 8min. then at 1.40 it just stops and goes to the next one. I can jump over it with pressing in the middle for example. it plays. as normal. UNTIL. 3 mins. then the same problems appear. I don't really understand how. just between 1.40-1.50 iTunes thinks that the song is finished. I know my english isn't so good but cuz there is no swedish support. I have to write here. any answers would be good

    I'm having a similar problem.
    Every now and then, a track from a ripped CD or from iTunes or from eMusic will "look" OK in iTunes (or on my iPod), but when the track plays, it gets partially through and it jumps to the next track in the playlist.
    For example, if playback of track 1 pauses and jumps to track 2 at 1:30 into playback of track 1, & I click on 1:31 or later in track 1, the rest of track 1 will play fine. But if the playback of track 1 starts at the before the "skip point," the track will stop & iTunes (or iPod) goes on to the next track in the playlist. If I locate the file (on my external drive) and play it in the finder, there's always buzzing sound at the point where the iTunes jumps to the next track.
    For ripped CD's this is not a huge deal, I just re-rip & usually all is well. With eMusic, I can download again, but with iTunes, I have to file a complaint & so far they've just credited my account, which is OK, but time consuming.
    At first I thought the problem was with my optical drive, but then the problem started happening with downloads from iTunes and eMusic as well. NONE of these shenanigans happened before I upgraded to iTunes 7.6, so I'm wondering if that's where the problem is. One thing's for sure: I'm not going to "jump" at the next upgrade of iTunes!
    I'm totally stumped & bummed. iTunes used to be a really good friend, now I find myself wondering if I should bother with putting my entire CD collection on iTunes if it's no longer as reliable as it used to be.

  • How do i play two sound file one after another

    Hi All,
    How do i play two sound file one after another using single AudioClip Component?.
    Advance in thanks
    Manivel

    AudioClip gives you very little control over what happens to the sound, it also isn't capable of playing long clips or waiting until a clip ends. It will play multiple clips over top of each other.
    To do what you want you should use the facilities of javax.sound. Here's a post with an example: http://forum.java.sun.com/thread.jspa?forumID=513&threadID=450768
    There is also a tutorial, but its example fails for long clips.

  • Problems with my Creative Sound Blaster X-Fi Xtreme Gamer bulk P

    Hey there!!!
    I acutally have a Problem with my Creative Sound Blaster X-Fi Xtreme Gamer bulk PCI-Card. The Card by it self is working perfectly. But i cant use the Digital-In as the Mic in. I dont know how to turn it so that the Digital-In is the Mic-In. So my Microphone donst work. I hear everything but nobody hears my Voice. There is sometimes a Signal but not the correct, the Guys playing with me dont hear anything of my voice...
    Can somebody help me plz?
    Greetings Thomas

    Moep wrote:
    Why i must use TORRENT?
    Why is this driver not on your page?!
    Please fast help...
    and this is a secure download you mean? ....
    Jeez, calm down already. I never said you HAD to download it, but if you want any of the applications that work in XP to work in Vista then you're going to need that disk; either by downloading it or fromk here,?http://us.creative.com/products/prod...7&product=6743?
    2. ISN'T THIS THE DRIVER FOR ME?! http://forums.creative.com/creativelabs/board/message?board.id=Vista&message.id=7838Message Edited by Moep on 07-3-20070:7 PM
    Maybe you really should take a vallium or something and re-read what I posted, then you may just grasp the fact that that is the exact driver I told you you needed.

  • Problem with Preview and PSD files - random gray square

    Hi guys, hope you can help...
    I've got a problem with Preview and PSD files.
    If I open in Preview both an original jpg straight from my reflex and the photoshop version of the same picture, the psd file presents a gray square (of what it seems unrendered image) in a random area of the photo (sometimes in the center.). The square is quite big...
    If I zoom in or zoom out it disappears...if I scroll to another photo and then back to the psd, the square it's there again...sometimes in a different position.
    I've tried the same psd on my older iMac with leopard...and got no problem at all.
    I suspect it got something to do with my Ati...
    (this is the second iMac 27...the first went back for gray banding on the lcd screen and flickering and yellow tinge........)
    Thanks for your help.
    DAve.

    maybe I'm onto something...
    I've just found out that opening Preview in 32bit mode (instead of default 64bit) works flawlessly with any psd files. If I switch back to 64bit mode, Preview is much faster but the gray square comes back...
    It seems like the i7 is much faster than the Ati....
    Any more realistic ideas?

  • Problem with kde and sound

    Hi!
    I've a problem with KDE and sound.
    When KDE shows a alert the alert's sound sounds with delay. 3-5 seconds.
    Same happens with kde start.
    Can anybody help me?
    Thanks!

    Pilli wrote:
    Hi!
    I've a problem with KDE and sound.
    When KDE shows a alert the alert's sound sounds with delay. 3-5 seconds.
    Same happens with kde start.
    Can anybody help me?
    Thanks!
    Change the player to mplayer or something in the control panel (Sound and Multimedia - System notifications - Player Settings).

  • I have problems with seeing my bookmarks, file, view, edit...buttons. I tried other shortcuts. I noticed that all of my bookmarks are located in the Internet Explorer browsers, how can I restore setting back to Mozilla Firefox?

    I have problems with seeing my bookmarks, file, view, edit...buttons. I tried other shortcuts. I noticed that all of my bookmarks are located in the Internet Explorer browsers, how can I restore setting back to Mozilla Firefox?

    Is the menu bar missing (the one containing File, View, Edit etc)? If it is, the following link shows how to restore it - https://support.mozilla.com/kb/Menu+bar+is+missing

  • I have a problem with running an EXE file on win2000, the Lab View is 5.1 and I do not know if it is 16 bit...

    I have a problem with running an EXE file on win2000, the Lab View is 5.1 and I do not know if it is 16 bit...what should I do?

    Hi Arika,
    The drivers that you need to install to make your executable work depends on what your executable is doing. To get started, you need to have the LabVIEW Run-Time Engine installed on your target machine (the Win2000 machine you are planning to use) in order to run your executable. Next, you need to determine what drivers your executable uses, if any. For example, if you are using GPIB instrument control, you will need to install the NI-488 drivers on your target machine. If you are performing data acquisition, you will need to install NI-DAQ drivers. If you are doing image acquistion, you will need to install NI-IMAQ drivers.
    All these drivers are available for downloading on ni.com. To get the drivers, go to ht
    tp://www.ni.com/support , click on the link that takes you to Drivers and Updates (under Option 3), and click on the links to get to the driver(s) you need. For example, if you need the LabVIEW 5.1.1 Run-Time engine, click on the All Drivers and Updates by Application link on the main page (http://www.ni.com/softlib.nsf/). Then click on the LabVIEW link, Windows 2000, Run Time Engine, and then you will see the link to get to the page to download the LabVIEW 5.1.1 Run-Time Engine.
    I hope this information helps.
    Best Regards,
    Wilbur Shen
    National Instruments

  • Problem with saving a pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21).

    Need advice on a saving file issue. I'm having problem with saving a .pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21). This is new as this error message just recently started to pop-up.

    More information about this issue can be found here:
    https://forums.adobe.com/thread/1672655
    A "quick" fix that worked for me was to uninstall Adobe... then download the base install for Adobe Reader 11.0.
    Then download each of the individual updates and run them sequentially. 
    I've installed back up to the last security update which is version 08 and have been able to do normal Save As operations.
    You will have to disable automatic updates in order to stay at version 08 until Adobe resolves this issue in a later release.
    http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows
    Adobe Reader 11.0 - Multilingual (MUI) installer    AdbeRdr11000_mui_Std
    Adobe Reader 11.0.01 update - Multilingual (MUI) installer    AdbeRdrUpd11001_MUI.msp
    Adobe Reader 11.0.02 update - All languages    AdbeRdrSecUpd11002.msp
    Adobe Reader 11.0.03 update - Multilingual (MUI) installer    AdbeRdrUpd11003_MUI.msp
    Adobe Reader 11.0.04 update - Multilingual (MUI) installer    AdbeRdrUpd11004_MUI.msp
    Adobe Reader 11.0.05 security update - All languages    AdbeRdrSecUpd11005.msp
    Adobe Reader 11.0.06 update - Multilingual (MUI) installer    AdbeRdrUpd11006_MUI.msp
    Adobe Reader 11.0.07 update - Multilingual (MUI) installer    AdbeRdrUpd11007_MUI.msp
    Adobe Reader 11.0.08 security update - All languages    AdbeRdrSecUpd11008.msp

  • Problem with Append mode in File Receiver

    Hello,
    I am facing some problem with Append Mode in File Receiver.
    In channel config, i have given :
    Construction Mode : Append
    File Type : Text
    Message Protocol : File Content Conversion
    The size of the file which i am trying to send is about 9.5MB.
    I got this error,
    "Recovering from loss of connection to database; message
    loaded into queue by recover job: System Job (Failover Recovery)".
    So, it would seem that there was a loss of connnection to the database    
    while the file was being written.
    Note -  XI successfully recovered from the connection loss and   
    successfully wrote the file, however since the communication channel  
    was set to append, it appended to the partial file that was written   
    before the database connection loss. This is not correct. The file    
    should have been overwritten after the recovery even though the communication
    channel was configured to append.                                     
    Can anyone help me on this regard.
    Thanks,
    Soorya.

    Hi Venkat,
    I would suggest u to split the file in to chunks if u face any problem in processing at a time in append mode and also
    Memory Requirements are must 4 processing huge files:
    Q: Which memory requirements does the File Adapter have? Is there a restriction on the maximum file size it can process?
    A: The maximum file size that can be processed by the File Adapter depends on a number of factors:
    o The most important one is the size of the Java heap, which is shared among all messages processed at a certain point in time. In order to be able to process larger messages without an out of memory error (OOM), it is recommended to increase the size of the available Java heap and/or to reduce the concurrency in the system so that fewer messages are processed in parallel.
    o Another factor negatively influencing the maximum message size in releases up to and including XI 3.0 SP 13 is an enabled charcter set (encoding) conversion if the message type is set to "Text".
    o Using the transport protocol "File Transfer Protocol (FTP)" also uses more memory for processing than the transport protocol "File System (NFS)" (up to and including XI 3.0 SP 13).
    o If the Message Protocol "File Content Conversion" is used in a File Sender channel, consider that not only the size of the input file affects the File Adapter's memory usage, but even more the size of the XML resulting from the conversion, which is usually a few factors larger than the original plain text file.
    To reduce the memory consumption in this scenario, consider configuring the setting "Maximum Recordsets per Message" for the sender channel. This will cause the input file to be split into multiple smaller mesages.
    Plz do refer the following links:
    U may plan the availability of ur communication channel using "Planning Availability Times" feature
    http://help.sap.com/saphelp_nw04/helpdata/en/45/06bd029da31122e10000000a11466f/frameset.htm
    /people/sravya.talanki2/blog/2005/11/29/night-mare-processing-huge-files-in-sap-xi
    hi check the below links for reference
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10748ef7-b2f0-2910-7cb8-c81e7f284af5
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7086f109-aaa7-2a10-0cb5-f69bd2affd2b
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2498bf90-0201-0010-4884-83568752a857
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cc1ec146-0a01-0010-90a9-b1df1d2f346f
    Regards,
    Vinod.

  • Problem with RTPExport output video files

    Hi, I have a problem with RTPExport output video files. One side streams H263/RTP(AVTransmit2.java) and other write this steam to a file by RTPExport.java. When network conditions are ideal, output video file has same fps and same number of frames like original file. Problem occures, when theres packet lost in network, then output file has different fps,and also has less frames like original video(because it didnt write missing frames to file, and thats why it get shorter). Pls how can I achieve output file that will have the same fps like original one? How to write to file an identical copy of what I can see while receiveing video with AVReceive2.java? Its there a way to modifi rtpexport or avreceiver to do this? Thanks a lot!

    Trubka wrote:
    When network conditions are ideal, output video file has same fps and same number of frames like original file. Problem occures, when theres packet lost in network, then output file has different fps,and also has less frames like original video(because it didnt write missing frames to file, and thats why it get shorter). Okay, first off, the second file is smaller on purpose. RTP intentionally drops packets that are old/out of order in order to make sure real-time video stays as close to real time as it can. This is by design, so there's really nothing that can be done about it.
    How to write to file an identical copy of what I can see while receiveing video with AVReceive2.java? Technically speaking, what you're getting in the RTPExport is exactly what you got on the receiving end. Any frames that are dropped during transmission will not be seen by the receiver, nor saved by the receiver.
    Pls how can I achieve output file that will have the same fps like original one? I'm not 100% sure that you can, but, you can give the following idea a try. I make no guarentees that it'll work, but it should work for you...
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/RTPConnector.html]
    That example is an example of a "custom transport layer" for RTP connections. Essentially, it's some code that's handed the RTP packets on the transmission end, and it's expected to deliver those RTP packets on the other end. And it doesn't care about how they get from A to B, only that they do.
    If you were to replace the UDP socket in that example with a TCP socket, you would be guarenteed not to drop packets due to network reasons. Every RTP packet you were handed by the transmitter, you would then hand to the receiver. There is no guarentee that none of the packets would be cast away as "old" by the RTP protocol itself, but there's also no guarentee any of them would be. It's a crap-shoot at best, but it's certainly worth a try.

Maybe you are looking for

  • New Feature for proxy

    Hi all! I'm not found this feature in current Async OS documentation for web products. So propose new feature - extended user logging mode. In this mode all POST requests with posted data from some user group are grabbed and inserted into database fo

  • Facing the problem in creating dll

    Hi, I have written the JNI example. I have make the .class file, .header file and .c file. But when I am trying to make the dll..its shows the following error. C:\jni test>cl -IC:\j2sdk1.4.2_17\include C:\j2sdk1.4.2_17\include\win32 -LD HelloWorldImp

  • HT201328 how to unlock my i phone so i can use it international

    how to unlock my iphone so i can use it international on any simcard

  • HR Resigned Employee Report

    Dear All, I need to make out a report to list all resigned employees and the position which they held while they resigned. IN sap the last position is marked as default position when they resign . So how will i fetch the position before the Default p

  • XML mapped to IDoc routed to two different receivers

    Hello gurus, I have an XML document coming into XI which needs to be mapped into an IDOC, then sent to two different systems (not to both of them) based on a value in the XML (the value is actually the SAP partner ID). Can this be done in BPM? Perhap