montouch detect when sound finished playing - xamarin.ios

In objective C is a method called AudioServicesAddSystemSoundCompletion which allows to add a handler for "audio done notification".
So I add the handler call AudioServicesPlaySystemSound and when the sound finished I'll get a notification.
monotouch has MonoTouch.AudioToolbox.SystemSound.PlaySystemSound to play such a sound.
But how do I know when the playing finished?
Situiation: I have a class which get's some information. When this information indicates an error I play a sound. If I'm already palying a sound I should do nothing.
And depending on a setting ("repeat alert") I should play the sound again the replay finished and the alert is still valid.
Sounds not so complicated - but without knowing when the sound finished playing I have a problem. So I can neither detect that I already play - nor can I repeat if needed.

This isn't bound in MonoTouch yet, you should file an enhancement request at http://monotouch.net/Support so we can expose it properly.

Related

LabView playing more than one sound at the time

I'm using event structure and want to do some like Launchpad.
Numeric keyboard have for each number added a sound.
Problem is, that when I press number example one, the program is waiting when the music stop play and next I can press example number four.
Is it possible, to play sounds from 3 key's at the same time using event structure ?
I put the files online here and added screenshots below. Block diagram:
Front panel:
Working Solution
I think I got this working much more easily than I expected using the Play Sound File VI under the Graphics and Sound -> Sound -> Output palette. That link is the 2011 documentation (couldn't find a more recent link), but it does not look like it has changed. The working result is shown below, with two different events handled by the event structure:
Key Down? event:
Stop Button event:
You may be fine without using the Sound Output Clear VI to the right of the main event loop, but having it there won't hurt.
It turns out that the Play Sound File VI does not block, so you can play multiple overlapping sound files. If you run into blocking on your machine (one sound file plays, then the next, and so on), let me know because I have another solution that might work.
A word on events
An important thing to understand is that events are handled in a queue. When you press keys, those key presses go in order onto the event queue. Each time your event-handling loop executes, it takes the oldest event out of that queue and processes it. The event structure in LabVIEW will only handle one event per iteration of your event-handling loop. On the next iteration, if events are still in the queue that your structure is set up to process, it will take the next-oldest one for that iteration and repeat.
Now, lets say that you want to do some super complicated processing that takes 10 seconds every time you press a key, and you put that processing inside of your main event loop. Your key presses still go onto the event queue as fast as you press them, but LabVIEW has to wait the full 10 seconds before it can dequeue the next keypress and process it, so you end up with an application that seems to hang while it chugs through the queue much slower than you are adding items to the queue.
One way to get around this is to take that complicated processing and put it outside of the queue in another process. If you have the resources, you can actually call a separate instance of a processing sub-VI in its own thread for every one of those key presses. This allows the event handling loop to spawn processes as fast as you can press keys, and then your processes take whatever time they need to simultaneously (resources permitting) perform whatever actions you wanted.
Essentially that is what the Play Sound File VI is doing. It sees that you want to play a file and spawns a process to play that sound over the speakers, allowing the event-handling loop to continue immediately rather than waiting for the sound to finish playing. As you press more keys, more processes get spawn that kill themselves when they are finished. You can do this manually too, which is the other solution that I have for you if Play Sound File does not behave the same way for you as it did for me.
Update:
Thanks to #Engineero for pointing out that Play Sound File vi actually isn't blocking. The updated code shows how to play overlapping sounds. I'll leave it to the user to add the Stop Sound on Key Up code. No timeout is needed because nothing is taking place in the event structure.
Also, note that for me the Play Sound vi needed to be in a while loop to keep playing. Not sure why this is needed, but the NI examples sets it up this way (\examples\Graphics and Sound\Sound\Sound Player.vi).
Finally, you may crash the vi if your sound card gets overwhelmed as mentioned here. If that happens I would go with a better sound library to try and squeeze more performance out of your sound card.
Original:
First, I assume you a referring to this Launchpad?
I was able to press up to 4 keys at once will the following - the important thing is to set the event timeout to 1 ms. If you need more than that it will require a more sophisticated design.
I was no able to easily implement a sound because all the basic LabVIEW beeps are what's considered "blocking I/O" meaning if you call 2 Beeps simultaneously than Windows will play one after another not both at the same time. You will need to implement you instrument notes using non blocking I/O probably in a language other than LabVIEW such as this C++ library.

Music replay does not work on Libgdx

I have a sound track for my game, which I play when player enters a level, and stop when the level ended.
Sound track is a Music class with looping set to true, and loaded through an AssetManager.
It works fine for the first level, I can hear the music, and when the level ends, I call stop. On the start of the second level, I cal start again, but I cannot hear any music. There is no error or exception either.
From the documentation, I thought I can user the same Music class instance, so theoretically it should work AFAIK.
Any idea why it doesn't work?

Does the VideoCastManager support stopping of playback?

How do you go about stopping the playback of a video? I only see a method for pausing.
Can I maybe force the load of a null video or something like that?
There will be a version of CastCompanionLibrary that will be published soon which exposes stop and some more new features. In most cases, you don't really need to call stop since that unloads the video as well; you can simply pause. Are you dealing with live streams? What is your use case for calling stop?

How to play background sound (music) in GW-Basic

I am developing a game in GW-Basic.i want to add music to it but the problem is that i am unable to play in the background but when i add sound then first the sound is played then after that game execution is started and vICE vERSA .while i want that both things play at the same time..so any idea how to do it??
This is actually possible. Use the PLAY "MB" statement to enable "music background" mode. In this mode all PLAY notes and SOUNDs are queued and executed in the background while your program is running. You can queue up to 32 notes. Look up PLAY in this manual.

"Aborting aboutToFinish handling." warning with PySide Phonon module

I'm allowing my workout-clock program to play sounds via the use of the phonon module. For each audio file in my program I create a device (createPlayer) and then use the play() method on it.
This works absolutely fine except for the fact that playing the sounds repeatedly somehow breaks the player. Sometimes the app works fine throughout an entire program, but sometimes the 'tic' sound of the clock gets disabled.
Every time I run the app, the second time any sound is played, I get the warning Aborting aboutToFinish handling. I think this is related.
Any suggestions?

Resources