Solved

synchronously or asynchronously ?? - playsound problem on large wav files

Posted on 2010-09-05
3
530 Views
Last Modified: 2012-05-10
I have a large vinyl record collection - 18,000 - and am in the process of recording them to computer at very high WAV quality - 32 bit , 48,000 hrz.  In writing the code in VB to play any I have recorded, the search for Artist/Album works great in my SQL database and displays the search in my DatGridview.  Then I select the Artist and/or Album to play and hit my Play button.  Stored with the Artist/Album is the full directory location of the matching WAV file.  
The Play button activates the Playit Sub where i activate MPlayer set on load to make Global.  It plays the large WAV file fine until I click on a different Artist/Album choice and hit play.  The WAV file playing stops immediately, but the new choice only sometimes does it start to play.  How can I solve this problem?  If it doesn't play, it will hang until I close the program and reload.  Thanks Marvin E Marshall

  Dim StopMusic As Boolean = True    ' These Dims are set at top of code under Imports
  Dim WaveFile As String = ""
  Dim Mplayer As New SoundPlayer()

 Public Sub Playit()
        Dim rowSl As Integer = 0
        Dim cell1, cell2, cell3, cell4, cell5 As String

        rowSl = DataGridView2.CurrentRow.Index

        cell1 = DataGridView2.Item(1, rowSl).Value
        cell2 = DataGridView2.Item(2, rowSl).Value
        cell3 = DataGridView2.Item(3, rowSl).Value
        cell4 = DataGridView2.Item(4, rowSl).Value
        cell5 = DataGridView2.Item(5, rowSl).Value

        Dim ln As Integer = 0
        ln = Len(Cell1)
        WaveFile = Cell1

        Mplayer.Stop()
        Application.doevents

        Mplayer.SoundLocation = cell1
         ' Mplayer.Play()
        Mplayer.PlaySync()

        txtPlaying.Text = WaveFile

    End Sub
0
Comment
Question by:MarvinEMarshall
  • 2
3 Comments
 
LVL 3

Expert Comment

by:AndyEastham
ID: 33609674
Hi,

This code contains some ideas to try:

 Mplayer.Stop()
        Application.doevents
        Thread.Sleep(1000) ' Wait a second
       
        Mplayer.SoundLocation = Nothing ' Will force reload
        Mplayer.SoundLocation = cell1
        Mplayer.Load() ' Need to reload if path changed
        Mplayer.Play()
        ' Mplayer.PlaySync()


Andy
0
 

Author Comment

by:MarvinEMarshall
ID: 33612849
AndyEastham

Thanks Andy.    I tried your code suggestion and variations. they seemed logical.  As far as the wait of one second  I changed that to - Threading.Thread.Sleep(1000)  which works without declaring.  However, the Mplayer.SoundLocation = Nothing throws and exception - and "" does the same.  Although, the idea seemed logical, so I created two 5 second wav files called Blank.wav and Blank2.wav.  Then if the Boolean MusicActive is true then I give Mplayer.SoundLocation that address and play it.  That still didn't clear things out enough, so I repeated the idea so I play both Bank stopped it cleared the location and then did the same for Blank2.  Both would play instantly - I made a couple of scratch sounds on them both just to verify they actually played.  Then after both played entirely - just 5 seconds each, I felt surely  the large uncompleted first wav file would be cleaned out of memory.  Nope, when a large file is then selected even after playing the two Blanks.  Even if I wait several minutes after the code executes the Load and Play lines of code and returns me back to my form.
So, there hast to be a way to force the memory block that loads the large wav file to clear or release after forciing a Mplayer.Stop()
I guess we can learn together on this one.  Thanks for your suggestions - Marvin E Marshall
0
 

Accepted Solution

by:
MarvinEMarshall earned 0 total points
ID: 33663515
AndyEastham,
Took a lot of research, but the disappointing fact is that the use of soundplayer is severaly limited and WILL NOT support of large WAV files if you want to move from one to another prior to it completing.

I guess we both learned on this one.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question