Click here to Skip to main content
11,492,385 members (63,645 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: 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 at 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
0 Sergey Alexandrovich Kryukov 404
1 Maciej Los 266
2 KarstenK 220
3 Sascha Lefèvre 215
4 CPallini 208
0 Sergey Alexandrovich Kryukov 9,943
1 OriginalGriff 8,610
2 Sascha Lefèvre 3,609
3 Maciej Los 3,372
4 Richard Deeming 2,440

Advertise | Privacy | Mobile
Web03 | 2.8.150520.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