Click here to Skip to main content
15,894,825 members
Articles / Programming Languages / Visual Basic

WMP Power Hour APP

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
31 Jul 2007CPOL1 min read 53.8K   1K   18  
Using the Windows Media Player Component

Public Class PowerHour
    Dim startTime As DateTime
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' If the button is clicked then start the timer. Oncer the timer is started and the button is clicked again
        ' the timer is stopped and the player fails
        If (Timer1.Enabled) Then
            Timer1.Stop()
            MessageBox.Show("You did not complete power hour", "Failed")
            Label3.Text = String.Empty
            Label4.Text = String.Empty
        Else
            startTime = DateTime.Now()
            Timer1.Start()
            Button1.Text = "Stop!"
        End If
    End Sub

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

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim span As TimeSpan = DateTime.Now.Subtract(startTime)
        Label4.Text = span.Seconds.ToString

        ProgressBar1.Value += 1

        If ProgressBar1.Value = 60 Then
            ProgressBar1.Value = 0
            ProgressBar2.Value += 1
            Dim span2 As TimeSpan = DateTime.Now.Subtract(startTime)
            Label3.Text = span2.Minutes.ToString
            wmp.Ctlcontrols.next()
            If ProgressBar2.Value = 60 Then
                MessageBox.Show("You've completed power hours", "Congratulations!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                ProgressBar2.Value = 0
            End If
        End If
    End Sub

    Private Sub AddMusicToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddMusicToolStripMenuItem.Click
        Dim dlg As New OpenFileDialog()
        dlg.InitialDirectory = "C:\"
        dlg.CheckFileExists = True
        dlg.Title = "Import a Playlist from WMP"
        dlg.Filter = "Windows Media Playlists|*.wpl"
        dlg.Multiselect = False
        dlg.ShowDialog()
        wmp.URL = dlg.FileName
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Still in school, program for fun...

Comments and Discussions