0% found this document useful (0 votes)
6 views5 pages

Code Source

This document is a Visual Basic .NET code for a media player application that allows users to browse, play, pause, stop, and manage a playlist of media files. It includes features for adding, removing, and clearing items from the playlist, as well as shuffling and repeating playback. The application utilizes the Windows Media Player library to handle media playback and provides a user interface for interaction.

Uploaded by

osmankargbo167
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Code Source

This document is a Visual Basic .NET code for a media player application that allows users to browse, play, pause, stop, and manage a playlist of media files. It includes features for adding, removing, and clearing items from the playlist, as well as shuffling and repeating playback. The application utilizes the Windows Media Player library to handle media playback and provides a user interface for interaction.

Uploaded by

osmankargbo167
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Imports WMPLib

Imports [Link]

Public Class Form1

Private currentIndex As Integer = -1

Private repeatEnabled As Boolean = False

Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles [Link]

[Link] = "Select Media File"

[Link] = "Media Files|*.mp3;*.mp4;*.wav;*.wmv;*.avi"

[Link] = [Link]([Link])

If [Link]() = [Link] Then

[Link] = [Link]

[Link] = [Link]([Link])

End If

End Sub

Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles [Link]

If [Link] >= 0 Then

currentIndex = [Link]

PlayFromPlaylist(currentIndex)

ElseIf [Link] <> "" Then

[Link]()

End If

End Sub
Private Sub btnPause_Click(sender As Object, e As EventArgs) Handles [Link]

[Link]()

End Sub

Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles [Link]

[Link]()

End Sub

Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles [Link]

If [Link] = 0 Then Exit Sub

currentIndex += 1

If currentIndex >= [Link] Then currentIndex = 0

PlayFromPlaylist(currentIndex)

End Sub

Private Sub btnPrevious_Click(sender As Object, e As EventArgs) Handles [Link]

If [Link] = 0 Then Exit Sub

currentIndex -= 1

If currentIndex < 0 Then currentIndex = [Link] - 1

PlayFromPlaylist(currentIndex)

End Sub

Private Sub PlayFromPlaylist(index As Integer)

If [Link] = 0 Then Exit Sub


If index < 0 OrElse index >= [Link] Then Exit Sub

Dim filePath As String = [Link](index).ToString()

If Not [Link](filePath) Then

[Link]("File not found: " & filePath)

Exit Sub

End If

currentIndex = index

[Link] = filePath

[Link] = [Link](filePath)

[Link]()

End Sub

Private Sub btnAddToPlaylist_Click(sender As Object, e As EventArgs) Handles [Link]

If [Link]() = [Link] Then

[Link]([Link])

End If

End Sub

Private Sub btnRemoveFromPlaylist_Click(sender As Object, e As EventArgs) Handles


[Link]

If [Link] >= 0 Then

[Link]([Link])

End If

End Sub

Private Sub btnClearPlaylist_Click(sender As Object, e As EventArgs) Handles [Link]


[Link]()

End Sub

Private Sub lstPlaylist_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


[Link]

If [Link] IsNot Nothing Then

[Link] = [Link]()

[Link] = [Link]([Link]())

End If

End Sub

Private Sub btnShuffle_Click(sender As Object, e As EventArgs) Handles [Link]

Dim rnd As New Random()

Dim items = [Link](Of String).OrderBy(Function(x) [Link]()).ToList()

[Link]()

For Each item In items

[Link](item)

Next

End Sub

Private Sub btnRepeat_Click(sender As Object, e As EventArgs) Handles [Link]

repeatEnabled = Not repeatEnabled

[Link] = If(repeatEnabled, [Link], [Link])

End Sub
Private Sub AxWindowsMediaPlayer1_PlayStateChange(sender As Object, e As
AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles
[Link]

If repeatEnabled AndAlso [Link] = [Link] Then

[Link]()

End If

End Sub

Private Sub progressBar_MouseDown(sender As Object, e As MouseEventArgs) Handles


[Link]

If [Link] IsNot Nothing Then

Dim newPosition As Double = (e.X / [Link]) *


[Link]

[Link] = newPosition

End If

End Sub

End Class

You might also like