Click here to Skip to main content
11,932,103 members (49,701 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB10.0
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?
Posted 16-Nov-12 9:59am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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)

Please see:[^].

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.

Sergey Alexandrovich Kryukov 18-Nov-12 21:59pm
You are welcome. It will work, for sure.
Good luck, call again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100