I have a form and a class module.
the application plays a sound file from using a windows media player control on the form. it seems silly to me that you need to have a hidden visual control on a form rather than just using code, but that's another gripe.
previously, the code (in the form module) was :
this worked perfectly.
i then changed things so that this calling code is in a class module:
and this code is in the form module:
and i hear no music
the funny thing is: if i put
in Sub Play, the audio file plays, until i dismiss the msgbox.
the application plays a sound file from using a windows media player control on the form. it seems silly to me that you need to have a hidden visual control on a form rather than just using code, but that's another gripe.
previously, the code (in the form module) was :
VB.NET:
Private Sub Something()
Call PlayMusic("filepath/filename.mp3")
End Sub
Private Sub PlayMusic(strPathName As String)
Me.AxWindowsMediaPlayer1.URL = strPathName
End Sub
this worked perfectly.
i then changed things so that this calling code is in a class module:
VB.NET:
Public Class Music
Private WithEvents frm1 As frmMain
Sub Play(ByVal strPathName As String) 'this proc uses its own thread
frmMain.AxWindowsMediaPlayer1.URL = strPathName
End Sub
End Class
and this code is in the form module:
VB.NET:
Private Snippet As Music
Private Sub Form1_Load(etc) Handles MyBase.Load
Snippet = New Music
Snippet.Play(filepath/filename.mp3")
End Sub
and i hear no music
the funny thing is: if i put
VB.NET:
msgbox("test")"
in Sub Play, the audio file plays, until i dismiss the msgbox.
Last edited: