解释程序时播放声音文件的vb 2010问题 [英] vb 2010 problem playing sound files when narrating program

查看:72
本文介绍了解释程序时播放声音文件的vb 2010问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试叙述一个描述如何下棋的程序.我播放声音文件的代码是[这是几个声音文件之一,带有显示操作的图片框]:

I''m trying to narrate a program describing how to play chess. My code for playing the sound file is [this is one of several sound files, with picture boxes showing the action]:

My.Computer.Audio.Play(My.Resources.BoardSquares, AudioPlayMode.WaitToComplete)



但是程序会等到所有声音文件都播放完之后,屏幕才会刷新以跟上叙述.



But the program waits until all sound files are played before the screen refreshes to catch up with the narration. How can I refresh the screen before the next sound file is played?

推荐答案

如果可以使用.NET Framework 3.5或更高版本(如果要使用Visual Studio,它应该是VS 2008或更高版本;但是绝对不需要Visual Studio来构建任何项目),您可以执行以下操作:引用程序集PresentationCode和WindowsBase(位于GAC中的WPF的一部分,因此请使用添加"的".NET"标记参考"窗口).

If you can use .NET Framework 3.5 or above (if you want to use Visual Studio, it should be VS 2008 or later; but Visual Studio is absolutely not required to build any project), you can do the following: reference assemblies PresentationCode and WindowsBase (part of WPF placed in GAC, so use ".NET" tag of "Add Reference" window).

Dim audioFileName As String = '...

'... ...

Dim player As New System.Media.SoundPlayer(audioFileName)
player.Play()



请参阅: http://msdn.microsoft.com/en-us/library/system .media.soundplayer.aspx [ ^ ].

它将异步播放(为防万一,我在发布代码之前对其进行了测试).
不用担心WPF:您的应用程序不必是WPF应用程序,它可以是任何东西.

一条建议:尝试仅使用.NET API,而不要使用VB专有的内容.

—SA



Please see: http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx[^].

It will play asynchronously (I tested it before posting the code, just in case).
Don''t worry about WPF: your application does not have to be a WPF application, it can be anything.

One advice: try to use .NET API only, and nothing VB-specific.

—SA


这篇关于解释程序时播放声音文件的vb 2010问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆