Click here to Skip to main content
12,896,806 members (58,300 online)
Click here to Skip to main content
Add your own
alternative version


23 bookmarked
Posted 28 Mar 2009

Sleeper Music Player

, 18 Oct 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
A playlist player for Windows that ends at a user specified time


I liked to listen to music when I went to bed, but getting up (and waking up) to turn it off again was a nightmare! I had a few options:

  1. Make a small enough playlist every time relative to how late it was
  2. Get a program that would turn off my PC after a while, but this usually led to me waking up due to the abrupt end and sudden Windows music!

So that's how this project came about.


In this project, I use Visual Studio 2008 prof (a small gift from uni:D) but I intend on making a 2005 edition, and it should definitely work with the Express Editions. The language is C# although if you ask nicely, I may write a copy in VB though I would prefer not to as I haven't done that in ages!

It is complete with a solution file and folders needed to get this to work, including a compiled example or two.

It uses all the basic components available to any basic developer using the Visual Studio IDEs. and Windows XP. I have SP3 installed on my machines but I'm sure it will work fine on earlier versions of XP. As for Vista & ME etc., I cannot say, because I don't have them, so if someone could try it out and get an email to me, that would be great!
The bulk of this code is auto-generated by the IDE, I did the bits in between.

I used wmplib, Windows Forms {listbox, buttons, labels, textboxes, etc.} and some interesting shutdown code that I got from this very website.

The Program

  • Plays a precreated playlist to a specified time, then plays that track until the end and shuts down the PC if needed or merely ends the program
  • Controls the volume for the app only
  • Allows the user to control file played, and volume
  • Allows the user to end the playing straight after the current song
  • Supports internet streams
  • Several UI bug fixes
  • Updated to
  • More in the TODO.txt file
  • New repo added for easier code management

Using the Code

It should be straight-forward(tm) but I never know. I have tried to give good variable names. If you look at the TODO.txt, it shows you whereabouts I am at the moment.
Example of a button call follows things to note.

Godmode is a debugging mode that probably won't be removed, if you write "Godmode" (no quotes) into the address of the playlist in settings, then you get to see the "god chat".

private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        if (Godmode)
            listBox2.Items.Add("settings opened");
        //button3_Click(null, null);
        Settings settings = new Settings();
        if (label1.Text != Settings1.Default.URL)
            if (Godmode)
                listBox2.Items.Add("playlist url changed");
            stopButton_Click(null, null);
            startButton_Click(null, null);
            label1.Text = Settings1.Default.URL;
        if (Godmode)
            this.Width = formwidth + listBox2.Width + 10;
            listBox2.Visible = true;
            this.Width = formwidth;
            listBox2.Visible = false;
        if (Godmode)
            if (Player.settings.volume != Settings1.Default.Volume)
                listBox2.Items.Add("volume changed from " + 
			Player.settings.volume + " to " + Settings1.Default.Volume);
        Player.settings.volume = Settings1.Default.Volume;

Points of Interest

I learned that:

  1. Combo boxes are great, but not here.
  2. The datetime box is stupid, moves days itself but not hours!
  3. Listboxes are useful but can be tricky.
  4. Wmplib is kinda out of date, but works I guess...
  5. The wmplaylist format is simple, but I ain't very good at XML.
  6. Coding for fun can be useful.



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


About the Author

Software Developer (Junior)
United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
kkumarsanjiv5-Mar-11 7:41
memberkkumarsanjiv5-Mar-11 7:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 18 Oct 2009
Article Copyright 2009 by Mickster04
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid