none
How to stop WebBrowser in vb.net RRS feed

  • Question

  • hi

    i use this code to play online music in app background

     WebBrowser1.Navigate("http://173.236.48.82:80/nexuspop.aac")

    and it work perfectly , but  when i use this codes to stop playing music 

     WebBrowser1.Stop()

    or even

    WebBrowser1.Navigate("http://www.google.com")

    its dont work And the music continues to play back in the background

    how can i stop music !!


    Tuesday, July 9, 2019 10:22 AM

All replies

  • Hi,

    Do you want to close an external program?You can close the program with a handle.

    Imports System.Runtime.InteropServices
    Imports System.Text
    
    Public Class Form1
        <DllImport("User32.dll", EntryPoint:="FindWindow")>
        Public Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
        End Function
        <DllImport("user32.dll", EntryPoint:="SendMessageA")>
        Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
        End Function
        Const WM_CLOSE As Integer = &H10
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate("http://audio.o1xfo1rddictionaries.com/en/mp3/test.mp3")
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Dim maindHwnd As IntPtr = FindWindow(Nothing, "Groove Music(Music Program Name)")
            If maindHwnd <> IntPtr.Zero Then
    
                SendMessage(maindHwnd, WM_CLOSE, 0, Nothing)
            Else
                MsgBox("No Find Main Window")
            End If
        End Sub
    End Class

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Wednesday, July 10, 2019 2:00 AM
    Moderator
  • Hi Alex

    thank for reply

    no i went to stop internal web browser (WebBrowser Component)

    this code should work

    WebBrowser1.Stop()

    but it not work and webbroswer will continues in background


    Wednesday, July 10, 2019 8:00 AM
  • Hi,

    internal web browser?not close such an external music program?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, July 10, 2019 8:52 AM
    Moderator
  • ok look like u dont understand my problem

    i use this code

    Public Class Form1
    
    WebBrowser1.Visible=False
    
       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       WebBrowser1.Navigate("http://173.236.48.82:80/nexuspop.aac")
       End Sub
    
       Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button1.Click
        WebBrowser1.Stop()
       End Sub
    
    End Class
    

    Button1 will work good and music file play in background

    but Button2 dont work!!

    Wednesday, July 10, 2019 1:15 PM
  • Hi,

    I use WebBrowser1 to open an online aac file. The result is to call windows10's own player to open the aac file. I thought you wanted to close the music player that comes with Windows.

    or try the code:

    WebBrowser1.Navigate("")

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 11, 2019 3:03 AM
    Moderator
  • hello Alex

    i tested this code before and it don't work

    WebBrowser1 will continue playing music even when i use this

    WebBrowser1.Stop()

    or

    WebBrowser1.Navigate("www.google.com")

    i think WebBrowser1 cache music file , and cached music will continue even after use above codes




    Sunday, July 14, 2019 2:08 PM
  • Hi,

    Are you sure that the player that comes with Windows is not playing music?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 15, 2019 6:29 AM
    Moderator