Playing a System sound in tvos [swift] - swift

In iOS I can play a system sound with the following code:
// import this
import AVFoundation
// create a sound ID, in this case its the tweet sound.
let systemSoundID: SystemSoundID = 1016
// to play sound
AudioServicesPlaySystemSound (systemSoundID)
There is this link https://github.com/TUNER88/iOSSystemSoundsLibrary to a list of available system sounds in iOS
My question is are system sounds available in tvOS? and which ones are available.

SO I found the Answer. . .
The above code works fine on an actual Apple TV. It does not work in the simulator. (It plays no system sounds in the Simulator.) Must be a bug.
I'm using Xcode version 7.3 and the 9.3 tvOS Simulator.
The above link to a list of sound files seems to work. I've tried 5 different systems sounds that work.

If the sound doesn't play in the simulator but does play on a live Apple TV, it might be that you've disabled user interface sounds.
To enable, load the System Preferences, select Sounds, and then tick the Play user interface sound effects checkbox (and also increase the Alert volume)
When you play the system sound, it should play in the simulator now.

Related

No Sound on iPhone Simulator - xcode 10, Swift 4 [duplicate]

Somehow my iPhone Simulator is unable to play sounds. First an app I'm working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash Landing app.
I can't find a sound setting anywhere in the simulator or Xcode preferences. I've tried resetting the simulator through "Reset Content and Settings" menu item to no avail.
On your Mac, go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects".
You need to re-activate your system sounds, see the end of this page.
I had no sound in the simulator, so I tested it with mobile safari and tried playing an mp3: No sound!
All the above tips didn't help. Eventually, I changed my INPUT source from the virtual soundflower device to Line-In, and the Simulator worked!
So, even if the app wasn't using input, it didn't work well with Soundflower.
I've seen this problem after my update from OSX10.5.7 to 10.6.2
And I made the following changes to make the simulater sing again:
Goto "Applications/Utilities" and run "Audio MIDI Setup", then change midi format from 48000 to 44100.
OpenAL not working on the simulator was fixed with the 2.1 SDK. Make sure Active SDK and Active Executable are set to 2.1.
By the way, make sure you're using the last version of CrashLanding (v1.8). Some nasty leaks in SoundEngine were fixed recently.
I've found sound to be very inconsistent in the simulator (2.1 SDK). Sometimes it works, sometimes it doesn't. Even when it does work, it's usually very choppy and distorted (when playing audio files such as mp3).
A few things to remember:
call AudioSessionInitialize as soon as your app finishes launching
set the kAudioSessionProperty_AudioCategory property for the session via AudioSessionSetProperty (with a value such as kAudioSessionCategory_MediaPlayback)
call AudioSessionSetActive(YES)
Of course when all else fails, just run it on your hardware!
EDIT: Now that the 2.2 SDK has been released, I haven't had any problems with sound in the simulator. They must have fixed the bugs! I highly recommend you upgrade to the 2.2 SDK.
if reactivating system sounds didn't work for you try this:
launch audio-midi-setup, then configure your "built in output" to use 44.100Hz, 2 channels, 24 bits. (from http://www.cocos2d-iphone.org/forum/topic/4159)
somehow after a few days, my iphone simulator now wants 48.000Hz, 2 channels, 24 bits.
just play with it for a bit and be warned that it might change randomly when plugging in headphones, going to standby, restarting, etc.
and here's a an off-topic hint: when you plug headphones into your iphone/ipad the buffer size might double (e.g. from 512bytes to 1024 bytes), make sure you don't rely on the buffersize you requested!
I'm encountering this issue while running a watchOS simulator. In my case, the following worked:
Close the simulator in which the sound doesn't work.
Open another watchOS simulator.
Close it and reopen the original one.
Here are two other possible reasons why sound might not play on simulator devices:
With Xcode 14.2 and simulators running iPadOS 16 / iOS 16, I noticed that sound was playing on iPad simulators, but not iPhone simulators. It turned out that this was related to the AVAudioSession.Category being set on the AVAudioSession. If the category is .ambient then sound plays on iPad but not iPhone simulators, if the category is .playback then it plays on both. Interestingly, this does not seems to be a issue for iOS 15, here .ambient category plays on iPhone simulators too.
If you are calling AVAudioPlayer.play(atTime: TimeInterval) then the TimeInterval you pass in must be later than the device's current time. Passing 0 will not work and just plays nothing. Even passing a value > 0 may play nothing, you need to add the time offset to the deviceCurrentTime on the player. See the associated documentation for an example. This applies to real devices too of course, not just simulators.

MPMoviePlayerController wont play movie on iPhone 3G when in release mode but will in debug mode

OK, I've got a weird one here...
I have an issue with MPMoviePlayerController and playing a m4v movie on an old iphone 3g.
When I connect the device to my mac, and run it through Xcode with the build set to Device|Debug - the movie plays fine.
When I change the build to Device|Release, the MPMoviePlayerPlaybackDidFinishNotification is called immediately with an error of "This movie format is not supported" and the movie is not shown.
Running 4.1 on the device, and have 4.1 set as the base SDK.
Do you have any ideas?
Thanks
Chris
Maybe the problem is really with your video encoding. Try example video provided in this tutorial:
http://mobiledevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html
If problem still occurs, let me know.

iPhone 4.0 problem.. MPMoviePlayerViewController , AVAudio APIs

I'm making iphone program. The main function is playing video files, and recording sound.
OS 3.1.3 version is fine. But iPhone 4.0 makes problem!!
When I executed playing video (MPMoviePlayerController) and continuously recording sound (AVAudioRecorder), AVAudioRecorder doesn't work....
No recording..! ;o;
Somebody help!!
Check the useApplicationAudioSession property on MPMoviePlayerController. In iOS 3.1.x, the movie player was always getting its own system provided audio session. In iOS 4.0, it can now share the application session, and that's the default value as well. Try switching that property to NO before starting to play your movie.

Playing video in a Customview like iPad feature

When we call MPMoviePlayerController.play method, the movie player is opened and the video is played in a separate full screen. is it possible to play a video in a custom view, that is I have an image added on a view, when this image is clicked, the image has to be removed and the video has to play there itself as the feature in iPad.
Non-full screen playback of video is possible in iPhone OS 3.2 for iPad.
If you are porting an application that uses the MPMoviePlayerController class of the Media Player framework, you must change your code if you want it to run in iPhone OS 3.2. The old version of this class supports only full-screen playback using a simplified interface. The new version supports both full- and partial-screen playback and offers you more control over various aspects of the playback.
On the full-screen question, see this section of the iPad Programming Guide for further information, and this property of MPMoviePlayerController specifically.
Bear in mind that you can still only play one video at a time, and that this is only currently possible for iPad.
Not using MPMoviePlayerController, no.
You might be able to achieve this using a custom movie player, but I haven't seen one in the wild yet, and I don't know how it would be done.

Movie, Image Editing, Mixing Audio in IPhone

I need to develop some sort of application featuring Editing Movie slices, Adding and editing images, Adding sound . recording movie, Adding effects, setting transitions between movie clips and images.
so is there any provision in SDK 3.0? I will use iPhone 3GS
Please Help Me.
Thanks
Unfortunately, there isn't a lot of support for a program like this on the iPhone yet. With the 3GS and OS 3.0, your program can let the user record a video and trim it, but everything after that is left to you to do from scratch. You get the filename of the recorded video, but there are no OS calls to even do something as simple as find out how many seconds of video there are.