Introduction
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:
- Make a small enough playlist every time relative to how late it was
- 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.
Background
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 1.0.2.0
- 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");
}
Settings settings = new Settings();
settings.ShowDialog();
if (label1.Text != Settings1.Default.URL)
{
if (Godmode)
{
listBox2.Items.Add("playlist url changed");
}
listBox1.Items.Clear();
stopButton_Click(null, null);
startButton_Click(null, null);
label1.Text = Settings1.Default.URL;
}
if (Godmode)
{
this.Width = formwidth + listBox2.Width + 10;
listBox2.Visible = true;
}
else
{
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:
- Combo boxes are great, but not here.
- The datetime box is stupid, moves days itself but not hours!
- Listboxes are useful but can be tricky.
- Wmplib is kinda out of date, but works I guess...
- The wmplaylist format is simple, but I ain't very good at XML.
- Coding for fun can be useful.
History