Solved

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

Posted on 2010-09-05
3
528 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now