soundplayer

asp.net SoundPlayer not playing from server

↘锁芯ラ 提交于 2019-12-12 00:50:16
问题 I have made the simplest test in order to check if SoundPlayer will play a wave file. From the local machine works just fine, once the site is on IIS it doesn't play the sounds (or give any error). Here is the code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Media; public partial class Default2 : System.Web.UI.Page { public SoundPlayer spWave; protected void Page_Load(object sender,

URI Prefix not supported

人盡茶涼 提交于 2019-12-11 19:53:09
问题 I am trying to load and play a wave file using: SoundPlayer simpleSound = new SoundPlayer(@"pack://application:,,,/MyAssembly;component/Sounds/10meters.wav"); simpleSound.Play(); With no success. I get a System.NotSupportedException :( see below. System.NotSupportedException: The URI prefix is not recognized. at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Net.WebRequest.Create(Uri requestUri) at System.Media.SoundPlayer.LoadSync() at System.Media.SoundPlayer

Play a sound while key is down

心已入冬 提交于 2019-12-11 19:18:16
问题 i would like to play a sound in C# while the key is down. If the key is released the sounds automatically stops. This is what I have so far: var player = new System.Windows.Media.MediaPlayer(); try { player.Open(new Uri(label46.Text)); player.Volume = (double)trackBar4.Value / 100; player.Play(); } catch (FileNotFoundException) { MessageBox.Show("File has been moved." + "\n" + "Please relocate it now!"); } 回答1: You can handle this through KeyDown and KeyUp events. For this, both events needs

System.Media.SoundPlayer, Playing more than 1 sound?

那年仲夏 提交于 2019-12-11 10:06:27
问题 Is there a way to play more than one sound while let's say the background music is going? The way I have it is: public static void PlaySound(string filename) { SoundPlayer player = new SoundPlayer(); player.SoundLocation = filename; player.Play(); } Which will play one sound, but using the same "PlaySound" it will basically stop the last sound played and just start a new thread playing the new sound. Is there a way to actually stop this and play more than one sound(s)? 回答1: Take a look at:

SoundPlayer not playing any bundled windows sounds PCM wav files

蓝咒 提交于 2019-12-11 03:29:11
问题 In C# I cannot get SoundPlayer class from System.Media to play any wav from my C:\Windows\Media folder using the following code. All I get is no sound: String filename = "C:\\Windows\\Media\\tada.wav"; SoundPlayer sp = new SoundPlayer(filename); sp.Load(); sp.Play(); I have checked the wave file "tada.wav" with a program called "Gspot" that tells me the audio codec is "PCM Audio". I do not receive any compiler warnings or errors and there is no exceptions raised when I run the program. I just

How to play a music file for a specified amount of time

独自空忆成欢 提交于 2019-12-11 02:44:48
问题 What I'm trying to do is play a music file for a specified duration, and then stop playing. However, the whole music file is being played. Any ideas? I've tried starting a new thread, still doesnt work. 回答1: The problem is that PlaySync blocks the thread, so other messages won't be processed. This includes your stop command from the Tick event. You have to use the regular Play function, which will be asynchronous and creates a new thread to play the file in. You will have to handle the

Windows Form: Play sound, but not from beginning

孤街浪徒 提交于 2019-12-11 00:36:39
问题 I want to play a track (.wav file) in my Windows Forms Application . But I do not want it to play from the beginning, but from a certain point somewhere in the track (let's say 10 seconds). To play the track from beginning is no problem: private void playSimpleSound() { SoundPlayer simpleSound = new SoundPlayer(@"c:\Windows\Media\sound.wav"); simpleSound.Play(); } But how can I skip the first 10 secons, and play only the rest of it? Thanks in advance! 回答1: SoundPlayer class not to support to

SoundPlayer causing Memory Leaks?

梦想与她 提交于 2019-12-09 16:11:38
问题 I'm writing a basic writing app in C# and I wanted to have the program make typewriter sounds as you typed. I've hooked the KeyPress event on my RichTextBox to a function that uses a SoundPlayer to play a short wav file every time a key is pressed, however I've noticed after a while my computer slows to a crawl and checking my processes, audiodlg.exe was using 5 GIGABYTES of RAM. The code I'm using is as follows: I initialise the SoundPlayer as a global variable on program start with

Is it possible to play 2 sounds back to back using SoundPlayer?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 03:32:51
问题 I'm looking for a way to play multiples sound back to back asynchronously. I actually have : jouerSon("_" + nbre1); jouerSon(operateur); jouerSon("_" + nbre2); jouerSon("equal"); public void jouerSon(String son) { System.Media.SoundPlayer player = new SoundPlayer(); player.Stream = Properties.Resources.ResourceManager.GetStream(son); // player.LoadAsync(); player.Play(); //Thread.Sleep(500); //player.Stop(); } I'd like to play the first sound, then when it's over the second one etc all while

powershell 'system.windows.media.mediaplayer' Register-ObjectEvent

跟風遠走 提交于 2019-12-04 05:27:35
问题 I'm trying to use the 'system.windows.media.mediaplayer' media player, to play a list of sound files, however I'm having trouble getting the media player to know when to play the next sound file. I'm trying to use the 'MediaEnded' event handle to work out when the sound file has ended, then move onto the next sound file. But I can't get the event handle to fire properly, could someone show me where I'm going wrong please? This is the code I'm using: Add-Type -AssemblyName presentationCore