Introduction
The bottom line "This article shows how to use remoting / XML / databases
/ threads / ping / custom controls to create a media player and a remote control
for the media player"
This article is really a bit of fun, I know I certainly had fun writing the
original project. The original project was submitted for my degree project,
this article represents a cut down version of the original. The original project
code is too big to submit to codeproject.
So what does this article do, well its about using a bunch of different things
together, to come up with something fun. So this is what I did, the application
is split into 2 parts a ServerApp and a ClientApp
- ServerApp : Hosts a Microsoft media player control, and a track list, it
also hosts a custom control that I made to manage an inbuilt media library
- ClientApp : Hosts a track list and some buttons to control the ServerApp
media player, it also hosts a custom control that I made to manage an inbuilt
media library
It may be obvious, but the intention, is to have the ServerApp installed one
one machine (with audio capabilities), and have the ClientApp installed on another
machine control the ServerApp music. The ServerApp would be connected to a stereo
and the ClientApp could provide remote control track lists to the ServerApp,
and have it play different songs on demand. The Client can also, stop FF on
track, REW one track, skip tracks, which will be done at the ServerApp PC.
This is done using a variety of techniques such as
- .NET remoting
- parsing XML (for tracklists)
- ping (.NET 1.1 didnt have a ping class, so that was found right here at
codeproject, this is mentioned in the code)
- custom controls
- Enable themes like windows XP uses (this was not easy in .NET v1.1, again
see the code)
- Database interaction
- Custom controls
- Embedded Microsoft media player control
NOTE : When I developed the original code, I wanted to be able to test parts
of the code in isolation (which is a good thing), so the code was mainly custom
controls, as such there are lots of different projects, and when zipped, its
all just too big for the codeproject guidelines. So if you are still interested
I have put all code in a zip file at Re_Mp3
code web site it contains all the code for this article. The 2 files at
the top are simply installers.
Sorry if this annoys some folk nothing I could do about the size of files.
BIG THANKS : When I wrote the orginal code for my degree, I came across an
icon site, called fooods icons, which at the time had free icons for non commercial
ventures, this being such a venture. So I took some icons from this site. Fooods
has now changed, and I cant see if icons are free for non commercial ventures
any more, so am sorry if I have breached something here, it was not intentional.
The Code
I could not include the code in the uploaded files, as its too big, but as
I say if anyone wants it, they can get it all from the zip at Re_Mp3
code web site
Running The Code
If you are using the zips from here, simply unzip the 2 files, and run the
installers. Then when they are installed, start the ServerApp 1st, then the
ClientApp.
If you are using the code contained at the Re_Mp3
code web site you can open the ServerApp / ClientApp solutions in Visual
Studio 2003 and build them and run them from within Visual Studio.
So What Does It All Look Like
Lets have a look shall we
ServerApp
The Server contains 2 custom controls (see the Re_Mp3
code web site if you are interested) these are a Media Player control and
a MediaLibrary control.
ServerApp Media Player Control
The Media Player control makes use of an embedded Microsoft media player control.
The control offers the following faetures
- Drag and drop files into track list from file system
- Currently playing track is bold
- Double click track, to play new track
- Change the format of the Microsoft media player control GUI
- Save and load tracklist to XML
- Use delete key to delete tracks
- Use CTRL / SHIFT to select tracks
- Use up/down arrow to move selected tracks
- When playing tracks from another computer (coming from the ClientApp perhaps)
will PING the computer who owns the track to make sure it can be played
NOTE :
The Microsoft media player control does not support full UNC paths, so I have
had to use a format such as \\NODE\DRIVE\DIRECTORY\FILE like \\BUDHA01\D$\MP3's\Buzzcocks
- singles going steady.
The one draw back with this approach is that the 2 machines need to have the
default administrative shares available for any drive that the user wishes to
use with the 2 Re_Mp3 applications.
For example I store music on my D:\ drive on my main PC so I have to make sure
D$ is accessable, likewise I store all music on my laptop on C:\, so I have
to make sure C$ is accessable on my laptop.
I know this is a major pain, but thats all I could do to make it work with
the Microsoft media player control. A better way would be to use DirectSound.
Maybe someone that wants to take this further can replace the embedded media
player control, that the ServerApp uses, with a DirectSound based custom control.
ServerApp Media Library Control
The Media Library control makes use of a Microsoft access database to store
all the logged music
The control offers the following faetures
- View library items by filesystem view / or by genre
- Change the view of the track to be detaills, icons, or thumnails
- Show all the details for a single track
- Add a logged folder to the Media player using right click menu
- manage the underlying database by using The Add folder / Share Files button,
or right click on the folder in the file system treeview and use delete option
The logging is slightly clever, in that a new scan is done each time the application
is started to see if any new file exists under the saved file system paths already
in the database. If new entries are found they are added to the library. Its
like having a filesystem watcher without having the application running the
whole time
ClientApp
As the Client application is used to control the Server applications music
being played, it needs to know where the server is. To this end it has an initial
screen which lists all network computers in the current network (see my other
article Listings
network computers), the user may choose one of these. If the Client can
make contact with a server at the address picked, the main client interface
is shown, otherwise the ClientApp quits.
Once sucessfully loaded, the Client contains 2 custom controls (see the Re_Mp3
code web site if you are interested) these are a ClientTrackList control
and a MediaLibrary control.
ClientApp ClientTrackList Control
The ClientTrackList control offers the following faetures
- Drag and drop files into track list from file system
- Currently playing track is bold
- Double click track, to play new track
- Save and load tracklist to XML
- Use delete key to delete tracks
- Use CTRL / SHIFT to select tracks
- Use up/down arrow to move selected tracks
- Use the Re-MP3 server : Media Player Operations to control the Re_Mp3 server,
such as create a new track list, STOP , REW one track, FF one track
This following screen shot shows this controlling in action, the current ServerApp
track is also bold at the Client end. This remote control is all done through
standard .NET Remoting technology
ClientApp Media Library Control
Is the same as the one used within the ServerApp
Well thats about it, apart from the couple of things to watch shown below.
Hope someone likes it. It was fun for me, so I dont mind if no one likes it
really, cos I did.
Things to watch
- As this project uses .NET remoting, your firewall will probably need to
know about the 2 applications, so when it asks accept the 2 projects as allowable
items
- As this project uses skinning, I have made the installers only works for
versions of windows >= Windows XP
- The Microsoft media player control does not support full UNC paths, so I
have had to use a format such as \\NODE\DRIVE\DIRECTORY\FILE like \\BUDHA01\D$\MP3's\Buzzcocks
- singles going steady. The one draw back with this approach is that the 2
machines need to have the default administrative shares available for any
drive that the user wishes to use with the 2 Re_Mp3 applications. For example
I store music on my D:\ drive on my main PC so I have to make sure D$ is accessable,
likewise I store all music on my laptop on C:\, so I have to make sure C$
is accessable on my laptop. I know this is a major pain, but thats all I could
do to make it work with the Microsoft media player control. A better way would
be to use DirectSound. Maybe someone that wants to take this further can replace
the embedded media player control, that the ServerApp uses, with a DirectSound
based custom control.
What Do You Think ?
Thats it, I would just like to ask, if you liked the article please vote for
it.
History
v1.0 26/11/06