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?
Related
There was a problem with audio playing in the exported instance of the game. The sound is played using the AudioStreamPlayer node. I export the game to html5 and run it either on a local server or on any service that executes html code. If during the game you minimize the browser, change the tab, make the game window NOT active, then all game processes are suspended, that is: the movement of all objects does not occur, all timers are suspended. BUT the music continues to play. I tried to handle a focus Notification , an input handle with a cursor to turn off the music, but this is not an option, because if you minimize the browser via alt + tab while on the tab with the game, then the focus does not go away and the input is still waiting (while as I said earlier, all other processes related to movement and the timer are suspended).
How stop this audio stream in this case?
thanks
When I call for the first time to Manager.CreatePlayer() its freezes my application for a split second and it's a problem for me because I'm writing a game and it's noticeable, what can I do to fix it ?
As far as I know, the common logics for game are :
Display loading screen
Here's all heavy operations are prepared/preloaded and cached, so the game can run smoothly later.
Methods that usually called here are Manager.createPlayer and Player.prefetch().
All the image & sound is prepared first, and can be used quickly when game started.
Start the game (loop)
As the resource have been prepared/preloaded, now you can use (draw/play) them here.
Use the Player instances that has been created & prefetched (from loading screen).
You can call Player.start() method here to play the sound.
You can read about the Player state (especially about prefetch) HERE.
Notice that you can reuse the Player instance and call start() method multiple times for playing the same sound. No need to call createPlayer again.
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.
I have a playlist, and I want to sequentially play through the tracks, but every time a new track is loaded, I want to call a function. How would I go about listening for this event?
SPPlaybackManager, the playback class in CocoaLibSpotify, doesn't automatically play tracks sequentially, so you have to manually tell it to play each time. Since you're managing that, you already know when a new track is starting playback.
Additionally, SPPlaybackManagerDelegate has a method -playbackManagerWillStartPlayingAudio:, which will let you know when audio starts hitting the speakers.
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.