Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Replication question 9 43
VB.net and sql server 4 36
Update a text value in another table 10 40
divide by zero error 23 16
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

778 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