Author Topic: Direct bass : Vb.net (vb2008, vb2010, vb6, vc#, vc++, devC++, delphi, AutoIt)  (Read 182682 times)

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #150 on: 7 Mar '14 - 20:46 »
LibZPlay EQualizer ;D

Example:
Code: [Select]
Imports System.Windows.Forms
Imports libZPlay.net
Public Class Form1
    Inherits Form
    Private player As ZPlay
    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        player = New ZPlay
        trackPreEQ.Minimum = -20000
        trackPreEQ.Maximum = 20000
        trackPreEQ.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ1.Minimum = -20000
        trackEQ1.Maximum = 20000
        trackEQ1.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ2.Minimum = -20000
        trackEQ2.Maximum = 20000
        trackEQ2.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ3.Minimum = -20000
        trackEQ3.Maximum = 20000
        trackEQ3.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ4.Minimum = -20000
        trackEQ4.Maximum = 20000
        trackEQ4.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ5.Minimum = -20000
        trackEQ5.Maximum = 20000
        trackEQ5.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ6.Minimum = -20000
        trackEQ6.Maximum = 20000
        trackEQ6.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ7.Minimum = -20000
        trackEQ7.Maximum = 20000
        trackEQ7.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackEQ8.Minimum = -20000
        trackEQ8.Maximum = 20000
        trackEQ8.TickFrequency = trackPreEQ.Maximum / 100 * 20
        trackVolL.Maximum = 100
        trackVolL.TickFrequency = 10
        trackVolR.Maximum = 100
        trackVolR.TickFrequency = 10
        trackVolL.Value = 100
        trackVolR.Value = 100
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Audio File(*.wav;*.mp3)|*.wav;*.mp3"
    End Sub
    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        player.EnableEqualizer((CType(sender, CheckBox)).Checked)
    End Sub
    Private Sub trackPreEQ_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPreEQ.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerPreampGain(CInt(trackPreEQ.Value))
        End If
    End Sub
    Private Sub trackPreEQ_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPreEQ.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerPreampGain(CInt(trackPreEQ.Value))
        End If
    End Sub
    Private Sub trackEQ1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ1.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(0, CInt(trackEQ1.Value))
        End If
    End Sub
    Private Sub trackEQ1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ1.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(0, CInt(trackEQ1.Value))
        End If
    End Sub
    Private Sub trackEQ2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ2.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(1, CInt(trackEQ2.Value))
        End If
    End Sub
    Private Sub trackEQ2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ2.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(1, CInt(trackEQ2.Value))
        End If
    End Sub
    Private Sub trackEQ3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ3.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(2, CInt(trackEQ3.Value))
        End If
    End Sub
    Private Sub trackEQ3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ3.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(2, CInt(trackEQ3.Value))
        End If
    End Sub
    Private Sub trackEQ4_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ4.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(3, CInt(trackEQ4.Value))
        End If
    End Sub
    Private Sub trackEQ4_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ4.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(3, CInt(trackEQ4.Value))
        End If
    End Sub
    Private Sub trackEQ5_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ5.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(4, CInt(trackEQ5.Value))
        End If
    End Sub
    Private Sub trackEQ5_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ5.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(4, CInt(trackEQ5.Value))
        End If
    End Sub
    Private Sub trackEQ6_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ6.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(5, CInt(trackEQ6.Value))
        End If
    End Sub
    Private Sub trackEQ6_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ6.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(5, CInt(trackEQ6.Value))
        End If
    End Sub
    Private Sub trackEQ7_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ7.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(6, CInt(trackEQ7.Value))
        End If
    End Sub
    Private Sub trackEQ7_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ7.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(6, CInt(trackEQ7.Value))
        End If
    End Sub
    Private Sub trackEQ8_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ8.Scroll
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(7, CInt(trackEQ8.Value))
        End If
    End Sub
    Private Sub trackEQ8_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackEQ8.ValueChanged
        If player IsNot Nothing Then
            player.SetEqualizerBandGain(7, CInt(trackEQ8.Value))
        End If
    End Sub
    Private Sub trackVolL_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVolL.Scroll
        On Error Resume Next
        Dim left As Integer
        Dim right As Integer
        player.GetMasterVolume(left, right)
        player.SetMasterVolume(CInt(trackVolL.Value), CInt(trackVolR.Value))
    End Sub
    Private Sub trackVolL_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVolL.ValueChanged
        On Error Resume Next
        Dim left As Integer
        Dim right As Integer
        player.GetMasterVolume(left, right)
        player.SetMasterVolume(CInt(trackVolL.Value), CInt(trackVolR.Value))
    End Sub
    Private Sub trackVolR_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVolR.Scroll
        On Error Resume Next
        Dim left As Integer
        Dim right As Integer
        player.GetMasterVolume(left, right)
        player.SetMasterVolume(CInt(trackVolL.Value), CInt(trackVolR.Value))
    End Sub
    Private Sub trackVolR_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVolR.ValueChanged
        On Error Resume Next
        Dim left As Integer
        Dim right As Integer
        player.GetMasterVolume(left, right)
        player.SetMasterVolume(CInt(trackVolL.Value), CInt(trackVolR.Value))
    End Sub
    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Me.Text = OpenFileDialog1.SafeFileName
        End If
    End Sub
    Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
        player.Close()
        Me.Text = OpenFileDialog1.SafeFileName
        player.OpenFile(OpenFileDialog1.FileName, TStreamFormat.sfAutodetect)
        Dim StreamInfo As New TStreamInfo()
        player.GetStreamInfo(StreamInfo)
        trackPos.Maximum = CInt(Fix(StreamInfo.Length.sec))
        trackPos.TickFrequency = CInt(trackPos.Maximum / 100 * 10)
        player.StartPlayback()
        Timer1.Enabled = True
    End Sub
    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        player.StopPlayback()
    End Sub
    Private Sub trackPos_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPos.Scroll
        Dim newpos As New TStreamTime()
        newpos.sec = CUInt(trackPos.Value)
        player.Seek(TTimeFormat.tfSecond, newpos, TSeekMethod.smFromBeginning)
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim pos As New TStreamTime()
        player.GetPosition(pos)
        trackPos.Value = CInt(Fix(pos.sec))
    End Sub
End Class

« Last Edit: 8 Mar '14 - 04:22 by sak2005 »

shakydd

  • Posts: 36
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #151 on: 8 Mar '14 - 12:37 »
I'm a bit confused here sak. I got the link (thanks for that) and the DLLs from that. I don't recognise the .NET DLL? Is that something you did yourself? Or is that Zoran's code wrapped up in a DLL? And then the examples you have - they are ZPlay examples, not anything to do with Bass? Or have you mixed the two? I can't work it out.... ::)

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #152 on: 8 Mar '14 - 15:38 »
I'm a bit confused here sak. I got the link (thanks for that) and the DLLs from that. I don't recognise the .NET DLL? Is that something you did yourself? Or is that Zoran's code wrapped up in a DLL? And then the examples you have - they are ZPlay examples, not anything to do with Bass? Or have you mixed the two? I can't work it out.... ::)

LibZPlay.net.dll cannot working with the Bass.
But PlayList.dll can be used with Bass or other.

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #153 on: 9 Mar '14 - 07:52 »
Free download: BASS PlayList Player Sample Project ;D
The PlayList can show and hiden. :)
NoneStop and Repeat Playing. ;)
Drag and Drop Songs to the playlist. 8)
Using contextMenu clear select item in the playlist. :D

« Last Edit: 9 Mar '14 - 08:06 by sak2005 »

shakydd

  • Posts: 36
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #154 on: 9 Mar '14 - 17:33 »
Looks nice but couldn't see the link again sak  ;D

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #155 on: 10 Mar '14 - 11:09 »
Looks nice but couldn't see the link again sak  ;D

I'm doing modify , please wait!.. ::)

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #156 on: 17 Mar '14 - 00:14 »
Tip! ;D EventHandler Level Sound Position, Using level sound for event tick.

Example:
Code: [Select]
Imports Un4seen.Bass
Public Class Form1
    Private WithEvents openplayBtn As New Button
    Private WithEvents pauseBtn As New Button
    Private WithEvents trackPos As New TrackBar
    Private WithEvents lblDuration As New Label
    Private progBar1 As New ProgressBar
    Private progBar2 As New ProgressBar
    Private openfileDlg As New OpenFileDialog
    Private strm As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)
    End Sub

    Public Sub New()
        InitializeComponent()
        openplayBtn.Name = "Button1"
        openplayBtn.Text = "Open"
        openplayBtn.Location = New Point(50, 200)
        pauseBtn.Name = "Button2"
        pauseBtn.Text = "Pause"
        pauseBtn.Location = New Point(150, 200)
        lblDuration.Text = "00:00/00:00"
        lblDuration.AutoSize = True
        lblDuration.Location = New Point(100, 150)
        trackPos.Width = 200
        trackPos.Location = New Point(30, 100)
        progBar1.SetBounds(30, 35, 200, 13)
        progBar2.SetBounds(30, 50, 200, 13)
        progBar1.Maximum = 32768
        progBar2.Maximum = 32768
        Me.Controls.AddRange(New Control() {openplayBtn, pauseBtn, lblDuration, trackPos, progBar1, progBar2})
        openfileDlg.FileName = Nothing
        openfileDlg.Filter = "Audio Files(*.wav;*.mp3)|*.wav;*.mp3"
        levelTimer.Enabled = True
        AddHandler Me.LevelChange, New EventHandler(AddressOf Me_LevelChange)
    End Sub

    Private Sub playOnLoadBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openplayBtn.Click, pauseBtn.Click
        Select Case sender.Name
            Case "Button1"
                Select Case openplayBtn.Text
                    Case "Open"
                        If openfileDlg.ShowDialog = Windows.Forms.DialogResult.OK Then
                            Bass.BASS_StreamFree(strm)
                            strm = Bass.BASS_StreamCreateFile(openfileDlg.FileName, 0, 0, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MUSIC_LOOP)
                            If strm Then
                                lblDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss") & "/" & "00:00"
                                trackPos.Maximum = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm))
                                trackPos.TickFrequency = CInt(trackPos.Maximum / 100 * 10)
                                openplayBtn.Text = "Play"
                                levelTimer.Enabled = True
                            End If
                        End If
                    Case "Play"
                            Bass.BASS_ChannelPlay(strm, True)
                            openplayBtn.Text = "Stop"
                    Case Else
                            Bass.BASS_ChannelStop(strm)
                            openplayBtn.Text = "Open"
                        If Strings.InStr(pauseBtn.Text, "Resume") Then
                            pauseBtn.Text = "Pause"
                            Bass.BASS_ChannelSetPosition(strm, Bass.BASS_ChannelSeconds2Bytes(strm, 0))
                            progBar1.Value = progBar1.Minimum
                            progBar2.Value = progBar2.Minimum
                        End If
                End Select
            Case Else
                Select Case pauseBtn.Text
                    Case "Pause"
                        If Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_PLAYING Then
                            Bass.BASS_ChannelPause(strm)
                            pauseBtn.Text = "Resume"
                            levelTimer.Stop()
                        End If
                    Case Else
                        Bass.BASS_ChannelPlay(strm, False)
                        pauseBtn.Text = "Pause"
                        levelTimer.Start()
                End Select
        End Select
    End Sub

    Private Sub trackPos_Scroll(ByVal sender As Object, ByVal e As EventArgs) Handles trackPos.Scroll
        Bass.BASS_ChannelSetPosition(strm, Bass.BASS_ChannelSeconds2Bytes(strm, CDbl(trackPos.Value)))
    End Sub

    Private Sub trackPos_Down(ByVal sender As Object, ByVal e As EventArgs) Handles trackPos.MouseDown
        If Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_PLAYING Then
            levelTimer.Stop()
            positionTimer.Stop()
        End If
    End Sub

    Private Sub trackPos_Up(ByVal sender As Object, ByVal e As EventArgs) Handles trackPos.MouseUp
        If Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_PLAYING Then
            levelTimer.Start()
            positionTimer.Start()
        End If
    End Sub

    '----------------------------- Tick EventHandler -----------------------------------------------------

    Private Sub Me_LevelChange(ByVal sender As Object, ByVal e As EventArgs)
        Try
            progBar1.Value = Utils.LowWord32(Bass.BASS_ChannelGetLevel(strm)) 'it's working if active is playing.
            progBar2.Value = Utils.HighWord32(Bass.BASS_ChannelGetLevel(strm))
        Catch ex As Exception
            progBar1.Value = progBar1.Minimum
            progBar2.Value = progBar2.Minimum 'if sound is paused or stopped then it will auto reset.
            trackPos.Value = progBar2.Value
            lblDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss") & "/" & "00:00"
            levelTimer.Stop()
        End Try
    End Sub

    Private Sub positionTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) 'auto timer current position.
        trackPos.Value = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm))
        lblDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss") & "/" & Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm)), "mm:ss")
    End Sub

    Private Sub levelTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles levelTimer.Tick
        OnLevelChange()
        OnPositionChange() 'The timer for tick events.
    End Sub

    Protected Overridable Sub OnLevelChange()
        If Bass.BASS_ChannelGetPosition(strm) > 0 Then
            RaiseEvent LevelChange(Me, New EventArgs)
        End If
    End Sub

    Protected Overloads Sub OnPositionChange()
        If Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_PLAYING Then
            positionTimer.Start()
            AddHandler positionTimer.Tick, New EventHandler(AddressOf positionTimer_Tick)
        Else
            If (Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_PAUSED) Or (Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_STOPPED) Then
                RemoveHandler positionTimer.Tick, New EventHandler(AddressOf positionTimer_Tick)
                positionTimer.Stop()
            End If
        End If
    End Sub

    Private WithEvents levelTimer As New Timer
    Private positionTimer As New Timer
    Private Event LevelChange As EventHandler
    Private Event PositionChange(ByVal sender As Object, ByVal e As EventArgs)
End Class
« Last Edit: 17 Mar '14 - 14:41 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #157 on: 18 Mar '14 - 02:04 »
Using code Un4seen.Bass.BASSTimer ;D

Example:
Code: [Select]
Imports Un4seen.Bass
Imports BassNetRegister

Public Class Form1
    Inherits Form

    Private strm As Integer
    Private openFilesDlg As OpenFileDialog
    Private playList As ListBox
    Private BASStimePosition As BASSTimer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BassRegister.RegisterBassNet()
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)
    End Sub

    Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        openFilesDlg = New OpenFileDialog
        openFilesDlg.FileName = Nothing
        openFilesDlg.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        openFilesDlg.Filter = "Audio Files(*.wav;*.mp3)|*.wav;*.mp3"
        openFilesDlg.Multiselect = True
        ListBox1.HorizontalScrollbar = True
        ProgressBar1.Maximum = 32768
        ProgressBar2.Maximum = ProgressBar1.Maximum
        playList = New ListBox
        playList.Size = ListBox1.Size
        playList.Location = ListBox1.Location
        Me.Controls.Add(playList)
        BASStimePosition = New BASSTimer
        AddHandler BASStimePosition.Tick, AddressOf BASStimePosition_Tick
    End Sub

    Private Sub BASStimePosition_Tick(ByVal sender As Object, ByVal e As EventArgs)
        On Error Resume Next
        TrackBarPosition.Value = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm))
        LabelPosition.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm)), "mm:ss")
        If Bass.BASS_ChannelGetLevel(strm) > 0 Then
            ProgressBar1.Value = Utils.LowWord32(Bass.BASS_ChannelGetLevel(strm))
            ProgressBar2.Value = Utils.HighWord32(Bass.BASS_ChannelGetLevel(strm))
            LabelStatus.Text = Status
        End If
        LabelStatus.Text = Status
        If Status = "stopped" Then
            ButtonStop.PerformClick()
            ProgressBar1.Value = ProgressBar1.Minimum
            ProgressBar2.Value = ProgressBar1.Value
            TrackBarPosition.Value = ProgressBar2.Value
            LabelPosition.Text = Utils.FixTimespan(0, "mm:ss")
            LabelStatus.Text = Status
            BASStimePosition.Stop()
        End If                  'if music loop, repeat is true.
        'NoneStopOrRepeat(False) 'if using not this code is stopped.
        NoneStopCompleted()
    End Sub

    Private Sub TrackBarPosition_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBarPosition.Scroll
        Bass.BASS_ChannelSetPosition(strm, Bass.BASS_ChannelSeconds2Bytes(strm, CDbl(TrackBarPosition.Value)))
    End Sub

    Private Sub ButtonOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOpen.Click
        If openFilesDlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each items As String In openFilesDlg.FileNames
                playList.Items.Add(items)
                ListBox1.Items.Add(System.IO.Path.GetFileName(items))
            Next items
            If ListBox1.SelectedIndex = -1 Then
                ListBox1.SetSelected(0, True)
                playList.SelectedIndex = ListBox1.SelectedIndex
                strm = Bass.BASS_StreamCreateFile(playList.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
                If strm Then
                    LabelDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss")
                    TrackBarPosition.Maximum = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm))
                    TrackBarPosition.TickFrequency = CInt(TrackBarPosition.Maximum / 100 * 10)
                End If
            End If
        End If
    End Sub

    Private Sub ButtonPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPlay.Click
        On Error Resume Next
        If ListBox1.SelectedItem = String.Empty Then Return
        playList.SelectedIndex = ListBox1.SelectedIndex
        Bass.BASS_StreamFree(strm)
        strm = Bass.BASS_StreamCreateFile(playList.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
        If strm Then
            LabelDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss")
            TrackBarPosition.Maximum = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm))
            TrackBarPosition.TickFrequency = CInt(TrackBarPosition.Maximum / 100 * 10)
            ProgressBar1.Value = ProgressBar1.Minimum
            ProgressBar2.Value = ProgressBar1.Value
            Bass.BASS_ChannelPlay(strm, True)
            BASStimePosition.Start()
            If Strings.InStr(ButtonPause.Text, "Resume") Then ButtonPause.Text = "Pause"
        End If
    End Sub

    Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
        ButtonPlay.PerformClick()
    End Sub

    Private Sub ButtonPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPause.Click
        Select Case ButtonPause.Text
            Case "Pause"
                If Status = "stopped" Then Return
                Bass.BASS_ChannelPause(strm)
                ButtonPause.Text = "Resume"
            Case Else
                Bass.BASS_ChannelPlay(strm, False)
                ButtonPause.Text = "Pause"
        End Select
    End Sub

    Private Sub ButtonStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStop.Click
        Bass.BASS_ChannelStop(strm)
        If Strings.InStr(ButtonPause.Text, "Resume") Then ButtonPause.Text = "Pause"
    End Sub

    Public Sub NoneStopOrRepeat(ByVal Repeat As Boolean)
        Select Case Repeat
            Case False
                If Bass.BASS_ChannelGetPosition(strm) = Bass.BASS_ChannelGetLength(strm) Then
                    Dim ind As Integer = ListBox1.SelectedIndex
                    Try
                        ListBox1.SetSelected(ind + 1, True)
                        playList.SelectedIndex = ind
                        ButtonPlay.PerformClick()
                    Catch ex As Exception
                        ListBox1.SetSelected(0, True)
                        playList.SelectedIndex = ind
                        ButtonPlay.PerformClick()
                    End Try
                End If
            Case Else
                If Bass.BASS_ChannelGetPosition(strm) = Bass.BASS_ChannelGetLength(strm) Then
                    Dim ind As Integer = ListBox1.SelectedIndex
                    ListBox1.SetSelected(ind, True)
                    playList.SelectedIndex = ind
                    ButtonPlay.PerformClick()
                End If
        End Select
    End Sub

    Public Sub NoneStopCompleted()
        If ListBox1.SelectedItem = String.Empty Then Return
        If Bass.BASS_ChannelGetPosition(strm) = Bass.BASS_ChannelGetLength(strm) Then
            Dim ind As Integer = ListBox1.SelectedIndex
            Try
                ListBox1.SetSelected(ind + 1, True)
                playList.SelectedIndex = ind
                If ListBox1.SelectedIndex <> 0 Then
                    ButtonPlay.PerformClick()
                End If
                ListBox1.Items.RemoveAt(ind)
                playList.Items.RemoveAt(ind)
            Catch ex As Exception
                ButtonStop.PerformClick()
                ListBox1.Items.RemoveAt(ind)
                playList.Items.RemoveAt(ind)
                LabelDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, 0), "mm:ss")
                If ListBox1.Items.Count <> -1 Then
                    ButtonStop.PerformClick()
                    ListBox1.SetSelected(0, True)
                    LabelDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss")
                    playList.SelectedIndex = ListBox1.SelectedIndex
                End If
            End Try
        End If
    End Sub

    Public ReadOnly Property Status() As String
        Get
            Dim state As String = Nothing
            Select Case Bass.BASS_ChannelIsActive(strm)
                Case BASSActive.BASS_ACTIVE_PAUSED
                    state = "paused"
                Case BASSActive.BASS_ACTIVE_PLAYING
                    state = "playing"
                Case BASSActive.BASS_ACTIVE_STALLED
                    state = "stalled"
                Case Else
                    state = "stopped"
            End Select
            Return state
        End Get
    End Property

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If Status = "playing" Then
            Bass.BASS_Free()
        End If
    End Sub
End Class



Get code NoneStopCompleted() , When song ended will auto delete item playlist.

Code: [Select]
Public Sub NoneStopCompleted()
        If ListBox1.SelectedItem = String.Empty Then Return
        If Bass.BASS_ChannelGetPosition(strm) = Bass.BASS_ChannelGetLength(strm) Then
            Dim ind As Integer = ListBox1.SelectedIndex
            Try
                ListBox1.SetSelected(ind + 1, True)
                playList.SelectedIndex = ind
                ButtonPlay.PerformClick()
                ListBox1.Items.RemoveAt(ind)
                playList.Items.RemoveAt(ind)
            Catch ex As Exception
                ButtonStop.PerformClick()
                ListBox1.Items.RemoveAt(ind)
                playList.Items.RemoveAt(ind)
            End Try
        End If
    End Sub
« Last Edit: 18 Mar '14 - 05:59 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #158 on: 18 Mar '14 - 11:00 »
Using BASS plugin , For playing mp4 or aac ;D

Example:
Code: [Select]
Imports Un4seen.Bass

Public Class Form1

    Private multiButton As Button
    Private openFileDlg As OpenFileDialog
    Private mp4Plugin, strm As Integer
    Private fileName As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mp4Plugin = Bass.BASS_PluginLoad("bass_aac.dll")
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)
    End Sub

    Public Sub New()
        InitializeComponent()
        openFileDlg = New OpenFileDialog
        openFileDlg.FileName = Nothing
        openFileDlg.Filter = "Audio Files(*.wav;*.mp3;*.mp4)|*.wav;*.mp3;*.mp4"
        multiButton = New Button
        multiButton.Text = "Open"
        multiButton.Location = New Point(100, 100)
        multiButton.Cursor = Cursors.Hand
        Me.Controls.Add(multiButton)
        AddHandler multiButton.Click, New EventHandler(AddressOf multiButton_Click)
    End Sub

    Private Sub multiButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Select Case multiButton.Text
            Case "Open"
                If openFileDlg.ShowDialog = Windows.Forms.DialogResult.OK Then
                    fileName = openFileDlg.FileName
                    multiButton.Text = "Play"
                End If
            Case "Play"
                Bass.BASS_StreamFree(strm)
                strm = Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MUSIC_LOOP)
                If strm Then
                    Bass.BASS_ChannelPlay(strm, True)
                    multiButton.Text = "Stop"
                End If
            Case Else
                Bass.BASS_ChannelStop(strm)
                multiButton.Text = "Open"
        End Select
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Bass.BASS_Free()
        Bass.BASS_PluginFree(mp4Plugin)
    End Sub
End Class
« Last Edit: 18 Mar '14 - 11:57 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #159 on: 19 Mar '14 - 04:06 »
BASS_mp4_Player_C++ ;D

Example:
Code: [Select]
#pragma once
namespace BassMP4Player {
    using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace Un4seen::Bass;
    /// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
///          'Resource File Name' property for the managed resource compiler tool
///          associated with all .resx files this class depends on.  Otherwise,
///          the designers will not be able to interact properly with localized
///          resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
private: int strm;
    private: int mp4Plugin; 
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
openFileDialog1->FileName = L"";
            openFileDialog1->Filter = "Audio Files(*.mp4;*.wav;*.mp3)|*.mp4;*.wav;*.mp3";
            progressBar1->Maximum = 32768;
            progressBar2->Maximum = progressBar1->Maximum;
timer1->Interval = 40;
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^  buttonOpen;
private: System::Windows::Forms::Button^  buttonPlay;
private: System::Windows::Forms::Button^  buttonPause;
private: System::Windows::Forms::Button^  buttonStop;
private: System::Windows::Forms::Label^  labelDuration;
private: System::Windows::Forms::Label^  labelPosition;
private: System::Windows::Forms::Label^  labelStatus;
private: System::Windows::Forms::TrackBar^  trackBarPosition;

    private: System::Windows::Forms::ProgressBar^  progressBar1;
private: System::Windows::Forms::ProgressBar^  progressBar2;
private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
private: System::Windows::Forms::TextBox^  textBoxfileName;
private: System::Windows::Forms::Timer^  timer1;
private: System::ComponentModel::IContainer^  components;
/// <summary>
/// Required designer variable.
/// </summary>


#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->buttonOpen = (gcnew System::Windows::Forms::Button());
this->buttonPlay = (gcnew System::Windows::Forms::Button());
this->buttonPause = (gcnew System::Windows::Forms::Button());
this->buttonStop = (gcnew System::Windows::Forms::Button());
this->labelDuration = (gcnew System::Windows::Forms::Label());
this->labelPosition = (gcnew System::Windows::Forms::Label());
this->labelStatus = (gcnew System::Windows::Forms::Label());
this->trackBarPosition = (gcnew System::Windows::Forms::TrackBar());
this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
this->progressBar2 = (gcnew System::Windows::Forms::ProgressBar());
this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
this->textBoxfileName = (gcnew System::Windows::Forms::TextBox());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBarPosition))->BeginInit();
this->SuspendLayout();
//
// buttonOpen
//
this->buttonOpen->Location = System::Drawing::Point(12, 147);
this->buttonOpen->Name = L"buttonOpen";
this->buttonOpen->Size = System::Drawing::Size(55, 23);
this->buttonOpen->TabIndex = 0;
this->buttonOpen->Text = L"Open";
this->buttonOpen->UseVisualStyleBackColor = true;
this->buttonOpen->Click += gcnew System::EventHandler(this, &Form1::buttonOpen_Click);
//
// buttonPlay
//
this->buttonPlay->Location = System::Drawing::Point(82, 147);
this->buttonPlay->Name = L"buttonPlay";
this->buttonPlay->Size = System::Drawing::Size(55, 23);
this->buttonPlay->TabIndex = 1;
this->buttonPlay->Text = L"Play";
this->buttonPlay->UseVisualStyleBackColor = true;
this->buttonPlay->Click += gcnew System::EventHandler(this, &Form1::buttonPlay_Click);
//
// buttonPause
//
this->buttonPause->Location = System::Drawing::Point(152, 147);
this->buttonPause->Name = L"buttonPause";
this->buttonPause->Size = System::Drawing::Size(55, 23);
this->buttonPause->TabIndex = 2;
this->buttonPause->Text = L"Pause";
this->buttonPause->UseVisualStyleBackColor = true;
//
// buttonStop
//
this->buttonStop->Location = System::Drawing::Point(225, 147);
this->buttonStop->Name = L"buttonStop";
this->buttonStop->Size = System::Drawing::Size(55, 23);
this->buttonStop->TabIndex = 3;
this->buttonStop->Text = L"Stop";
this->buttonStop->UseVisualStyleBackColor = true;
this->buttonStop->Click += gcnew System::EventHandler(this, &Form1::buttonStop_Click);
//
// labelDuration
//
this->labelDuration->AutoSize = true;
this->labelDuration->Location = System::Drawing::Point(12, 119);
this->labelDuration->Name = L"labelDuration";
this->labelDuration->Size = System::Drawing::Size(34, 13);
this->labelDuration->TabIndex = 4;
this->labelDuration->Text = L"00:00";
//
// labelPosition
//
this->labelPosition->AutoSize = true;
this->labelPosition->Location = System::Drawing::Point(246, 119);
this->labelPosition->Name = L"labelPosition";
this->labelPosition->Size = System::Drawing::Size(34, 13);
this->labelPosition->TabIndex = 5;
this->labelPosition->Text = L"00:00";
//
// labelStatus
//
this->labelStatus->AutoSize = true;
this->labelStatus->Location = System::Drawing::Point(122, 119);
this->labelStatus->Name = L"labelStatus";
this->labelStatus->Size = System::Drawing::Size(45, 13);
this->labelStatus->TabIndex = 6;
this->labelStatus->Text = L"stopped";
//
// trackBarPosition
//
this->trackBarPosition->Location = System::Drawing::Point(15, 71);
this->trackBarPosition->Name = L"trackBarPosition";
this->trackBarPosition->Size = System::Drawing::Size(265, 45);
this->trackBarPosition->TabIndex = 7;
this->trackBarPosition->Scroll += gcnew System::EventHandler(this, &Form1::trackBarPosition_Scroll);
//
// progressBar1
//
this->progressBar1->Location = System::Drawing::Point(15, 42);
this->progressBar1->Name = L"progressBar1";
this->progressBar1->Size = System::Drawing::Size(265, 11);
this->progressBar1->TabIndex = 9;
//
// progressBar2
//
this->progressBar2->Location = System::Drawing::Point(15, 54);
this->progressBar2->Name = L"progressBar2";
this->progressBar2->Size = System::Drawing::Size(265, 11);
this->progressBar2->TabIndex = 10;
//
// openFileDialog1
//
this->openFileDialog1->FileName = L"openFileDialog1";
//
// textBoxfileName
//
this->textBoxfileName->Location = System::Drawing::Point(15, 12);
this->textBoxfileName->Name = L"textBoxfileName";
this->textBoxfileName->Size = System::Drawing::Size(265, 20);
this->textBoxfileName->TabIndex = 11;
//
// timer1
//
this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 182);
this->Controls->Add(this->textBoxfileName);
this->Controls->Add(this->progressBar2);
this->Controls->Add(this->progressBar1);
this->Controls->Add(this->trackBarPosition);
this->Controls->Add(this->labelStatus);
this->Controls->Add(this->labelPosition);
this->Controls->Add(this->labelDuration);
this->Controls->Add(this->buttonStop);
this->Controls->Add(this->buttonPause);
this->Controls->Add(this->buttonPlay);
this->Controls->Add(this->buttonOpen);
this->Name = L"Form1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"BassPlayerMP4 (C++)";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBarPosition))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
mp4Plugin = Bass::BASS_PluginLoad(L"bass_aac.dll");
Bass::BASS_Init(-1, 44100,  BASSInit::BASS_DEVICE_DEFAULT, System::IntPtr::Zero);
}
private: System::Void buttonOpen_Click(System::Object^  sender, System::EventArgs^  e) {
if (openFileDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
{
textBoxfileName->Text = openFileDialog1->SafeFileName;
}
}
    private: System::Void buttonPlay_Click(System::Object^  sender, System::EventArgs^  e) {
Bass::BASS_StreamFree(strm);
strm = Bass::BASS_StreamCreateFile(textBoxfileName->Text, 0, 0, BASSFlag::BASS_DEFAULT|BASSFlag::BASS_MUSIC_LOOP);
if (strm)
{
labelDuration->Text = Utils::FixTimespan(Bass::BASS_ChannelBytes2Seconds(strm, Bass::BASS_ChannelGetLength(strm)), L"mm:ss");
trackBarPosition->Maximum = Convert::ToInt32( Bass::BASS_ChannelBytes2Seconds(strm, Bass::BASS_ChannelGetLength(strm)));
trackBarPosition->TickFrequency = Convert::ToInt32(trackBarPosition->Maximum/100*10);
Bass::BASS_ChannelPlay(strm, true);
                 timer1->Enabled = true;
if (Bass::BASS_ChannelIsActive(strm)== BASSActive::BASS_ACTIVE_PLAYING)
{
     labelStatus->Text = L"playing";
}
}
}
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
trackBarPosition->Value = Convert::ToInt32(Bass::BASS_ChannelBytes2Seconds(strm, Bass::BASS_ChannelGetPosition(strm)));
progressBar1->Value = Utils::LowWord32(Bass::BASS_ChannelGetLevel(strm));
progressBar2->Value = Utils::HighWord32(Bass::BASS_ChannelGetLevel(strm));
labelPosition->Text = Utils::FixTimespan(Bass::BASS_ChannelBytes2Seconds(strm, Bass::BASS_ChannelGetPosition(strm)), L"mm:ss");
}
    private: System::Void trackBarPosition_Scroll(System::Object^  sender, System::EventArgs^  e) {
Bass::BASS_ChannelSetPosition( strm, Bass::BASS_ChannelSeconds2Bytes(strm, Convert::ToDouble(trackBarPosition->Value)));
}
private: System::Void buttonStop_Click(System::Object^  sender, System::EventArgs^  e) {
Bass::BASS_ChannelStop(strm);
                 timer1->Enabled = false;
if (Bass::BASS_ChannelIsActive(strm)== BASSActive::BASS_ACTIVE_STOPPED)
{
     labelStatus->Text = L"stopped";
}
}
private: System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
Bass::BASS_PluginFree(mp4Plugin);
Bass::BASS_Free();
}
    };
}

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #160 on: 19 Mar '14 - 05:41 »
BassMp4Player_C# ;D

Example:
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Un4seen.Bass;
using BassNetRegister;

namespace BassMP4PlayerCsharp
{
    public partial class Form1 : Form
    {
        private int strm = 0;
        private int mp4Plugin;
        public Form1()
        {
            InitializeComponent();
            openFileDialog1.FileName = String.Empty;
            openFileDialog1.Filter = "Audio Files(*.mp4;*.wav;*.mp3)|*.mp4;*.wav;*.mp3";
            progressBar1.Maximum = 32768;
            progressBar2.Maximum = 32768;
            timer1.Interval = 40;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            BassRegister.RegisterBassNet();
            mp4Plugin = Bass.BASS_PluginLoad("bass_aac.dll");
            Bass.BASS_Init(-1,44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle);
        }
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.SafeFileName;
            }
        }
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            Bass.BASS_StreamFree(strm);
            strm = Bass.BASS_StreamCreateFile(textBox1.Text, 0, 0, BASSFlag.BASS_DEFAULT|BASSFlag.BASS_MUSIC_LOOP);
            if (strm != 0)
            {
                label1.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss");
                trackBar1.Maximum = Convert.ToInt32(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)));
                trackBar1.TickFrequency = Convert.ToInt32(trackBar1.Maximum / 100 * 10);
                Bass.BASS_ChannelPlay(strm, true);
                buttonPause.Text = "Pause";
                timer1.Enabled = true;
            }
        }
        private void buttonPause_Click(object sender, EventArgs e)
        {
            if (status() != "stopped")
            {
                if (buttonPause.Text == "Pause")
                {
                    Bass.BASS_ChannelPause(strm);
                    buttonPause.Text = "Resume";
                }
                else
                {
                    Bass.BASS_ChannelPlay(strm, false);
                    buttonPause.Text = "Pause";
                }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            label3.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm)), "mm:ss");
            trackBar1.Value = Convert.ToInt32(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm)));
            try
            {
                progressBar1.Value = Utils.LowWord32(Bass.BASS_ChannelGetLevel(strm));
                progressBar2.Value = Utils.HighWord32(Bass.BASS_ChannelGetLevel(strm));
            }
            catch
            {
            }
                label2.Text = status();
        }
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            Bass.BASS_ChannelSetPosition( strm, Bass.BASS_ChannelSeconds2Bytes( strm, Convert.ToDouble(trackBar1.Value)));
        }
        private void buttonStop_Click(object sender, EventArgs e)
        {
            Bass.BASS_ChannelStop(strm);
            if (status() == "stopped")
            {
                progressBar1.Value = 0;
                progressBar2.Value = 0;
                trackBar1.Value = 0;
                label3.Text = "00:00";
                buttonPause.Text = "Pause";
                timer1.Enabled = false;
                label2.Text = "stopped";
            }
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Bass.BASS_PluginFree(mp4Plugin);
            Bass.BASS_Free();
        }
        private string status()
        {
            string state = string.Empty;
            if (Bass.BASS_ChannelIsActive(strm) == BASSActive.BASS_ACTIVE_PAUSED)
            {
                state = "paused";
            }
            else if (Bass.BASS_ChannelIsActive(strm) == BASSActive.BASS_ACTIVE_PLAYING)
            {
                state = "playing";
            }
            else if (Bass.BASS_ChannelIsActive(strm) == BASSActive.BASS_ACTIVE_STALLED)
            {
                state = "stalled";
            }
            else
            {
                state = "stopped";
            }
            return state;
        }
    }
}
« Last Edit: 20 Mar '14 - 05:52 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #161 on: 21 Mar '14 - 00:16 »
Free Download: BassMPeg324.dll and sample project ;D Click here

Example:
Code: [Select]
Imports BassMpeg324
Imports Un4seen.Bass

Public Class Form1
    Inherits Form

    Private mplayer As New Mpeg324

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

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Text = "Mpeg324 Player"
        mplayer.PlayListCreated(Me, ListBox1)
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Audio Files(*.mp4;*.wav;*.mp3)|*.mp4;*.wav;*.mp3"
        OpenFileDialog1.Multiselect = True
        ListBox1.HorizontalScrollbar = True
        CheckBox1.Checked = True
        AddHandler mplayer.PositionChange.Tick, AddressOf mplayer_PositionChange
        AddHandler mplayer.LevelChange, AddressOf mplayer_LevelChange
        AddHandler mplayer.SongPausing, AddressOf mplayer_SongPausing
        AddHandler mplayer.SongStopping, AddressOf mplayer_SongStopping
    End Sub

    Private Sub mplayer_SongStopping(ByVal sender As Object, ByVal e As EventArgs)
        TrackBar1.Value = TrackBar1.Minimum
        Label2.Text = "00:00"
        LedLevelMeter1.Level = TrackBar1.Value
        LedLevelMeter2.Level = LedLevelMeter1.Level
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            mplayer.PlayListAppendItems(OpenFileDialog1.FileNames)
            mplayer.PlayListSelectedIndex(ListBox1)
            If mplayer.Mpeg324_Status = "stopped" Then
                mplayer.Mpeg324_OpenFile(mplayer.playlist.SelectedItem)
                mplayer.Mpeg324_DurationString(Label1)
                mplayer.Mpeg324_MaxPosition(TrackBar1)
                mplayer.Mpeg324_MaxPosTickFreq(TrackBar1)
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If ListBox1.SelectedItem <> String.Empty Then
            mplayer.PlayListSelectedIndex(ListBox1)
            mplayer.Mpeg324_OpenFile(mplayer.playlist.SelectedItem)
            mplayer.Mpeg324_DurationString(Label1)
            mplayer.Mpeg324_MaxPosition(TrackBar1)
            mplayer.Mpeg324_MaxPosTickFreq(TrackBar1)
            mplayer.Mpeg324_Play()
            mplayer.BtnReset(Button3)
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If mplayer.Mpeg324_Status <> "stopped" Then
            If ListBox1.SelectedItem <> String.Empty Then
                mplayer.Mpeg324_PauseResume(Button3)
            End If
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If ListBox1.SelectedItem <> String.Empty Then
            mplayer.Mpeg324_Stop()
            mplayer.BtnReset(Button3)
        End If
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        mplayer.Mpeg324_ChangePosition(TrackBar1.Value)
    End Sub

    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        mplayer.Mpeg324_Volume(TrackBar2)
        ToolTip1.SetToolTip(TrackBar2, TrackBar2.Value.ToString)
    End Sub
    Private Sub TrackBar2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.ValueChanged
        ToolTip1.SetToolTip(TrackBar2, TrackBar2.Value.ToString)
    End Sub

    Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
        mplayer.Mpeg324_Balance(CSng(TrackBar3.Value))
        ToolTip1.SetToolTip(TrackBar3, TrackBar3.Value.ToString)
    End Sub
    Private Sub TrackBar3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.ValueChanged
        ToolTip1.SetToolTip(TrackBar3, TrackBar3.Value.ToString)
    End Sub

    Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
        Button2.PerformClick()
    End Sub

    Private Sub mplayer_PositionChange(ByVal sender As Object, ByVal e As EventArgs)
        On Error Resume Next
        mplayer.Mpeg324_CurrentPosition(TrackBar1)
        mplayer.Mpeg324_PositionString(Label2)
        If CheckBox1.CheckState = CheckState.Checked Then
            mplayer.PlayNoneStop(Button2)
        Else
            If mplayer.Mpeg324_Status = "stopped" Then
                Button4.PerformClick()
            End If
        End If
    End Sub

    Private Sub mplayer_LevelChange(ByVal sender As Object, ByVal e As EventArgs)
        mplayer.Mpeg324_LevelMeter("L", LedLevelMeter1)
        mplayer.Mpeg324_LevelMeter("H", LedLevelMeter2)
    End Sub

    Private Sub mplayer_SongPausing(ByVal sender As Object, ByVal e As EventArgs)
        mplayer.Mpeg324_LedMeterPausing(LedLevelMeter1, LedLevelMeter2)
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        mplayer.Mpeg324_Close()
    End Sub
End Class
« Last Edit: 24 Mar '14 - 05:32 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #162 on: 24 Mar '14 - 05:46 »
Mpeg324 Player C# ;D (Using.. BassMpeg324DLL)

Example:
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BassMpeg324;

namespace Mpeg324Player_Csharp_Sample
{
    public partial class Form1 : Form
    {
        private Mpeg324 mplayer;
        public Form1()
        {
            this.StartPosition = FormStartPosition.CenterScreen;
            InitializeComponent();
            this.Text = "MPeg324CS Player";
            mplayer = new Mpeg324();
            mplayer.PlayListCreated(this, PlayList);
            openFileDialog1.FileName = string.Empty;
            openFileDialog1.Filter = "Audio Flies(*.mp4;*.wav;*.mp3)|*.mp4;*.wav;*.mp3";
            openFileDialog1.Multiselect = true;
            PlayList.HorizontalScrollbar = true;
            trackBar1.Value = 10;
            checkBox1.Checked = true;
            mplayer.PositionChange.Tick += mplayer_PositionChange;
            mplayer.LevelChange += mplayer_LevelChange;
            mplayer.SongPausing += mplayer_SongPausing;
            mplayer.SongStopping += mplayer_SongStopping;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            mplayer.Mpeg324_Initialize();
        }

        private void buttonOpen_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                mplayer.PlayListSelectedIndex(PlayList);
                mplayer.PlayListAppendItems(openFileDialog1.FileNames);
                if (mplayer.Mpeg324_Status == "stopped")
                {
                    mplayer.Mpeg324_OpenFile(Convert.ToString(PlayList.SelectedItem));
                    mplayer.Mpeg324_DurationString(labelDuration);
                    mplayer.Mpeg324_MaxPosition(trackBarPosition);
                    mplayer.Mpeg324_MaxPosTickFreq(trackBarPosition);
                }
            }
        }

        private void buttonPlay_Click(object sender, EventArgs e)
        {
            if ( Convert.ToString(PlayList.SelectedItem) != string.Empty)
            {
                mplayer.Mpeg324_OpenFile(Convert.ToString(PlayList.SelectedItem));
                mplayer.Mpeg324_DurationString(labelDuration);
                mplayer.Mpeg324_MaxPosition(trackBarPosition);
                mplayer.Mpeg324_MaxPosTickFreq(trackBarPosition);
                mplayer.Mpeg324_Play();
                mplayer.BtnReset(buttonPause);
            }
        }

        private void PlayList_DoubleClick(object sender, EventArgs e)
        {
            buttonPlay.PerformClick();
        }
        private void mplayer_PositionChange(object sender, System.EventArgs e)
        {
            mplayer.Mpeg324_CurrentPosition(trackBarPosition);
            mplayer.Mpeg324_PositionString(labelPosition);
          labelStatus.Text =  mplayer.Mpeg324_Status;
          if (checkBox1.CheckState == CheckState.Checked)
          {
              mplayer.PlayNoneStop(buttonPlay);
          }
          else
          {
              if (mplayer.Mpeg324_Status == "stopped")
              {
                  buttonStop.PerformClick();
              }
          }
        }
        private void mplayer_LevelChange(object sender, EventArgs e)
        {
            mplayer.Mpeg324_LevelMeter("L", ledLevelMeter1);
            mplayer.Mpeg324_LevelMeter("H", ledLevelMeter2);
        }

        private void trackBarPosition_Scroll(object sender, EventArgs e)
        {
            mplayer.Mpeg324_ChangePosition(trackBarPosition.Value);
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            mplayer.Mpeg324_Volume(trackBar1);
        }

        private void trackBar2_Scroll(object sender, EventArgs e)
        {
            mplayer.Mpeg324_Balance(trackBar2.Value);
        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            mplayer.Mpeg324_Stop();
            mplayer.BtnReset(buttonPause);
        }
        private void mplayer_SongPausing(object sender, EventArgs e)
        {
            mplayer.Mpeg324_LedMeterPausing(ledLevelMeter1, ledLevelMeter2);
        }
        private void mplayer_SongStopping(object sender, EventArgs e)
        {
            trackBarPosition.Value = trackBarPosition.Minimum;
            labelPosition.Text = "00:00";
            ledLevelMeter1.Level = trackBarPosition.Value;
            ledLevelMeter2.Level = ledLevelMeter1.Level;
            labelStatus.Text = "stopped";
        }

        private void buttonPause_Click(object sender, EventArgs e)
        {
            if (mplayer.Mpeg324_Status != "stopped")
            {
                if (Convert.ToString(PlayList.SelectedItem) != string.Empty)
                {
                    mplayer.Mpeg324_PauseResume(buttonPause);
                }
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            mplayer.Mpeg324_Close();
        }
    }
}
« Last Edit: 24 Mar '14 - 09:44 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #163 on: 25 Mar '14 - 01:24 »
MPeg324 Player C++ ;D

Long post, cannnot post. Download: Click here


 
« Last Edit: 25 Mar '14 - 01:30 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #164 on: 25 Mar '14 - 11:51 »
Free Download: BassEQualizer Library DLL  ;D Click here

It's easy for creatting EQ control many bands.

Example:
Code: [Select]
Imports Un4seen.Bass
Imports BassEQLib

Public Class Form1

    Private player As BassEQ
    Private fxEQ As Integer()
    Private strm As Integer
    Private file As String

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Text = "BassEQ Player"
        player = New BassEQ
        fxEQ = New Integer(9 - 0) {}
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Audio File(*.wav;*.mp3)|*.wav;*.mp3"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            file = OpenFileDialog1.FileName
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Bass.BASS_StreamFree(strm)
        strm = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MUSIC_LOOP)
        If strm Then
            Bass.BASS_ChannelPlay(strm, True)
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Bass.BASS_ChannelStop(strm)
    End Sub

    Private Sub EQ_0_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_0.Scroll
        player.updateBandEQ(fxEQ, 0, CSng(EQ_0.Value))
    End Sub
    Private Sub EQ_0_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_0.ValueChanged
        player.updateBandEQ(fxEQ, 0, CSng(EQ_0.Value))
    End Sub

    Private Sub EQ_1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_1.Scroll
        player.updateBandEQ(fxEQ, 1, CSng(EQ_1.Value))
    End Sub
    Private Sub EQ_1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_1.ValueChanged
        player.updateBandEQ(fxEQ, 1, CSng(EQ_1.Value))
    End Sub

    Private Sub EQ_2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_2.Scroll
        player.updateBandEQ(fxEQ, 2, CSng(EQ_2.Value))
    End Sub
    Private Sub EQ_2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_2.ValueChanged
        player.updateBandEQ(fxEQ, 2, CSng(EQ_2.Value))
    End Sub

    Private Sub EQ_3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_3.Scroll
        player.updateBandEQ(fxEQ, 3, CSng(EQ_3.Value))
    End Sub
    Private Sub EQ_3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_3.ValueChanged
        player.updateBandEQ(fxEQ, 3, CSng(EQ_3.Value))
    End Sub

    Private Sub EQ_4_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_4.Scroll
        player.updateBandEQ(fxEQ, 4, CSng(EQ_4.Value))
    End Sub
    Private Sub EQ_4_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_4.ValueChanged
        player.updateBandEQ(fxEQ, 4, CSng(EQ_4.Value))
    End Sub

    Private Sub EQ_5_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_5.Scroll
        player.updateBandEQ(fxEQ, 5, CSng(EQ_5.Value))
    End Sub
    Private Sub EQ_5_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_5.ValueChanged
        player.updateBandEQ(fxEQ, 5, CSng(EQ_5.Value))
    End Sub

    Private Sub EQ_6_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_6.Scroll
        player.updateBandEQ(fxEQ, 6, CSng(EQ_6.Value))
    End Sub
    Private Sub EQ_6_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_6.ValueChanged
        player.updateBandEQ(fxEQ, 6, CSng(EQ_6.Value))
    End Sub

    Private Sub EQ_7_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_7.Scroll
        player.updateBandEQ(fxEQ, 7, CSng(EQ_7.Value))
    End Sub
    Private Sub EQ_7_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_7.ValueChanged
        player.updateBandEQ(fxEQ, 7, CSng(EQ_7.Value))
    End Sub

    Private Sub EQ_8_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_8.Scroll
        player.updateBandEQ(fxEQ, 8, CSng(EQ_8.Value))
    End Sub
    Private Sub EQ_8_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_8.ValueChanged
        player.updateBandEQ(fxEQ, 8, CSng(EQ_8.Value))
    End Sub

    Private Sub EQ_9_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_9.Scroll
        player.updateBandEQ(fxEQ, 9, CSng(EQ_9.Value))
    End Sub
    Private Sub EQ_9_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_9.ValueChanged
        player.updateBandEQ(fxEQ, 9, CSng(EQ_9.Value))
    End Sub

    Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
        resetEQ()
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.CheckState = CheckState.Checked Then
            enableEQ()
        Else
            disableEQ()
        End If
    End Sub

    Private Sub enableEQ()
        player.setBandsParamEQ(strm, fxEQ, 9) 'if set BandsParamEQ = 9 is EQ 10 bands.(0 to 9)
        player.setFreqBandEQ(fxEQ, 80, 0)
        player.setFreqBandEQ(fxEQ, 120, 1)
        player.setFreqBandEQ(fxEQ, 250, 2)
        player.setFreqBandEQ(fxEQ, 500, 3)
        player.setFreqBandEQ(fxEQ, 1000, 4)
        player.setFreqBandEQ(fxEQ, 1800, 5)
        player.setFreqBandEQ(fxEQ, 3500, 6)
        player.setFreqBandEQ(fxEQ, 7000, 7)
        player.setFreqBandEQ(fxEQ, 10000, 8)
        player.setFreqBandEQ(fxEQ, 14000, 9)
        player.updateBandEQ(fxEQ, 0, CSng(EQ_0.Value))
        player.updateBandEQ(fxEQ, 1, CSng(EQ_1.Value))
        player.updateBandEQ(fxEQ, 2, CSng(EQ_2.Value))
        player.updateBandEQ(fxEQ, 3, CSng(EQ_3.Value))
        player.updateBandEQ(fxEQ, 4, CSng(EQ_4.Value))
        player.updateBandEQ(fxEQ, 5, CSng(EQ_5.Value))
        player.updateBandEQ(fxEQ, 6, CSng(EQ_6.Value))
        player.updateBandEQ(fxEQ, 7, CSng(EQ_7.Value))
        player.updateBandEQ(fxEQ, 8, CSng(EQ_8.Value))
        player.updateBandEQ(fxEQ, 9, CSng(EQ_9.Value))
    End Sub

    Private Sub disableEQ()
        player.disableEQ(strm, fxEQ)
    End Sub

    Private Sub resetEQ()
        EQ_0.Value = 0
        EQ_1.Value = 0
        EQ_2.Value = 0
        EQ_3.Value = 0
        EQ_4.Value = 0
        EQ_5.Value = 0
        EQ_6.Value = 0
        EQ_7.Value = 0
        EQ_8.Value = 0
        EQ_9.Value = 0
    End Sub
End Class
« Last Edit: 25 Mar '14 - 12:07 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #165 on: 26 Mar '14 - 03:26 »
Get code BassControl and TrebleControl ;D

Example:
Code: [Select]
Imports Un4seen.Bass
Imports BassEQLib

Public Class Form1
    Inherits Form
    Private player As BassEQ
    Private fxEQ As Integer()
    Private fxB As Integer()
    Private fxT As Integer()
    Private strm As Integer
    Private file As String

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Text = "Bass EQ Control Player"
        player = New BassEQ
        fxEQ = New Integer(9 - 0) {}
        fxB = New Integer(0) {}
        fxT = New Integer(0) {}
        Timer1.Interval = 40
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Audio File(*.wav;*.mp3)|*.wav;*.mp3"
        BASSAttributeVolume(trackVol)
        ProgressBar1.Maximum = 32768
        ProgressBar2.Maximum = ProgressBar1.Maximum
      End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            file = OpenFileDialog1.FileName
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If file <> String.Empty Then
            Bass.BASS_StreamFree(strm)
            strm = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MUSIC_LOOP)
            If strm Then
                trackPos.Maximum = CInt(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)))
                trackPos.TickFrequency = CInt(trackPos.Maximum / 100 * 10)
                lblDuration.Text = Utils.FixTimespan(CDbl(trackPos.Maximum), "mm:ss")
                BassControl()
                TrebleControl()
                Bass.BASS_ChannelPlay(strm, True)
                Timer1.Enabled = True
            End If
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Bass.BASS_ChannelStop(strm)
        Timer1.Enabled = False
    End Sub

    Private Sub trackPos_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPos.Scroll
        Bass.BASS_ChannelSetPosition(strm, Bass.BASS_ChannelSeconds2Bytes(strm, CDbl(trackPos.Value)))
    End Sub

    Private Sub EQ_0_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_0.Scroll
        player.updateBandEQ(fxEQ, 0, CSng(EQ_0.Value))
    End Sub
    Private Sub EQ_0_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_0.ValueChanged
        player.updateBandEQ(fxEQ, 0, CSng(EQ_0.Value))
    End Sub

    Private Sub EQ_1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_1.Scroll
        player.updateBandEQ(fxEQ, 1, CSng(EQ_1.Value))
    End Sub
    Private Sub EQ_1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_1.ValueChanged
        player.updateBandEQ(fxEQ, 1, CSng(EQ_1.Value))
    End Sub

    Private Sub EQ_2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_2.Scroll
        player.updateBandEQ(fxEQ, 2, CSng(EQ_2.Value))
    End Sub
    Private Sub EQ_2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_2.ValueChanged
        player.updateBandEQ(fxEQ, 2, CSng(EQ_2.Value))
    End Sub

    Private Sub EQ_3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_3.Scroll
        player.updateBandEQ(fxEQ, 3, CSng(EQ_3.Value))
    End Sub
    Private Sub EQ_3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_3.ValueChanged
        player.updateBandEQ(fxEQ, 3, CSng(EQ_3.Value))
    End Sub

    Private Sub EQ_4_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_4.Scroll
        player.updateBandEQ(fxEQ, 4, CSng(EQ_4.Value))
    End Sub
    Private Sub EQ_4_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_4.ValueChanged
        player.updateBandEQ(fxEQ, 4, CSng(EQ_4.Value))
    End Sub

    Private Sub EQ_5_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_5.Scroll
        player.updateBandEQ(fxEQ, 5, CSng(EQ_5.Value))
    End Sub
    Private Sub EQ_5_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_5.ValueChanged
        player.updateBandEQ(fxEQ, 5, CSng(EQ_5.Value))
    End Sub

    Private Sub EQ_6_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_6.Scroll
        player.updateBandEQ(fxEQ, 6, CSng(EQ_6.Value))
    End Sub
    Private Sub EQ_6_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_6.ValueChanged
        player.updateBandEQ(fxEQ, 6, CSng(EQ_6.Value))
    End Sub

    Private Sub EQ_7_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_7.Scroll
        player.updateBandEQ(fxEQ, 7, CSng(EQ_7.Value))
    End Sub
    Private Sub EQ_7_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_7.ValueChanged
        player.updateBandEQ(fxEQ, 7, CSng(EQ_7.Value))
    End Sub

    Private Sub EQ_8_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_8.Scroll
        player.updateBandEQ(fxEQ, 8, CSng(EQ_8.Value))
    End Sub
    Private Sub EQ_8_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_8.ValueChanged
        player.updateBandEQ(fxEQ, 8, CSng(EQ_8.Value))
    End Sub

    Private Sub EQ_9_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_9.Scroll
        player.updateBandEQ(fxEQ, 9, CSng(EQ_9.Value))
    End Sub
    Private Sub EQ_9_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EQ_9.ValueChanged
        player.updateBandEQ(fxEQ, 9, CSng(EQ_9.Value))
    End Sub

    Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
        resetEQ()
    End Sub

    Private Sub CheckBox1_CheckStateChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckBox1.CheckStateChanged
        If CheckBox1.CheckState = CheckState.Checked Then
            enableEQ()
        Else
            disableEQ()
        End If
    End Sub

    Private Sub enableEQ()
        player.setBandsParamEQ(strm, fxEQ, 9)
        player.setFreqBandEQ(fxEQ, 80, 0)
        player.setFreqBandEQ(fxEQ, 120, 1)
        player.setFreqBandEQ(fxEQ, 250, 2)
        player.setFreqBandEQ(fxEQ, 500, 3)
        player.setFreqBandEQ(fxEQ, 1000, 4)
        player.setFreqBandEQ(fxEQ, 1800, 5)
        player.setFreqBandEQ(fxEQ, 3500, 6)
        player.setFreqBandEQ(fxEQ, 7000, 7)
        player.setFreqBandEQ(fxEQ, 1000, 8)
        player.setFreqBandEQ(fxEQ, 14000, 9)
        player.updateBandEQ(fxEQ, 0, CSng(EQ_0.Value))
        player.updateBandEQ(fxEQ, 1, CSng(EQ_1.Value))
        player.updateBandEQ(fxEQ, 2, CSng(EQ_2.Value))
        player.updateBandEQ(fxEQ, 3, CSng(EQ_3.Value))
        player.updateBandEQ(fxEQ, 4, CSng(EQ_4.Value))
        player.updateBandEQ(fxEQ, 5, CSng(EQ_5.Value))
        player.updateBandEQ(fxEQ, 6, CSng(EQ_6.Value))
        player.updateBandEQ(fxEQ, 7, CSng(EQ_7.Value))
        player.updateBandEQ(fxEQ, 8, CSng(EQ_8.Value))
        player.updateBandEQ(fxEQ, 9, CSng(EQ_9.Value))
    End Sub

    Private Sub disableEQ()
        player.disableEQ(strm, fxEQ)
    End Sub

    Private Sub resetEQ()
        EQ_0.Value = 0
        EQ_1.Value = 0
        EQ_2.Value = 0
        EQ_3.Value = 0
        EQ_4.Value = 0
        EQ_5.Value = 0
        EQ_6.Value = 0
        EQ_7.Value = 0
        EQ_8.Value = 0
        EQ_9.Value = 0
    End Sub

    Private Sub trackBass_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackBass.Scroll
        player.updateBandEQ(fxB, 0, CSng(trackBass.Value))
    End Sub
    Private Sub trackBass_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackBass.ValueChanged
        player.updateBandEQ(fxB, 0, CSng(trackBass.Value))
    End Sub
    Private Sub trackTreble_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackTreble.Scroll
        player.updateBandEQ(fxT, 0, CSng(trackTreble.Value))
    End Sub
    Private Sub trackTreble_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackTreble.ValueChanged
        player.updateBandEQ(fxT, 0, CSng(trackTreble.Value))
    End Sub

    Public Sub BassControl()
        player.setBandsParamEQ(strm, fxB, 0)
        player.setFreqBandEQ(fxB, 100, 0)
    End Sub
    Public Sub TrebleControl()
        player.setBandsParamEQ(strm, fxT, 0)
        player.setFreqBandEQ(fxT, 16000, 0)
    End Sub

    Private Sub trackVol_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVol.Scroll
        VolumeControl(trackVol)
    End Sub
    Private Sub trackVol_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVol.ValueChanged
        VolumeControl(trackVol)
    End Sub

    Private Sub trackBal_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackBal.Scroll
        BalanceControl(trackBal)
    End Sub
    Private Sub trackBal_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackBal.ValueChanged
        BalanceControl(trackBal)
    End Sub

    Private Sub BASSAttributeVolume(ByVal ctlVol As TrackBar)
        ctlVol.Maximum = 20
        ctlVol.Value = trackVol.Maximum
        ctlVol.TickFrequency = 1
    End Sub
    Private Sub VolumeControl(ByVal ctlVol As TrackBar)
        Bass.BASS_SetVolume(1.0F / 20 * CSng(ctlVol.Value))
    End Sub

    Private Sub BalanceControl(ByVal ctlVol As TrackBar)
        Bass.BASS_ChannelSetAttribute(strm, BASSAttribute.BASS_ATTRIB_PAN, CSng(trackBal.Value) / 100 * 10)
    End Sub

    Private Sub Label12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label12.Click
        trackVol.Value = 20
        trackBal.Value = 0
        trackBass.Value = trackBal.Value
        trackTreble.Value = trackBass.Value
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        trackPos.Value = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm))
        lblPosition.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm)), "mm:ss")
        ProgressBar1.Value = Utils.LowWord32(Bass.BASS_ChannelGetLevel(strm))
        ProgressBar2.Value = Utils.HighWord32(Bass.BASS_ChannelGetLevel(strm))
    End Sub
End Class

Download: Sample Project Click here



Get code Bass Form Closing

Code: [Select]
Private Sub BassClosing(ByVal handle As Integer)
        If (Bass.BASS_ChannelIsActive(handle) = BASSActive.BASS_ACTIVE_PLAYING) Or (Bass.BASS_ChannelIsActive(handle) = BASSActive.BASS_ACTIVE_PAUSED) Then
            Bass.BASS_ChannelStop(handle)
            Bass.BASS_Free()
        Else
            Bass.BASS_Free()
        End If
    End Sub

« Last Edit: 26 Mar '14 - 08:53 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #166 on: 26 Mar '14 - 08:56 »
Get code Loundness or BassBoost ::)

Code: [Select]
   Private fxLB As Integer() = New Integer(0) {}
    Private fxLT As Integer() = New Integer(0) {}
    Private Sub lblLoundN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblLoundN.Click
        Select Case lblLoundN.Text
            Case "LoundnessOn"
                player.setBandsParamEQ(strm, fxLB, 0)
                player.setFreqBandEQ(fxLB, 100, 0)
                player.setBandsParamEQ(strm, fxLT, 0)
                player.setFreqBandEQ(fxLT, 16000, 0)
                player.updateBandEQ(fxLB, 0, 10)
                player.updateBandEQ(fxLT, 0, 10)
                lblLoundN.Text = "LoundnessOff"
            Case Else
                player.updateBandEQ(fxLB, 0, 0)
                player.updateBandEQ(fxLT, 0, 0)
                lblLoundN.Text = "LoundnessOn"
        End Select
    End Sub

Download: Demo Click here
« Last Edit: 26 Mar '14 - 12:52 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #167 on: 27 Mar '14 - 05:08 »
How to embed VLC Media Player into VB.NET Windows Forms App ;D

It's support sound types all platform (audio - video)

Download: VLC ActiveX Plugin Component Register

https://www.youtube.com/watch?v=tWE-lGgdzss
https://www.youtube.com/watch?v=569ruE-JyCE&list=PLB7BEC4AE7EDF4E62
« Last Edit: 27 Mar '14 - 06:39 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #168 on: 29 Mar '14 - 21:15 »
Debug.. SongEnding EventHandler for PlayNoneStop  in the axWindowsMediaPlayer

Example:
Code: [Select]
   Private WithEvent activeTime As Timer
    Private Event SongEnding As EventHandler

    Protected Overridable Sub OnSongEnding()
        If AxWindowsMediaPlayer1.Ctlcontrols.currentPosition >= AxWindowsMediaPlayer1.newMedia(wmPlayList.SelectedItem).duration - 1 Then
            RaiseEvent SongEnding(Me, New EventArgs)
        End If
    End Sub

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        activeTime = New Timer

       'You must add start or Enable timer on the play button, It will work.

        AddHandler Me.SongEnding, AddressOf Me_SongEnding
    End Sub
  
    Private Sub Me_SongEnding(ByVal sender As Object, ByVal e As EventArgs)
        PlayList.PlayNoneStop(AxWindowsMediaPlayer1)
        ListBox1_DoubleClick(sender, e)                       'On event one tick if song ending.
    End Sub

    Private Sub activeTime_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles  activeTime.Tick
        OnSongEnding()
    End Sub
'=============================================================
wmPlayList Class
Code: [Select]
please wait!'=============================================================
Download: WindowsMediaPlayer DEMO Project (please wait!)
« Last Edit: 30 Mar '14 - 06:26 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #169 on: 30 Mar '14 - 18:48 »
Get code.. Wait! or Ready to playing (PlayOnLoad) in the WindowsMediaPlayer ;D

Example:
Code: [Select]
Public Class Form1
    Inherits Form

    Private OpenFileDialog1 As New OpenFileDialog
    Private file As String

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Text = "WMP Player"
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Support Audio & Video Files|*.*"
        OpenFileDialog1.Multiselect = True
    End Sub

    Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
        On Error Resume Next
        AxWindowsMediaPlayer1.URL = ComboBox1.Text
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each items As Object In OpenFileDialog1.FileNames
                ComboBox1.Items.Add(items)
                If ComboBox1.SelectedIndex = -1 Then
                    ComboBox1.Text = ComboBox1.Items.Item(0)
                    ComboBox1.SelectionLength = 0
                End If
            Next items
        End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        AxWindowsMediaPlayer1.URL = ComboBox1.Text
    End Sub

« Last Edit: 30 Mar '14 - 18:59 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #170 on: 31 Mar '14 - 05:30 »
Get code: Led Level Meter and Led Spectrum Visualizer for WindowsMediaPlayer ;D

Something at you to do.
1. Install AudioSoundRecorder for .NET Click here
2. Register AutoItX3DLL Click here
3. LedLevelMeterLib.dll Component Click here



 
Example:
Code: [Select]
Public Class Form1
    Inherits Form

    Private OpenFileDialog1 As New OpenFileDialog
    Private file As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If AudioSoundRecorder1.GetInputDevicesCount = 0 Then
            System.Windows.Forms.MessageBox.Show("No input device detected and/or connected: the program will now close. Please, tr" & _
    "y to plug a microphone into the sound card or an external audio device into the " & _
    "Line-In before launching again the program.")
            MyBase.Close()
        End If
        AudioSoundRecorder1.InitRecordingSystem()
        AudioSoundRecorder1.DisplayVUMeter.Create(Me.Handle.ToInt32)
    End Sub

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Text = "WMP Player"
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Support Audio & Video Files|*.*"
        OpenFileDialog1.Multiselect = True
    End Sub

    Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
        Dim oAutoIt As New AutoItX3Lib.AutoItX3
        Do While Not (oAutoIt.WinClose("Trial version reminder", "") > 0) : Loop
        AudioSoundRecorder1.EncodeFormats.ForRecording = AudioSoundRecorder.enumEncodingFormats.ENCODING_FORMAT_NOFILE
        AudioSoundRecorder1.StartFromDirectSoundDevice(0, 1, String.Empty)
        AudioSoundRecorder1.SetInputDeviceChannelDefault(0, 1)
        AudioSoundRecorder1.SetInputDeviceChannelVolume(0, 1, 1)
    End Sub

    Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
        On Error Resume Next
        AxWindowsMediaPlayer1.URL = ComboBox1.Text
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each items As Object In OpenFileDialog1.FileNames
                ComboBox1.Items.Add(items)
                If ComboBox1.SelectedIndex = -1 Then
                    ComboBox1.Text = ComboBox1.Items.Item(0)
                    ComboBox1.SelectionLength = 0
                End If
            Next items
        End If
    End Sub

    Private Sub AudioSoundRecorder1_VUMeterValueChange(ByVal sender As System.Object, ByVal e As AudioSoundRecorder.VUMeterValueChangeEventArgs) Handles AudioSoundRecorder1.VUMeterValueChange
        If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
            LedLevelMeter1.Level = e.nPeakLeft
            LedLevelMeter2.Level = e.nPeakRight
        Else
            LedLevelMeter1.Level = 0
            LedLevelMeter2.Level = 0
        End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        AxWindowsMediaPlayer1.URL = ComboBox1.Text
    End Sub

    Private Sub ClearItemSelectedToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearItemSelectedToolStripMenuItem.Click
        ComboBox1.Items.RemoveAt(ComboBox1.SelectedIndex)
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        AudioSoundRecorder1.Stop()
        AxWindowsMediaPlayer1.close()
    End Sub
End Class
« Last Edit: 1 Apr '14 - 09:34 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #171 on: 2 Apr '14 - 07:25 »
Free Download: LedLevelSpeakers Component ;D Please wait!

You must install Audio Sound Recorder, becouse using with.

« Last Edit: 2 Apr '14 - 09:50 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #172 on: 5 Apr '14 - 12:51 »
Download : WMPlayerLib.dll for WindowsMediaPlayer ;D Sample project Click here

Example:
Code: [Select]
Imports System
Imports WMPLib
Imports WMPlayerLib

Public Class Form1

    Private WMPlayer As WMPlayer
    Private state As Boolean = False

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        WMPlayer = New WMPlayer
        WMPlayer.PlayListCreate(Me, ListBox1) 'Create new playlist.
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Audio Files(*.mp3;*.wav;*.wma)|*.mp3;*.wav;*.wma|Vidio Files(*.mp4;*.dat;*.mpg;*.wmv;*.avi)|*.mp4;*.dat;*.mpg;*.wmv;*.avi|PlayList(*.mru)|*.mru|All Files(*.*)|*.*"
        ListBox1.HorizontalScrollbar = True
        CheckBox3.Checked = True
        AddHandler WMPlayer.SongEnding, AddressOf WMPlayer_SongEnding
        AddHandler WMPlayer.SongStopping, AddressOf WMPlayer_SongStopping
    End Sub

    Private Sub WMPlayer_SongStopping(ByVal sender As Object, ByVal e As EventArgs)
        TrackBar1.Value = TrackBar1.Minimum
        Timer1.Enabled = False
        Label2.Text = "00:00"      'It will working is stopped if push button stop.
        Label3.Text = "Stopped"
    End Sub

    Private Sub WMPlayer_SongEnding(ByVal sender As Object, ByVal e As EventArgs)
        If CheckBox1.CheckState = CheckState.Checked Then
            SongRepeat()
        End If
        If CheckBox2.CheckState = CheckState.Checked Then
            WMPlayer.PlayNoneStop()
            btnPLay.PerformClick()
        End If
        If CheckBox3.CheckState = CheckState.Checked Then
            TrackBar1.Value = TrackBar1.Minimum
            Timer1.Enabled = False
            Label2.Text = "00:00"      'It will working is stopped, when status song ending, if checked this box.
            Label3.Text = "Stopped"
        End If
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        OpenFileDialog1.Multiselect = True
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If ListBox1.SelectedIndex = -1 Then
                WMPlayer.PlayListAppendItems(OpenFileDialog1.FileNames) 'Add Items to the playlist.
                Select Case OpenFileDialog1.FilterIndex
                    Case 1
                        WMPlayer.Open(WMPlayer.PlayListSelectedItem) 'Return full path item list to selected is..WMPlayer.PlayListSelectedItem.
                        Label1.Text = WMPlayer.DurationString
                        TrackBar1.Maximum = WMPlayer.Duration(WMPlayer.PlayListSelectedItem)
                        TrackBar1.TickFrequency = TrackBar1.Maximum / 100 * 10
                    Case 2
                    Case Else
                End Select
            Else
                WMPlayer.PlayListAppendItems(OpenFileDialog1.FileNames)
            End If
        End If
    End Sub

    Private Sub btnPLay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPLay.Click
        If Not ListBox1.SelectedItem = Nothing Then
            Select Case OpenFileDialog1.FilterIndex
                Case 1
                    WMPlayer.Open(WMPlayer.PlayListSelectedItem)
                    Label1.Text = WMPlayer.DurationString
                    TrackBar1.Maximum = WMPlayer.Duration(WMPlayer.PlayListSelectedItem)
                    TrackBar1.TickFrequency = TrackBar1.Maximum / 100 * 10
                    WMPlayer.Play()
                    Timer1.Enabled = True
                Case 2
                Case Else
            End Select
            If Strings.InStr(btnPlause.Text, "Resume") Then btnPlause.Text = "Pause"
        End If
    End Sub

    Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
        btnPLay.PerformClick()
    End Sub

    Private Sub btnPlause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlause.Click
        If (WMPlayer.StatusString = "Playing") Or (WMPlayer.StatusString = "Paused") Then
            Select Case btnPlause.Text
                Case "Pause"
                    WMPlayer.Pause()
                    btnPlause.Text = "Resume"
                Case Else
                    WMPlayer.Resume()
                    btnPlause.Text = "Pause"
            End Select
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label2.Text = WMPlayer.PositionString
        TrackBar1.Value = WMPlayer.CurrentPosition
        Label3.Text = WMPlayer.StatusString
    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        WMPlayer.Stop()
        If Strings.InStr(btnPlause.Text, "Resume") Then btnPlause.Text = "Pause"
    End Sub

    Private Sub SongRepeat()
        WMPlayer.Stop()
        state = True
        Timer1.Enabled = False
        If state Then
            btnPLay.PerformClick()
        End If
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        WMPlayer.ChangePosition(CDbl(TrackBar1.Value))
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.CheckState = CheckState.Checked Then
            CheckBox2.Checked = False
            CheckBox3.Checked = False
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If CheckBox2.CheckState = CheckState.Checked Then
            CheckBox1.Checked = False
            CheckBox3.Checked = False
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.CheckState = CheckState.Checked Then
            CheckBox1.Checked = False
            CheckBox2.Checked = False
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        WMPlayer.Close()
    End Sub
End Class
« Last Edit: 5 Apr '14 - 13:10 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #173 on: 5 Apr '14 - 15:41 »
Get code : MPeg3-4 UserComponent ;D

You must compile to DLL file for using in the ToolBox.

Code: [Select]
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class Player
    Inherits UserControl

    Private openfile As OpenFileDialog
    Private pl As SoundControl
    Private IsBool As Boolean

    Private Sub Player_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        pl.InitSound(Me, CBtextBox, openfile)
    End Sub

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        pl = New SoundControl
        openfile = New OpenFileDialog
        openfile.FileName = Nothing
        openfile.Filter = "Audio Files(*.mp3;*.wav)|*.mp3;*.wav|Video Files(*.mp4)|*.mp4|All Files(*.*)|*.*"
        AddHandler pl.SongStopping, AddressOf pl_SongStopping
    End Sub

    Private Sub pl_SongStopping(ByVal sender As Object, ByVal e As EventArgs)
        timePosition.Enabled = False
        trackPos.Value = trackPos.Minimum
        lblPosition.Text = "00:00"
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        If CBtextBox.SelectedIndex = -1 Then
            If openfile.ShowDialog = DialogResult.OK Then
                pl.Open(openfile.FileName)
                pl.Stream()
                lblDuration.Text = pl.DorationString
                trackPos.Maximum = pl.MaxPosition
                trackPos.TickFrequency = trackPos.Maximum / 100 * 10
            End If
        Else
            If openfile.ShowDialog = DialogResult.OK Then
                pl.Open(openfile.FileName)
            End If
        End If
    End Sub

    Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
        If CBtextBox.SelectedIndex <> -1 Then
            pl.Stream()
            lblDuration.Text = pl.DorationString
            trackPos.Maximum = pl.MaxPosition
            trackPos.TickFrequency = trackPos.Maximum / 100 * 10
            pl.Play()
            timePosition.Enabled = True
            If Strings.InStr(btnPause.Text, "Resume") Then btnPause.Text = "Pause"
        End If
    End Sub

    Private Sub btnPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPause.Click
        If CBtextBox.SelectedIndex <> -1 Then
            Select Case IsBool
                Case False
                    If pl.StatusString = "playing" Then
                        pl.Pause()
                        btnPause.Text = "Resume"
                        IsBool = True
                    End If
                Case Else
                    If pl.StatusString = "paused" Then
                        pl.Resume()
                        btnPause.Text = "Pause"
                        IsBool = False
                    End If
            End Select
        End If
    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        If CBtextBox.SelectedIndex <> -1 Then
            pl.Stop()
            If Strings.InStr(btnPause.Text, "Resume") Then btnPause.Text = "Pause"
        End If
    End Sub

    Private Sub trackPos_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPos.Scroll
        pl.ChangePosition(CDbl(trackPos.Value))
    End Sub

    Private Sub timePosition_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timePosition.Tick
        lblPosition.Text = pl.PositionString
        trackPos.Value = pl.CurrentPosition
        lblStatus.Text = pl.StatusString
    End Sub
End Class

« Last Edit: 7 Apr '14 - 21:47 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net (vb2008, vc#, vc++)
« Reply #174 on: 7 Apr '14 - 21:50 »
Using AudioLib.dll UserComponent by writting code.

Example:
Code: [Select]
Imports System
Imports System.Drawing
Imports System.IO
Imports System.Windows.Forms
Imports Un4seen.Bass
Imports Un4seen.Bass.AddOn.Aac.BassAac

Public Class Player
    Inherits UserControl

    Private txtURL As Label
    Private CBtxtBox As ComboBox
    Private CBlistBox As ComboBox
    Private btnOpen As Button
    Private lblDuration As Label
    Private lblPosition As Label
    Private lblStatus As Label
    Private trackPos As TrackBar
    Private btnPlay As Button
    Private btnPause As Button
    Private btnStop As Button
    Private openfile As OpenFileDialog
    Private timePos As Timer
    Private stateTime As Timer
    Private Event SongStopping As EventHandler
    Private file As String
    Private IsPaused As Boolean
    Private strm As Integer

    Private Sub Player_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BassNet.Registration("", "")
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle.ToInt32)
        CBlistBox = New ComboBox
        CBlistBox.Size = CBtxtBox.Size
        CBlistBox.Location = CBtxtBox.Location
        Me.Controls.Add(CBlistBox)
    End Sub

    Public Sub New()
        MyBase.New()
        Me.Size = New Size(275, 125)
        InitializeComponent()

        txtURL = New Label
        txtURL.Text = "URL:"
        txtURL.Location = New Point(5, 15)
        txtURL.AutoSize = True

        CBtxtBox = New ComboBox
        CBtxtBox.Width = 200
        CBtxtBox.Location = New Point(35, 10)

        btnOpen = New Button
        btnOpen.Width = 30
        btnOpen.Text = "..."
        btnOpen.Location = New Point(240, 10)

        btnPlay = New Button
        btnPlay.Width = 55
        btnPlay.Text = "Play"
        btnPlay.Location = New Point(5, 95)
        btnPlay.Cursor = Cursors.Hand

        btnPause = New Button
        btnPause.Width = 55
        btnPause.Text = "Pause"
        btnPause.Location = New Point(110, 95)
        btnPause.Cursor = Cursors.Hand

        btnStop = New Button
        btnStop.Width = 55
        btnStop.Text = "Stop"
        btnStop.Location = New Point(215, 95)
        btnStop.Cursor = Cursors.Hand

        lblDuration = New Label
        lblDuration.Text = "00:00"
        lblDuration.Location = New Point(5, 60)
        lblDuration.AutoSize = True

        lblPosition = New Label
        lblPosition.Text = "00:00"
        lblPosition.Location = New Point(240, 60)
        lblPosition.AutoSize = True

        lblStatus = New Label
        lblStatus.Text = "stopped"
        lblStatus.Location = New Point(110, 40)
        lblStatus.AutoSize = True

        trackPos = New TrackBar
        trackPos.AutoSize = False
        trackPos.SetBounds(35, 60, 200, 20)

        timePos = New Timer
        stateTime = New Timer

        Me.Controls.AddRange(New Control() {txtURL, CBtxtBox, btnOpen, btnPlay, btnPause, btnStop, lblDuration, lblPosition, lblStatus, trackPos})

        openfile = New OpenFileDialog
        openfile.FileName = Nothing
        openfile.Filter = "Audio Files(*.wav;*.mp3)|*.wav;*.mp3|Video Files(*.mp4)|*.mp4|All Files(*.*)|*.*"

        AddHandler btnOpen.Click, New EventHandler(AddressOf btnOpen_Click)
        AddHandler btnPlay.Click, New EventHandler(AddressOf btnPlay_Click)
        AddHandler btnPause.Click, New EventHandler(AddressOf btnPause_Click)
        AddHandler btnStop.Click, New EventHandler(AddressOf btnStop_Click)
        AddHandler trackPos.Scroll, New EventHandler(AddressOf trackPos_Scroll)
        AddHandler timePos.Tick, New EventHandler(AddressOf timePos_Tick)
        AddHandler stateTime.Tick, New EventHandler(AddressOf stateTime_Tick)
        AddHandler Me.SongStopping, New EventHandler(AddressOf Me_SongStopping)
    End Sub

    Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As EventArgs)
        If openfile.ShowDialog = DialogResult.OK Then
            CBlistBox.Items.Add(openfile.FileName)
            CBtxtBox.Items.Add(Path.GetFileName(openfile.FileName))
            If CBtxtBox.SelectedIndex = -1 Then
                CBtxtBox.SelectedIndex = 0
                CBlistBox.SelectedIndex = CBtxtBox.SelectedIndex
                If Strings.InStr(IO.Path.GetExtension(CBtxtBox.Text), "mp4", CompareMethod.Text) Then
                    strm = BASS_MP4_StreamCreateFile(CBlistBox.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
                Else
                    strm = Bass.BASS_StreamCreateFile(CBlistBox.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
                End If
                lblDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss")
                trackPos.Maximum = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm))
                trackPos.TickFrequency = trackPos.Maximum / 100 * 10
            End If
        End If
    End Sub

    Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As EventArgs)
        If CBtxtBox.Items.Count = 0 Then Return
        If strm Then Bass.BASS_StreamFree(strm)
        CBlistBox.SelectedIndex = CBtxtBox.SelectedIndex
        If Strings.InStr(IO.Path.GetExtension(CBtxtBox.Text), "mp4", CompareMethod.Text) Then
            strm = BASS_MP4_StreamCreateFile(CBlistBox.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
        Else
            strm = Bass.BASS_StreamCreateFile(CBlistBox.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
        End If
        lblDuration.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm)), "mm:ss")
        trackPos.Maximum = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm))
        trackPos.TickFrequency = trackPos.Maximum / 100 * 10
        Bass.BASS_ChannelPlay(strm, True)
        timePos.Enabled = True
        stateTime.Start()
        If Strings.InStr(btnPause.Text, "Resume") Then btnPause.Text = "Pause"
        IsPaused = False
    End Sub

    Private Sub btnPause_Click(ByVal sender As Object, ByVal e As EventArgs)
        If BASS_ChannelStatusString = "stopped" Then Return
        Select Case IsPaused
            Case False
                Bass.BASS_ChannelPause(strm)
                btnPause.Text = "Resume"
                IsPaused = True
            Case Else
                Bass.BASS_ChannelPlay(strm, False)
                btnPause.Text = "Pause"
                IsPaused = False
        End Select
    End Sub

    Private Sub btnStop_Click(ByVal sender As Object, ByVal e As EventArgs)
        If (BASS_ChannelStatusString = "playing") Or (BASS_ChannelStatusString = "paused") Then
            Bass.BASS_ChannelStop(strm)
            If Strings.InStr(btnPause.Text, "Resume") Then btnPause.Text = "Pause"
            IsPaused = False
        End If
    End Sub

    Private Sub Me_SongStopping(ByVal sender As Object, ByVal e As EventArgs)
        timePos.Enabled = False
        trackPos.Value = trackPos.Minimum
        lblPosition.Text = "00:00"
        lblStatus.Text = "stopped"
    End Sub

    Public Sub Closed()  'For using in the FormClosing.
        If BASS_ChannelStatusString <> "stopped" Then Bass.BASS_ChannelStop(strm)
        Bass.BASS_Free()
    End Sub

    Private Sub trackPos_Scroll(ByVal sender As Object, ByVal e As EventArgs)
        Bass.BASS_ChannelSetPosition(strm, Bass.BASS_ChannelSeconds2Bytes(strm, CDbl(trackPos.Value)), BASSMode.BASS_POS_BYTES)
    End Sub

    Private Sub timePos_Tick(ByVal sender As Object, ByVal e As EventArgs)
        trackPos.Value = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm))
        lblPosition.Text = Utils.FixTimespan(Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm)), "mm:ss")
        lblStatus.Text = BASS_ChannelStatusString
    End Sub

    Protected Overridable Sub OnStopping()
        If BASS_ChannelStatusString = "stopped" Then
            stateTime.Stop()
            RaiseEvent SongStopping(Me, New EventArgs)
        End If
    End Sub

    Private Sub stateTime_Tick(ByVal sender As Object, ByVal e As EventArgs)
        OnStopping()
    End Sub

    Public ReadOnly Property BASS_ChannelStatusString() As String
        Get
            Dim state As String = Nothing
            Select Case Bass.BASS_ChannelIsActive(strm)
                Case BASSActive.BASS_ACTIVE_PAUSED
                    state = "paused"
                Case BASSActive.BASS_ACTIVE_PLAYING
                    state = "playing"
                Case BASSActive.BASS_ACTIVE_STALLED
                    state = "stalled"
                Case Else
                    state = "stopped"
            End Select
            Return state
        End Get
    End Property
End Class
« Last Edit: 9 Apr '14 - 11:40 by sak2005 »