First of all i know this is a programming forums, but my problem concerns Xcode and the problem happens with me while CODING.
When i use Xcode, when it is stopped in breakpoints while debugging the sound of the music played ( in my Mac music player ) is gone !!! i know this is awkward but it happens. Does any one has a solution or at least a reason for this?
After googling this problem i just found one case talking about the same problem here in this Link
I'm not using Spotify like the case in the link i'm using another music player called Vox
I have changed Vox and changed it with Deezer and it has the same problem
Update 1
As mentioned in the Accepted Answer, This problem only happened while using Cocos2dx in Xcode, When i returned back to the use Xcode with just iOS sdk without the Cocos2dx this problem doesn't exist any more.
This is happening when your capture audio session in your application and debug something.
The case to reproduce this using Xcode + simulator (on device you will have phone's audio session, so it can not be reproduced with the following snippet). Sometimes it stops just after breakpoint occurs, sometimes - after about a minute (i think, session expires after that time, or something like that)
Create empty project and override didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
if (setCategoryError) // set breakpoint here
NSLog(#"Error setting category! %#", setCategoryError);
return YES;
}
I think, on breakpoint session somehow stops music playing. so - check your project for the code, which manipulates with audio session (AVAudioSession).
Hope, this helps.
I had the same issue and I figured it had something to do with CocosDenshion. Do you use it? If so, try to not create a CDSoundEngine. Does it fix the issue? You could create it only in your release build.
Had the same problem, super annoying.
Fixed it by routing sound through soundflower.
https://github.com/mLupine/SoundflowerBed/releases
Then install soundflower bed:
https://github.com/mattingalls/Soundflower/releases/tag/2.0b2
Look for the soundflower icon in your menu bar on the right, select your output device of choice, then go to your sound options and select soundflower as the output.
Hope that helps!
The Simulator is the iOS/watchOS/tvOS user space running on the host mac kernel, so it shares its audio subsystem with the mac. When stopped in the debugger none of the audio callbacks can be serviced. I suspect this happens when you have an active audio session with active callbacks.
Please file a bug at https://bugreport.apple.com and provide a sample project if you can.
Related
I've recently built a simple Swift macOS app based upon VLCKit; its purpose is mainly to play IP camera streams via RTSP in a window that stays always visible on screen (i.e. to monitor a gate).
Given the purpose of the app, I keep the streaming playing all the time, except when the user minimizes it in the Dock (meaning that I only call mediaPlayer?.stop in viewDidDisappear).
The app works very well, but I've recently discovered that, unless it is minimized (and, as a consequence, the playback is already stopped), something prevents the screensaver from running.
I've tried subscribing to all NSNotificationCenter com.apple.screensaver.* notifications, and I've realized that when the playback is running, none of them is fired; if I minimize the app and stop the playback, everything behaves normally (screensaver starts after the regular delay, all the com.apple.screensaver notifications are properly detected).
I've also tried running pmset -g to check if my app was listed as preventing sleep, but it's not.
My impression, but I might be wrong, is that my instance of VLCMediaPlayer by default prevents the screensaver launch.
I know that in the VLC Mac app the screensaver can be manually prevented via an advanced setting, but I can't seem to be able to find a parameter to set in my code to tell VLCKit to stop blocking the screensaver.
To your knowledge, by default VLCKit prevents the screensaver from running? Is there a way to alter that behavior?
Please let me know if you need any further detail... and thanks in advance!
In VLC, there are options called "--disable-screensaver" and "--no-disable-screensaver". By default, "--disable-screensaver" is used.
If you want to enable screensaver just do this:
NSArray *options = #[#"--no-disable-screensaver"];
_mediaPlayer1 = [[VLCMediaPlayer alloc] initWithOptions:options];
What else options available in your VLC lib? pass option "--help" to your VLC and it will list all available options.
What is the full list of options? https://wiki.videolan.org/VLC_command-line_help/
It turned out VLCKit does actually prevent the screensaver from running by default, and that it doesn't use libvlc to do so, so the libvlc option "--no-disable-screensaver" I was at one point trying to pass was not respected.
The solution was to comment out a UpdateSystemActivity() function call on line 1409 of VLCMediaPlayer.m, as suggested to me here.
My wp7 app crashes when I come back from a task such as Map, Call or Web Browser. Infact, if i lock my phone and resume it again, still it crashes. Please tell me what could be the problem and how can I remove it?
There is a problem with you code.
Remove the application off the phone by starting a new emulator instance.
Open App.xaml.cs
Put a breakpoint in the method RootFrame_NavigationFailed and Application_UnhandledException
Now use the CallStack to find the root of the issue.
With no code posted (and in your case it could be ANYTHING in the project) you will be the best person to resolve your issue. If you can post a small reproduction on here we can take a look.
In application exit methods you probably should restore the data you dealt with last time before you quited
When Finder finishes copying of files then it triggers a sound alert. How can I do that from my app?
Please note that it is not the same as simply playing a sound. I am from Windows background so I am assuming that OSX allows users to configure notification sound from some central location. So, if the user chooses a different sound for an event then that API should play that new sound. This way I can make my app gel into the system and it will be able to alert the user using sound which the user is familiar with.
Answering my own question.
Found a good guide on this - System Sounds in Cocoa (wayback machine archive).
Official guide - Introduction to Sound Programming Topics for Cocoa.
Official NSSound reference.
Update
Additional notes
The system alerts are the ones which user can configure, others like emptying recycle bin, sound made when copying files are not.
NSBeep is the simplest way to trigger the alert sound which notifies the user of an error. Other sounds are available at the following locations in Lion.
/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds
For other user interface sounds check the Resources folder under related packages of the core applications. These application packages can be found in /System/Library/CoreServices/.
So, for example if you want to play the move to recycle bin sound then use the following code.
NSSound *systemSound = [[NSSound alloc] initWithContentsOfFile:#"/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/dock/drag to trash.aif" byReference:YES];
if (systemSound) {
[systemSound play];
}
Caveats
The name and path of the sound files may change at anytime. In fact the location of SystemSounds before Lion was /System/Library/Components/CoreAudio.component/Contents/Resources/SystemSounds.
You should also check this guide http://cocoathings.blogspot.com/2013/01/playing-system-sounds.html
NSSound(named: "Funk")?.play()
I am working on creating a very simple app. 2 buttons, both play sound. Each clip lasts 1 second and responds to "TouchUpInside". They are .caf files that I converted in iTunes.
Here is my code, once again, it works in the simulator but not on the device:
enter code here- (void)viewDidLoad {
NSLog(#"InView did load");
AudioServicesCreateSystemSoundID ((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:#"bigaif" ofType:#"caf"]], &systemSoundID);
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource: #"smallwav" ofType:#"wav"]],
&systemSoundIDTwo);
}
-(IBAction) playSound:(id) sender {
AudioServicesPlaySystemSound(systemSoundID);
}
-(IBAction) playSoundTwo:(id) sender {
AudioServicesPlaySystemSound(systemSoundIDTwo);
}
After looking for errors in my code for the past 30 min I found that the mute button on the side of iPad was on. Check that before trying some fancy solution.
30 min well spent...
I found my answer. I was using SystemSound and what do you know, I had my system sounds muted in my device settings.
I had same issue. I didn't add a link reference to the AudioToolbox.framework but it still worked on simulator.
I added it and it played in the foreground of my app on the device.
Then I wanted it to play the sound in the background. In info.plist "Required background modes" add the key "plays audio". That got it working the background.
This happened to me as well. Sounds were playing just fine in the simulator, but not on the device. I tried to play the sounds multiple different ways. I used both SystemSound and AVAudioPlayer with the same results. I even downloaded the code from a Mobile Orchard tutorial, and had the same result. Code example worked fine in simulator, but wouldn't play on the device.
After 2 hours of this, I double-tapped the home button on the iPad, scrolled to the left to the sound controls, and then tapped the speaker icon on the left. That placed a slash through the speaker icon to indicate that system volume was muted. I then tapped again, the slash went away, and I was then able to play sounds through the device.
So basically, I had to toggle through the muted state of the device using this method and that reset something on the iPad to where I could hear the sounds.
Note that this was on iOS6.
I am trying to get the MPMovieplayerController to work. I load a video everything goes wel i even see the first frame but then it automatically pauses, if i press play it pauses again. In the simulator it works perfectly but on the ipad device it gives the problem. I can even seek through the video and i see the frame i seeked to but nothing plays. This is some output from the console:
2010-06-08 22:16:13.145 app[3089:207] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
[Switching to thread 12803]
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/VCH263.videodecoder" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/H264H2.videodecoder" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/MP4VH2.videodecoder" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/JPEGH1.videodecoder" (file not found).
2010-06-08 22:16:15.145 app[3089:207] setting file:///private/var/mobile/Applications/46CE5456-6338-4BBF-A560-DCEFF700ACE0/tmp/MediaCache/
I dont get those warning when using the simulator BTW.
Does anyone know how to fix this ?
Set the property "useApplicationAudioSession" of the MPMoviePlayerController to "NO" to resolve the problem.
Found the solution just restart the ipad and it works again weird but thats it :)
Had the same problem. Video was playing ok on simulation but not on device. The problem was either on my HTML5 code embeded in the UIView or on the mp4 video compression, I don't know what fixed it but I suggest you try both. I am still getting the error when I am testing the video on the device, but the video plays just fine!
I had an issue on the device where the video would show up but not play. I could scrub. The fix for me was that I was using the avaudiorecorder, and I was releasing it before playing the video without stopping the audio recorder. My solution was to add the stop call to the recorder before starting the video:
[recorder stop];
[recorder release];
Avaudioplayer was causing my problem. Apperently on the iPad Avaudioplayer and Mpmovieplayercontroller cannot both play at the same time.
If an Avaudioplayer object is open the Mpmovieplayer will only display a frame and immediately stop playing.
As far as I can tell this only happens with iPad device 3.2.1 and SDK 4.0.1; simulators and the iPhone work fine
I switched back to Audioservices since I need Audioplayer and Movieplayer to play at the same time.