I keep getting null reference error

Posts 1–4 of 4 · Page 1 of 1
I keep getting null reference error
Every time i run this and click the button i get a null reference error

Code:
Imports System****
Imports WMPLib
Imports AxWMPLib

Public Class Form1

    Dim WithEvents myplayer As AxWMPLib.AxWindowsMediaPlayer
    Private Sub PlayFile(ByVal url As String)
        myplayer = New AxWMPLib.AxWindowsMediaPlayer
        myplayer.URL = ("C:\Users\JeanneSky\Documents\lalala.wma")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        myplayer.Ctlcontrols.play()

    End Sub




End Class
Try WithEvents myplayer As NEW AxWMPLib.AxWindowsMediaPlayer.
I get System.Windows.Forms.AxHost+InvalidActiveXStateExc eption on myplayer.Ctlcontrols.play() fml i might use direct sound

because I heard there the same execpt direct sound is harder
Alright Im now trying to use System.Media.SoundPlayer its playing perfect but I play lalala.wav and when i play GA005.wav they dont play spontaneously how can i do this maybe using this with mciSendString API somehow?

module1
Code:
Module Module1
    Private PlaySound As New System.Media.SoundPlayer
    Private kick As New System.Media.SoundPlayer
    Public Sub PlaySoundFile(ByVal SoundPath As String)
        PlaySound.SoundLocation = SoundPath
        PlaySound.Load()
        PlaySound.Play()
    End Sub
    Public Sub kickfile(ByVal SoundPath As String)
        kick.SoundLocation = SoundPath
        kick.Load()
        kick.Play()
    End Sub
End Module

form1
Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        kickfile("C:\Users\JeanneSky\Desktop\leo\Sounds\drumkit\KICK\GA005.wav")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        PlaySoundFile("C:\Users\JeanneSky\Desktop\lalala.wav")
    End Sub
End Class
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?