none
Suppress messages from embedded Windows Media PLayer RRS feed

  • Question

  • I am handling the Mediaplayer-MediaError-Event by own code, telling the user more specific items then the automatically shown player-errormessage-box does.

    So I would like to supress the mediaplayer's own message. Is this possible?

    (the same question on stackoverflow 6 years ago is not exactly the same and the answer does not hit my issue)


    Tuesday, September 10, 2019 8:11 PM

Answers

  • Solution-summary

    Import WMPLib

    In Formload:
    WMPlayer.settings.enableErrorDialogs = False
    that makes the WMPlayer_ErrorEvent raising after an Error (only now it raises), which I don't use because:

    Before WMPlayer_ErrorEvent the WMPlayer_MediaError-Event is raising. Here I handle the errormessage my way.


    Wednesday, September 11, 2019 7:38 PM

All replies

  • Internally there is only ErrorEvent which does not suppress the error.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, September 11, 2019 1:12 AM
    Moderator
  • Hi,

    You can use Handle to close the error window,my demo:

    Imports System.Runtime.InteropServices
    
    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:="SendMessage", SetLastError:=True, CharSet:=CharSet.Auto)>
        Public Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
        End Function
        Private Const WM_CLOSE As Integer = &H10
        Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Await Task.Run(Sub()
                               AxWindowsMediaPlayer1.URL = "D:\test.exe"
                           End Sub)
            Dim maindHwnd As IntPtr = FindWindow(Nothing, "Windows Media Player")
    
            If maindHwnd <> IntPtr.Zero Then
                SendMessage(maindHwnd, WM_CLOSE, 0, 0)
            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, September 11, 2019 2:14 AM
    Moderator
  • Internally there is only ErrorEvent which does not suppress the error.

    ?
    I'm dealing with the MediaError-Event. The Error-Event does not fire for files, which cannot be played, (because I have corrupted them for testing purpose.)
    Wednesday, September 11, 2019 5:47 PM
  • Thank you Alex, seems to be a solution.

    My problem: you start it with an async sub. I have never dealt with that stuff.
    I start in in a normal sub with the command 'wmplayer.Ctlcontrols.play()', but I suppose, that is the issue. I cannot put this sub to Private async sub... (VS2010)

    I suppose, the message-window pops up 'later' - I cannot find this window after wmplayer.Ctlcontrols.play() nor in the media-error-event.

    But:

    after searching around I found the IWMPSettings::enableErrorDialogs property. This is the way, MS recommends, to suppress the Player-Messagebox.

    Works fine! Thank you anyway!


    Wednesday, September 11, 2019 6:51 PM
  • Solution-summary

    Import WMPLib

    In Formload:
    WMPlayer.settings.enableErrorDialogs = False
    that makes the WMPlayer_ErrorEvent raising after an Error (only now it raises), which I don't use because:

    Before WMPlayer_ErrorEvent the WMPlayer_MediaError-Event is raising. Here I handle the errormessage my way.


    Wednesday, September 11, 2019 7:38 PM