Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:45:45+00:00 2026-06-15T17:45:45+00:00

I have the following code: http://pastebin.com/EgjbzqA2 which is basically just a stripped down version

  • 0

I have the following code: http://pastebin.com/EgjbzqA2 which is basically just a stripped down version of http://www.dreamincode.net/forums/topic/57357-mymusic-player/. I want the program to play one file repeatedly, however, this function doesn’t work for some reason. The program plays each file once and then stops.

Private Sub Player3_PlayStateChange(ByVal NewState As Integer) Handles Player3.PlayStateChange
    Static Dim PlayAllowed As Boolean = True
    Select Case CType(NewState, WMPLib.WMPPlayState)
        Case WMPLib.WMPPlayState.wmppsReady
            If PlayAllowed Then
                Player3.controls.play()
            End If
        Case WMPLib.WMPPlayState.wmppsMediaEnded
            ' Start protection (without it next wouldn't play
           PlayAllowed = False
            ' Play track
           Player3.controls.play()
            ' End Protection
           PlayAllowed = True
            updatePlayer()
    End Select
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:45:46+00:00Added an answer on June 15, 2026 at 5:45 pm

    The PlayAllowed doo-wop is hackorama to work around a control getting cranky when you ask it to do something else in an event. That often goes wrong, they don’t expect the floor mat to be jerked when they fire an event. The technical term is that they don’t handle re-entrancy well, a very common problem.

    There’s a very elegant solution to re-entrancy problems, the key is that you delay the request to play the same song again, after the event was raised. In Winforms you can easily get such a delay by using Control.BeginInvoke(), the target runs after everything settles back down. The technical term for that is “waiting for the program to re-enter the message loop”. That worked very well on this code, I had no trouble looping the same song over and over again with this code, tested on Windows 8:

    Public Class Form1
        Dim WithEvents Player3 As New WMPLib.WindowsMediaPlayer
        Dim Song As String = "c:\temp\ding.wav"
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            PlayCurrentSong()
        End Sub
    
        Private Sub Player3_PlayStateChange(ByVal NewState As Integer) Handles Player3.PlayStateChange
            If NewState = WMPLib.WMPPlayState.wmppsMediaEnded Then
                Me.BeginInvoke(New MethodInvoker(AddressOf PlayCurrentSong))
            End If
        End Sub
    
        Private Sub PlayCurrentSong()
            Player3.URL = Song
            Player3.controls.play()
        End Sub
    End Class
    

    Tweak the code as needed since it won’t match yours very well. The essential part is the Me.BeginInvoke() call in the PlayStateChanged event handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code http://pastebin.com/vLeD1GJm wich works just fine, but if I increase:
I have the following code; http://pastebin.com/Wf598D2E But I can't get distance value to #result
I have the following code: String website = http://www.somewebsite.com/; Document doc = Jsoup.connect(website).get(); Elements
i have the following simple grid960 HTML code: http://pastebin.com/m1SYMH5S but it looks verry different
I have the following code: http://pastebin.com/U9qYSmET When I try to telnet into my server
I went through the code at the following two links: http://pastebin.com/iUd22CRY http://www.jensbits.com/2009/10/04/jquery-ajax-and-jquery-post-form-submit-examples-with-php Everything seems
I have the following code: http://pastebin.com/gg4kgGKz On line 240 of the pastebin code, I
I have the following sample HTML code: http://pastebin.com/Mya6tPc6 And here is the jQuery code
I have the following XML: http://pastebin.com/QiRK72BK which is generated in response to a REST
I have problems with following code: http://lisper.ru/apps/format/96 The problem is in normalize function, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.