I'm making a game to learn how to properly use C#, but the sounds that I use don't play as intended. They make no errors, but play late and the file seems cut.
I'm using WinForms, so I tried a SoundPlayer with a Stream, or tried with Visual Basic's Audio class.
I also tried to make a dictionary full of streams, or full of SoundPlayer, but it didn't change anything.
It work when I use the AudioPlayMode.WaitToComplete, but it isn't what I want.
Thanks in advance !
I've figured it out. I just put the audio in a Thread, and put Audio.WaitToComplete in it.
Related
Is this possible? It would be great..
I've tried:
http://fci-h.blogspot.kr/2007/06/how-to-play-flash-swf-inside-c.html
which gives me a attempted to read protected memory error
and
http://blog.debreuil.com/?p=35
which I just can't work out how to use - I just want the code to play a .swf file I've made already in my XNA game.
I would just love to be able to do cutscenes or live backgrounds in this way, especially if they can be streamed from file instead of preloaded.
Thanks a lot for any help!
Sorry, but this is not possible without extreme hard work that's just not going to be within your reach. (Or some painfully awkward method, like embedding a Webpage below your game)
On the bright side - there's pretty much no need for .swf embedding. Anything flash can do, XNA can do better!
Use animated images or videos for live backgrounds / cutscenes - or program them yourself in XNA using manipulation of static images - if you need help with that, post a new question asking for help with some specific thing you need done.
Also, if you want, you can ask for help converting Flash Actionscript to its C#/XNA equivalent - it can be done without too much work by anyone with a little experience in both languages.
I have been trying to find some things online about how to make your own visualizer that responds to sound, But so far I only could find tutorials for on a mac.
I also found some premade visualizer but prefer not to spend 50$ on a asset for it
theasset
I was wondering of somebody could maybe tell me how to basicly code a particle system to respond to sound interactions such as certain frequency's
I've found a nice tutorial here: http://www.41post.com/4776/programming/unity-making-a-simple-audio-visualization.
It is able to get different frequencies from the sounds and do something accordingly. You can try and change the variables of the particle with it.
Another thing I found is a project which analyses the spectrum of sound. You can download it here.
I also found this tutorial which generates a level based on the sound.
These links no longer works
Try them out and let us know what you thought of them and if they helped! Good luck.
I am working on a Kinect project that requires me to prompt the user to perform gestures. I have the gesture recognition completed, but was wanting to do something a bit more fun then having the screen just say "JUMP!".
Is there a fairly painless way to add a short video, gif or something? I would obviously have to create these animations as well, but I am more concerned with adding them to the application once I have the animations.
The animations being played would have to change throughout the program, as I will be prompting the user to perform various gestures.
I am completely open to any ideas or suggestions you guys might have.
Thanks!
Decided to try mediaElement. Seems to be working. If anyone stumbles across this, it can easily be changed in C# by setting the source attribute.
I have transitions in my game and they work fine, but I want to now play a video cut-scene between certain transitions but can't find out how to do it.
EDIT Actually I just found out that XNA 4.0 has video playing capabilities now, they just have to be in .wmv format. Thanks for any help.
You might want to check out http://xnadsplayer.codeplex.com, saw that linked in a few different places.
I'm trying to play a sound file in monotouch but it gets cut off after a second or two. Here is the code I'm using to play the sound:
SoundFileName = filename;
var sound = SystemSound.FromFile(filename);
sound.PlaySystemSound();
It's an MP3 file that I'm trying to play. Again, I hear it for a brief second and then it gets cut. I added a thread.sleep() line afterwards and THEN it'll play throughout.
But that's not ideal because the length of the mp3 files that I'm playing could vary. Any help would be greatly appreciated. Thank you.
You need to declare your sound object at the form or class level. In your posted sample, sound is only scoped to the function, so as soon as the method ends the variable goes out of scope and is disposed before the sound finished playing. Thread.sleep works because that call prevents the method from ending for a while (and thus prevents sound from going out of scope).
You may also want to look at this question: Playing a sound with MonoTouch
I don't think SystemSound is intended to use with MP3's of open duration.