Media Player in VB.NET

Media-Player-in-VB.NET.gif

This program for the disabled people who can't speak to help them in chanting God's Names. It is believed that if you listen God almost 24 hrs. Then you get salvation. 

Public Class Frmmantraplayer
    'for close button declaration
    Private Const MF_BYPOSITION = &H400
    Private Const MF_REMOVE = &H1000
    Private Const MF_DISABLED = &H2
    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
    Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
    Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean

    Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
        Dim hMenu As IntPtr
        Dim menuItemCount As Integer
        hMenu = GetSystemMenu(hwnd, False)
        menuItemCount = GetMenuItemCount(hMenu)
        Call RemoveMenu(hMenu, menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)
        Call RemoveMenu(hMenu, menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
        Call DrawMenuBar(hwnd)
    End Sub

    Private Sub frmmantraplayer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call DisableCloseButton(Me.Handle)
    End Sub

    Private Sub cmdopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdopen.Click
        'If axMantraAVmv.URL = "" Then Exit Sub
        If Txtplaycount.Text = "" Then Exit Sub
        axMantraAVmv.settings.playCount = Txtplaycount.Text
        lbldisplayplaycount.Text = Txtplaycount.Text
        OpenFileDialog1.Filter = "Audio Wave files(*.wav)|*.wav|MP3 files (*mp3)|*.mp3|MP4 files(*.mp4)|*.mp4|All files(*.*)|*.*"
        OpenFileDialog1.FilterIndex = 2
        OpenFileDialog1.ShowDialog()
        axMantraAVmv.URL = OpenFileDialog1.FileName
    End Sub

    Private Sub btnplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.Click
        axMantraAVmv.Ctlcontrols.play()
    End Sub

    Private Sub btnpause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnpause.Click
        axMantraAVmv.Ctlcontrols.pause()
    End Sub

    Private Sub bntstopped_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntstopped.Click
        axMantraAVmv.Ctlcontrols.stop()
    End Sub

    Private Sub CmdRefresh_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdRefresh.Click
        axMantraAVmv.Ctlcontrols.stop()
        axMantraAVmv.Refresh()
        Txtplaycount.Text = ""
        lbldisplayplaycount.Text = ""
    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Dim msg As String
        Dim title As String
        Dim style As String
        Dim response As String
        msg = "Are sure you don't you want to continue?"
        style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Question Or MsgBoxStyle.YesNo
        title = "Quitting Percent APP"
        response = MsgBox(msg, style, title)
        If response = MsgBoxResult.No Then
            MsgBox("You cannot quit, clear values please!")
        Else
            Me.Close()
            End
        End If
    End Sub

    Private Sub cmdvolcontrol_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdvolcontrol.Click
        'MantraAVmv.ShowPropertyPages()
        Shell("C:\WINDOWS\system32\sndvol32.exe", AppWinStyle.NormalFocus)
    End Sub

    Private Sub axMantraAVmv_MediaChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MediaChangeEvent) Handles axMantraAVmv.MediaChange
        Txtplaycount.Text = Val(Txtplaycount.Text) - 1
    End Sub
End Class


Similar Articles