SwiftUI Preview turns on microphone - swift

Does anyone know how to stop swiftUI previews from turning the microphone on? I wear bluetooth headphones while I work and every time a preview boots up it enables the mic. This degrades my audio quality since the headphones then split their bandwidth between playback and input.
My workaround has been to go into sound settings and just switch my default input to either my webcam or the macbook itself. It's so weird that the preview in xcode would turn on the mic every time it is enabled though.
Context: I have a MBP 2019 Xcode 12.4 Catalina
Thanks!

I've found that the Xcode Previews like to fuss around with the coreaudiod deamon, causing all sorts of issues (mics going on, audio stuttering, duplicated output). Try to manually kill all of those deamons from the terminal level. Apps that need this daemon to work should automatically restart needed deamon instances on their own, while Xcode won't do this.
sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`

Related

VLC loop/repeat not seamless when running in remote command mode

I have a Raspberry Pi 4 running Raspbian and run VLC from a command prompt with the following parameters
vlc --intf rc --rc-host localhost:65513 --fullscreen
I have successfully gotten VLC to play a video by issuing remote commands through a Socket and have issued a repeat/loop command.
The looping doesn't have to be seamless but it momentarily cuts back to the command prompt before it replays the video and looks unprofessional.
Is there any solution to this? I cannot find anything that works. I can live with the screen staying black for a moment but can't have work presentations playing continously on a screen that shows Linux in the background every 30 seconds.
I had the same issue, here is how I "fixed it" :
set desktop background to a black jpeg.
Told the panel not to appear at launch by editing /home/pi/.config/lxsession/LXDE-pi/autostart as follow (first line that launchs the panel is commented to do so) :
##lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#xscreensaver -no -splash
Prevent the pi to blank screen or go to sleep by editing file /etc/lightdm/lightdm.conf and adding in the [SeatDefaults] section :
xserver-command=X -s 0 -dpms
Now when VLC is looping, it still cuts back to the desktop but as everything is blacked out (no panel, black background), the cut becomes invisible.
Et voilĂ  :)
My best.
S.Y.
I solved this by using two instances of VLC, whereby one instance streams the video to the other using the --sout-keep flag. This way the VLC instance actually producing an image shows a continuous stream, as the streaming instance tries to keep one stream instance open across multiple(or one looped) file.
For example:
vlc rtp://127.0.0.1 --intf dummy --fullscreen --no-video-title-show --alsa-audio-device hw:1,0 &
cvlc file.mp4 --sout "#rtp{mux=ts,dst=127.0.0.1,sdp=sap,name='somename'}" --sout-keep --loop
The same happened to me some month ago, it looks that the only one solution is to wait for the release of vlc 4.0 for raspbian too, and no plans about it.

Using Ti.Media.VideoPlayer video does not loop on iPhone 4

Having a weird problem with my app.
Trying to play a video in a loop (see the code below). VideoPlayer repeatMode is set to Ti.Media.VIDEO_REPEAT_MODE_ONE.
Works in simulator, works on iPhone 4s, works on iPad Air... does not work on iPhone 4 (all of them running iOS 7.1.1 apart from simulator - 7.1).
Exact symptoms: after one play, video should restart from beginning, but it stops. If controls are available, I can press play to start playing it again, then after reaching the end it stops again.
I could swear that it worked on iPhone 4 before the 7.1 upgrade, but somehow it stopped.
Anyone could replicate this issue? Or have any idea?
Sys info:
Titanium SDK: Tested with 3.2.3.GA; 3.2.2.GA; 3.2.1.GA; 3.2.0.GA
Platform & version: iOS 7.1.1 (11D201)
Device: works on iPhone 4s, iPad Air, simulator; fails on iPhone 4
Host Operating System: OSX 10.9.2
Titanium Studio: 3.2.3.201404181442
Xcode: 5.1.1 (5B1008)
Alloy: 1.3.1
Code for basic Alloy project to replicate:
index.js
var videoPlayer = Titanium.Media.createVideoPlayer({
autoplay : true,
fullscreen : false,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
repeatMode: Ti.Media.VIDEO_REPEAT_MODE_ONE,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
//Video is 12s long so it is easy to notice that it does not loop.
videoPlayer.url = "video/candles.mp4";
$.index.add(videoPlayer);
$.index.open();
index.xml
<Alloy>
<Window class="container">
</Window>
</Alloy>
I would appreciate any suggestions.
I have done some research and played around with the Titanium.Media.VideoPlayer and managed to work around the issue. Below you can find the solution in case anyone else encounter this problem.
First of all, some info on the problem.
I have found some forum boards where developers were having very similar problem with MPMoviePlayerController on iPad 1st gen. Looped video was less or more randomly freezing on loop. So I think there is a problem with the Apple video player on some devices, and not necessary with Titanium implementation.
My first approach was to try replay video on complete event that is fired when video stops playing, instead of using repeatMode.
So far so good. It worked on the first time, yay! But the happiness was rather short. During an hour of test of videoPlayer.play() on event complete, the video sometimes was repeating 10-30 times fine and then suddenly was freezing. What gives? Turns out the video player had some sort of a hiccup.
Normal sequence of events was as follows:
video ends, playbackstate changes to 2,
complete event is fired
I restart video on complete
playbackstate changes to 1, video is playing until the end.
For a mysterious reason once in a while this sequence got additional something happening:
video reaches the end - playbackstate changes to 2,
complete event is fired.
video gets restarted on complete
playbackstate changes to 1, video starts playing
suddenly playbackstate changes to 1, video stops, without firing complete event.
Solution
So, knowing all this, I have set up listeners to listen to playbackstate instead of complete and when I hear playbackstate: 1 then I restart video and tadaaa! Everything works!.
Caveat: not 'everything' unfortunately. I am using custom video controls, so I have lost pause, and stop ability (every time video playback state changes to 'stopped' I restart it forcefully). To make it work I have to remember to remove listener every time I press 'pause/stop' buttons and then reattach it afterwards.
Hope that helps someone.

Trying to play an audio file

I'm trying to play an audio file in a cocos2d application. Here is the line which tries to play the sound:
[[SimpleAudioEngine sharedEngine] playEffect:#"pig_squeal.wav"];
If I put a log near this line, the log appears, and I can play the sound with iTunes. But when the sound should be played, there is a message displayed:
AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
What's the problem?
This was discussed in comments but I've amalgamated all the possibilities of why it may not work here.:
That's not an error message, just some information.
Is the sound definitely in your library and a part of the target?
You haven't changed the volume of the SimpleAudioEngine or the volume of your device isn't all the way down?
Click the sound in your library. Press Option+Command+1 to bring up the file editor. Scroll down to "Target Membership" and ensure the sound is checked for your target.
Try a different sound effect too? Try and narrow the problem down to "is it SimpleAudioEngine".
Also try and playBackgroundMusic for a sound (This was the solution in this case)
And try an mp3
There isn't a problem. It's a status message written to the log when you initialise the current OpenAL context using alcMakeContextCurrent. As far as I'm aware, you can't get rid of the message.
There is no problems with your code for the Playing of the Sound. Please check the Sound file has been added to the project also do check the format of the sound. It should play the Sound whenever you call the Play Effect. Please also try to PRELOAD the sound effect in the init method.
that message means the song was read correctly and should be playing. possible reasons you don't hear it?
volume turned down.
device malfunctioning
audio has silence in it
audio file is large and will take a long time to load.
sound has been redirect to come out of the headphones or the ear piece (even if not attached)
But the sound is loading and most likely playing.
If you are getting a crash while running in device from xcode pls try this(worked for me). Dissconnect the device from Xcode and run the app in the device. I dont know why it worked like that. But when I did this there was no crash.

Running IPhone apps while in sleep mode

As of IPhone OS 3.0, MotionX GPS is able to keep recording a GPS track while in sleep mode. After you push the sleep button on top of the phone, the app continues receiving GPS coordinates and recording them. Does anyone know how they're able to do this? I'm only aware of the method to keep running audio while in sleep mode.
I found a great webpage that explains how to do it -
Cached link from Wayback machine
Original Link, now 404
You have to start a timer that plays a sound every 10 seconds. But the sound can be silent.
[UIApplication sharedApplication].idleTimerDisabled=YES should do it
I heard that the [UIApplication sharedApplication].idleTimerDisabled=YES will leave the screen's background light on, (after the user pressed the sleep button,) which will drain the battery.
But I have not tried this myself, so anybody with experiences correct this if it is wrong.

idleTimerDisabled not working since iPhone 3.0

I have used:
[UIApplication sharedApplication].idleTimerDisabled = YES;
in a number of Apps developed and running under iPhone OS 2.x and never had any problems with it. They were clock apps so needed to run constantly and ignore the iPhone's idle Timer setting.
However, trying to achieve the same with a new App running OS 3.0 (and which needs to be deployed under 3.0 as it uses some 3.0 APIs) I've found the idle Timer to be either ignored or inconsistent.
My App plays music from the iPod library and when the music is playing it auto-locks regardless of the above setting. But once you unlock it, it then doesn't auto-lock again unless you play music again, in which case it locks again after the iPhone auto-lock time setting.
I'm amazed no-one else has come across this as I imagine it would affect a large number of Apps.
Just to clarify:
1. The above code is in ApplicationDidFinishLaunching
2. I know that the phone won't auto-lock when testing from xCode regardless of settings
If anyone has any thoughts I'd be very grateful...
Our app uses the MPMediaPLayer. We also had the idleTimerDisabled=YES code in the ApplicationFinishedLaunching, which works EXCEPT if untethered, and there is already a current nowPlayingItem which is left playing (or unpaused, if paused at app startup). Obviously this is all with the Settings -> General -> Autolock set to some timed value.
By adding idleTimerDisabled=NO, immedately followed by idleTimerDisabled=YES in one of the other bits of code AFTER we had figured out what bit of music we would get playing seemed to solve the problem. Just setting it to YES was insufficient.. and subsequent queries had always indicated the correct value (YES).. so it appears the Apple code ignores the setting of the value IF there is a current piece of music and that is not changed by your code.. but does notice a change of value.
This is all under iOS 3.0.
Even in 2015, using iOS 8.2, this bug is still alive and kicking.
Here's my solution, using XCode 6.2.
iPhone - phone goes to sleep even if idleTimerDisabled is YES
Basically, even now, in 2015, the only way to safely make sure that the device doesn't go to sleep is to repeatedly call a piece of code to keep the device awake.
-(void)callEveryTwentySeconds
{
// DON'T let the device go to sleep during our sync
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
}
Sounds like a bug, file with Radar - I am not too surprised this has not been seen much as there are probably not a lot of apps that try to lock the screen open and play music.
Having same issue. It does work when the device is plugged in. You can press lock button on top, and my NSTimer fires later and causes a vibrate. However if the device is not plugged in pressing the lock button puts the device to sleep. Any solution would be greatly appreciated.
iCodeblog posted about the idletimer, I said it didn't work, and the person who develops 'cute clock' was nice enough to reply. You have to do a hack, play a 1 second or longer silent sound every 10 or so seconds with NSTimer. This keeps the device awake even if the user hits the lock button.
I develop Seconds - Interval Timer for iPhone and iPod touch and I've had no end of trouble with this. The idea of my app is that people create timers based on a number of intervals where each interval can have it's own playlist or track played.
In iOS3 I had the problem that I couldn't disable the idle timer by just setting idleTimerDisabled = YES. In the end I came up with the same solution as Neil whereby I would periodically set it to NO, then immediately to YES again. This seemed to work.
I'm now updating the app to iOS4 (I know, iOS5 is just around the corner...) and now I have the opposite problem. If the MPMediaPlayer changes track before the idle timer reaches it's limit it gets reset. I've just tested this by creating an interval in my app that was 55 seconds, my auto-lock was set to a minute. At 50 seconds the screen dimmed as it prepared to lock, but at 55 seconds when the music changed it went back to full brightness and then didn't lock as it should.
Overall, the implementation of this seems flakey at best.