eMedia Player Code
Posted: Sun Nov 15, 2009 10:14 am
Hi All
Here is the code for my eMedia Player, just in case anyone wants to know how its structured.
SOURCE FILES BELOW cooll;
![Image]()
Here is the code for my eMedia Player, just in case anyone wants to know how its structured.
SOURCE FILES BELOW cooll;

Code: Select all
ChrisImports System
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Public IsMousePressed = 0
Public a
Public b
Public IsInsideControl
Public PBLocation
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HTCAPTION As Integer = &H2
<Runtime.InteropServices.DllImport("User32.dll")> _
Public Shared Function ReleaseCapture() As Boolean
End Function
<Runtime.InteropServices.DllImport("User32.dll")> _
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click
///this is to open the Controls
Me.Width = (861)
End Sub
Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label8.Click
/// this is too close the Controls
Me.Width = (622)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PlayerControl.settings.volume = PictureBox1.Location.X.ToString
Dim Tips As New Windows.Forms.ToolTip
Tips.SetToolTip(Panel3, "Choose your Theme")
Tips.SetToolTip(Label5, "Exit eMedia Player")
Tips.SetToolTip(Label6, "Minimise eMedia Player")
Tips.SetToolTip(Label7, "Open eMedia Controls")
Tips.SetToolTip(Label8, "Close eMedia Contols")
Tips.SetToolTip(PictureBox9, "Click to goto codenstuff.com")
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
PictureBox1.Location = New Point(PictureBox1.Location.X + (e.X - a), PictureBox1.Location.Y)
IsMousePressed = 0
PBLocation = PictureBox1.Location.X.ToString
If PBLocation < 0 Then
PictureBox1.Location = New Point(0, PictureBox1.Location.Y)
End If
If PBLocation > 100 Then
PictureBox1.Location = New Point(100, PictureBox1.Location.Y)
End If
PBLocation = PictureBox1.Location.X.ToString
IsInsideControl = 0
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
a = e.X
b = e.Y
IsMousePressed = 1
IsInsideControl = 1
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If IsMousePressed = 1 Then
If PBLocation < 101 AndAlso IsInsideControl = 1 AndAlso PBLocation > -1 Then
PlayerControl.settings.volume = PictureBox1.Location.X.ToString
PictureBox1.Location = New Point(PictureBox1.Location.X + (e.X - a), PictureBox1.Location.Y)
PBLocation = PictureBox1.Location.X.ToString
End If
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If PlayerControl.playState = WMPLib.WMPPlayState.wmppsPlaying Then
Dim CurPos As Integer = Convert.ToInt32(PlayerControl.Ctlcontrols.currentPosition * 1000)
Dim DurationVar As Integer = Convert.ToInt32(PlayerControl.currentMedia.duration * 1000)
If DurationVar > 0 Then
PictureBox2.Location = New Point(Convert.ToInt32((CurPos * 100) / DurationVar), PictureBox2.Location.Y)
End If
End If
If PlayerControl.playState = WMPLib.WMPPlayState.wmppsStopped Then
PictureBox2.Location = New Point(0, PictureBox2.Location.Y)
End If
End Sub
Private Sub PictureBox2_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseUp
PictureBox2.Location = New Point(PictureBox2.Location.X + (e.X - a), PictureBox2.Location.Y)
IsMousePressed = 0
PBLocation = PictureBox2.Location.X.ToString
If PBLocation < 0 Then
PictureBox2.Location = New Point(0, PictureBox2.Location.Y)
End If
If PBLocation > 100 Then
PictureBox2.Location = New Point(100, PictureBox2.Location.Y)
End If
PBLocation = PictureBox2.Location.X.ToString
IsInsideControl = 0
End Sub
Private Sub PictureBox2_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
a = e.X
b = e.Y
IsMousePressed = 1
IsInsideControl = 1
End Sub
Private Sub PictureBox2_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
If IsMousePressed = 1 Then
If PBLocation < 101 AndAlso IsInsideControl = 1 AndAlso PBLocation > -1 Then
Try
If (PlayerControl.currentMedia.duration <> 0) Then
Dim NewPerc As Double = Convert.ToDouble(PictureBox2.Location.X) / 100
Dim DurationVar As Integer = Convert.ToInt32(PlayerControl.currentMedia.duration * 1000) ' milliseconds
Dim NewPos As Integer = (DurationVar * NewPerc) / 1000
PlayerControl.Ctlcontrols.currentPosition = NewPos
Else
PictureBox2.Location = New Point(0, PictureBox2.Location.Y)
End If
Catch ex As Exception
End Try
PictureBox2.Location = New Point(PictureBox2.Location.X + (e.X - a), PictureBox2.Location.Y)
PBLocation = PictureBox2.Location.X.ToString
End If
End If
End Sub
Private Sub Label9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.Click
Try
ListBox1.Items.Clear()
Loc.ShowDialog()
TextBox1.Text = Loc.SelectedPath
Dim dFolder As DirectoryInfo = New DirectoryInfo(TextBox1.Text)
Dim fFileArray() As FileInfo = dFolder.GetFiles("*.wav")
'"Filearray" at this step is holding the files.
Dim fFile As FileInfo
'Loop through the arrays and list them in the listbox.
For Each fFile In fFileArray
ListBox1.Items.Add(fFile.Name)
Next
Catch ex As Exception
End Try
End Sub
Private Sub ListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Click
Try
PlayerControl.URL = TextBox1.Text & "\" & ListBox1.SelectedItem
Catch ex As Exception
End Try
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
PlayerControl.Ctlcontrols.play()
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
PlayerControl.Ctlcontrols.stop()
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
PlayerControl.Ctlcontrols.pause()
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
Application.Exit()
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
Me.BackgroundImage = My.Resources._2
Label9.ForeColor = Color.Blue
Label10.ForeColor = Color.CadetBlue
Label11.ForeColor = Color.CadetBlue
Panel1.BackgroundImage = My.Resources.barblue
Panel2.BackgroundImage = My.Resources.barblue
PictureBox1.BackgroundImage = My.Resources.bitblue
PictureBox2.BackgroundImage = My.Resources.bitblue
End Sub
Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
Me.BackgroundImage = My.Resources._3
Label9.ForeColor = Color.GreenYellow
Label10.ForeColor = Color.GreenYellow
Label11.ForeColor = Color.GreenYellow
Panel1.BackgroundImage = My.Resources.bargreen
Panel2.BackgroundImage = My.Resources.bargreen
PictureBox1.BackgroundImage = My.Resources.bitgreen
PictureBox2.BackgroundImage = My.Resources.bitgreen
End Sub
Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click
Me.BackgroundImage = My.Resources._4
Label9.ForeColor = Color.DarkGray
Label10.ForeColor = Color.DarkGray
Label11.ForeColor = Color.DarkGray
Panel1.BackgroundImage = My.Resources.barblack
Panel2.BackgroundImage = My.Resources.barblack
PictureBox1.BackgroundImage = My.Resources.bitblack
PictureBox2.BackgroundImage = My.Resources.bitblack
End Sub
Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click
Me.BackgroundImage = My.Resources._5
Label9.ForeColor = Color.MistyRose
Label10.ForeColor = Color.Red
Label11.ForeColor = Color.Red
Panel1.BackgroundImage = My.Resources.barred
Panel2.BackgroundImage = My.Resources.barred
PictureBox1.BackgroundImage = My.Resources.bitred
PictureBox2.BackgroundImage = My.Resources.bitred
End Sub
Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click
Me.BackgroundImage = My.Resources._6
Label9.ForeColor = Color.Yellow
Label10.ForeColor = Color.Yellow
Label11.ForeColor = Color.Yellow
Panel1.BackgroundImage = My.Resources.barYellow
Panel2.BackgroundImage = My.Resources.barYellow
PictureBox1.BackgroundImage = My.Resources.bityellow
PictureBox2.BackgroundImage = My.Resources.bityellow
End Sub
Private Sub PictureBox8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox8.Click
Me.BackgroundImage = My.Resources._1
Label9.ForeColor = Color.Black
Label10.ForeColor = Color.DarkGray
Label11.ForeColor = Color.DarkGray
Panel1.BackgroundImage = My.Resources.barblack
Panel2.BackgroundImage = My.Resources.barblack
PictureBox1.BackgroundImage = My.Resources.bit
PictureBox2.BackgroundImage = My.Resources.bit
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If e.Button = MouseButtons.Left Then
ReleaseCapture()
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label12.Text = TimeOfDay
End Sub
Private Sub PictureBox9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click
Process.Start("iexplore.exe", "http://www.codenstuff.com")
End Sub
End Class