Click here to Skip to main content
Rate this: bad
good
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 8:59am

1 solution

Rate this: bad
good
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)
player.Play()
 
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
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov at 18-Nov-12 21:59pm
   
You are welcome. It will work, for sure.
Good luck, call again.
--SA

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 6,676
1 OriginalGriff 6,056
2 CPallini 2,473
3 Richard MacCutchan 1,697
4 Abhinav S 1,560


Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
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