Playing sounds one at a time

Im building a windows phone 8/8.1 app which consists in playing sounds, the way im doing is once i press a button, it fires up the event and runs this code: StreamResourceInfo info = Application.GetResourceStream(new Uri("Assets/Sound/DO_converted.wav", UriKind.Relative)); SoundEffect sound = SoundEffect.FromStream(info.Stream); SoundEffectInstance instance = sound.CreateInstance(); instance.Pla

一次播放一个声音

我建立一个Windows Phone 8 / 8.1应用程序,其中包括播放声音,我做的方式是一旦我按下按钮,它启动事件并运行此代码: StreamResourceInfo info = Application.GetResourceStream(new Uri("Assets/Sound/DO_converted.wav", UriKind.Relative)); SoundEffect sound = SoundEffect.FromStream(info.Stream); SoundEffectInstance instance = sound.CreateInstance(); instance.Play(); 但是,如果我按下更多,然后一个按钮,我

sound not playing at the right moment

I created a MediaElement for a Background Music in my Windows Phone App and it plays perfectly now the problem when I tried to add sound for a button when pressed When I debug , the Background music plays , but when I press the button it navigates me to the next page without playing the sound I created, and when I press BackButton from the Navigated Page , it plays it, why? code: private voi

声音不在正确的时刻播放

我在我的Windows Phone应用程序中为背景音乐创建了一个MediaElement ,当我尝试在按下按钮时为其添加声音时,它现在完全播放问题 当我调试时, 背景音乐会播放 ,但是当我按下按钮时,它会导航到下一页, 而不播放我创建的声音,并且当我从导航页按BackButton时,它会播放它,为什么? 码: private void play_Click(object sender, RoutedEventArgs e) { MediaElement Click = new MediaElement(); Click.Source =

C# playing multiple audio files at once from your resources?

I'd like to be able to press a button to play a sound of a button being pressed while music is already playing. SoundPlayer is no help because it stops the music to play the sound. I have added the sounds to my Resources (WindowsFormsApplication2.Resources.Properties.button) and I don't want to have to type in the file location. Answer from MerickOWA You CANNOT play two sounds at on

C#从您的资源中一次播放多个音频文件?

我希望能够在播放音乐时按下按钮来播放按钮的声音。 SoundPlayer没有帮助,因为它会阻止音乐播放声音。 我已将声音添加到我的资源(WindowsFormsApplication2.Resources.Properties.button),我不想输入文件位置。 来自MerickOWA的答复 使用SoundPlayer无法一次播放两种声音。 SoundPlayer使用本机WINAPI PlaySound功能来完成不支持播放同步声音的任务。 创建SoundPlayer的多个实例将无济于事。 有很多选项,其中大

Console Application c# background music

This question already has an answer here: Play multiple sounds using SoundPlayer 5 answers You're using the win32 function PlaySound, correct? If you look at the documentation, you'll see that there is a flag called SND_NOSTOP. If you set this flag, PlaySound will not attempt to stop sounds which are playing from the process. Here's the documentation: http://msdn.microsoft.com

控制台应用程序c#背景音乐

这个问题在这里已经有了答案: 使用SoundPlayer 5回答播放多个声音 你正在使用win32函数PlaySound,对吗? 如果您查看文档,您会看到有一个名为SND_NOSTOP的标志。 如果您设置了此标志,则PlaySound不会尝试停止正在播放的声音。 这里的文档:http://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx 这里有一个在C#中使用PlaySound的指南,其中包括标志,所以你可以自己设置:http://www.c

Playing same sound many times C# WPF

I'm trying to play the same overlapping sound whenever a button is pressed. I tried with MediaElement and SoundPlayer, but the music stops and starts again. I need to create a new instance, but creating new MediaElement() and adding to the Stage didn´t work too :-/ Thanks for your help Check here: http://www.interact-sw.co.uk/iangblog/2008/01/25/wpf-concurrent-audio Create multiple Me

多次播放相同的声音C#WPF

我试图在按下按钮时播放相同的重叠声音。 我尝试使用MediaElement和SoundPlayer,但音乐停止并重新开始。 我需要创建一个新的实例,但是创建新的MediaElement()并添加到舞台上并没有工作: - / 谢谢你的帮助 点击这里查看:http://www.interact-sw.co.uk/iangblog/2008/01/25/wpf-concurrent-audio 在CodeBehind中创建多个MediaPlayers。 我没有成功与MediaPlayers,但它的工作原理: MediaElement mp = new MediaEle

Playing two sounds simultaneously c#

I am creating a WP7 application that requires various sound effects to be played (on button press) over looped background music. The background music is initiated by pressing Button 1 and loops fine. When I press button3 (triggers a sound effect), the sound effect overlays on the background music fine on first press. However, when I press button3 again, the background music stops. I cannot fi

同时播放两个声音c#

我正在创建一个WP7应用程序,需要在循环播放的背景音乐上播放各种音效(按下按钮时)。 背景音乐通过按下按钮1启动并循环播放。 当我按下按钮3(触发声音效果)时,首次按下后,音效就会叠加在背景音乐上。 但是,当我再次按下按钮3时,背景音乐停止。 我无法弄清楚为什么会发生这种情况!? 我已经粘贴了以下代码的相关部分。 将不胜感激任何帮助。 public partial class MainPage : PhoneApplicationPage { SoundEff

Play wav file async multiple times with .net

I have an app that I need to play a wav file when a key is pressed, I use the SoundPlayer class but if another sound is being played when a new key is pressed, it stops the sound the play it again making it look ugly.... is there any way to play the same sound again even if there is another of being played? thanks! Use PlaySound from the windows API in combination with the SND_ASYNC and SND

使用.net多次播放wav文件

我有一个应用程序,当按下一个按键时需要播放一个wav文件,我使用SoundPlayer类,但是如果在按下一个新键时播放另一个声音,它会停止播放声音,使其看起来很难看。 ... 有什么方法可以再次播放相同的声音,即使有另一个正在播放? 谢谢! 将Windows API中的PlaySound与SND_ASYNC和SND_NOSTOP标志结合使用。 http://www.pinvoke.net/default.aspx/winmm.playsound 用法 //And the actual usage PlaySound (fileName, UI

Redrawing Client Area with transparency

I need to render only the Client Area of a Control (TextBox) on winforms with transparency using GDI, because GDI+ doesn't support transparency for dynamic controls. I've already searched a lot, for two days, and founded two links: https://msdn.microsoft.com/en-us/library/windows/desktop/dd162910(v=vs.85).aspx http://www.winprog.org/tutorial/transparency.html I think if i join thes

用透明度重绘客户区

因为GDI +不支持动态控件的透明度,所以我只需要使用GDI以透明度渲染Winforms上的控件(TextBox)的客户区。 我已经搜索了很多,两天,并建立了两个链接: https://msdn.microsoft.com/en-us/library/windows/desktop/dd162910(v=vs.85).aspx http://www.winprog.org/tutorial/transparency.html 我想如果我加入这两个解决方案,我可以获得我想要的,但我不知道如何将它们放入代码中。 有人可以帮助我吗? 我试过使用A

How do I make a WPF window movable by dragging the extended window frame?

In applications like Windows Explorer and Internet Explorer, one can grab the extended frame areas beneath the title bar and drag windows around. For WinForms applications, forms and controls are as close to native Win32 APIs as they can get; one would simply override the WndProc() handler in their form, process the WM_NCHITTEST window message and trick the system into thinking a click on the

如何通过拖动扩展窗口框架来移动WPF窗口?

在Windows资源管理器和Internet Explorer等应用程序中,可以抓取标题栏下方的扩展框架区域并拖动窗口。 对于WinForms应用程序,表单和控件尽可能接近本机Win32 API; 我们可以简单地覆盖WndProc()处理程序的形式,处理WM_NCHITTEST窗口消息,并诱使系统认为点击框架区域真的是通过返回HTCAPTION在标题栏上单击。 我已经在我自己的WinForms应用程序中做到了这一点,以获得令人愉快的效果。 在WPF中,我也可以实现一个类似的W

How to make an OpenGL rendering context with transparent background?

Rendering contexts usually have a solid color on the background (black or whatever, see the image below): I'm wondering if it's possible to setup a window, with no decorations AND with the transparent background, while allowing me to render OpenGL stuff on it. This would give the illusion that the triangle is floating on the screen. The transparent background should allow you to see

如何使透明背景的OpenGL渲染上下文?

渲染上下文通常在背景上具有纯色(黑色或其他,请参阅下图): 我想知道是否可以设置一个窗口,没有装饰和透明背景,同时允许我渲染OpenGL的东西。 这会产生错觉,三角形在屏幕上浮动。 透明背景应该允许您查看可能位于其后面的桌面或其他应用程序。 你能举例说明源代码吗? 平台:Windows(仅限win32) 在一个不成功的奖金上花费一些名声来获得一些关于这个问题的帮助后,我终于意识到我感兴趣的问题有多复杂。 少