Click here to Skip to main content
15,867,330 members
Articles / Programming Languages / C#
Article

Remote control media player

Rate me:
Please Sign up or sign in to vote.
4.86/5 (36 votes)
11 Feb 20078 min read 193.8K   6.9K   145   38
An article which shows how to remotley control a media player

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

Image 1

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

Image 2

Image 3

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.

Image 4

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

Image 5

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

Image 6

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.

Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

Comments and Discussions

 
QuestionCan-not play files Pin
r1ck11114-Jul-09 9:44
r1ck11114-Jul-09 9:44 
AnswerRe: Can-not play files Pin
Sacha Barber14-Jul-09 21:36
Sacha Barber14-Jul-09 21:36 
GeneralRe: Can-not play files Pin
r1ck11114-Jul-09 23:05
r1ck11114-Jul-09 23:05 
Ok no problem, thanks anyway.

Richard
GeneralRe: Can-not play files Pin
Sacha Barber15-Jul-09 0:36
Sacha Barber15-Jul-09 0:36 
GeneralRe: Can-not play files Pin
r1ck11115-Jul-09 4:49
r1ck11115-Jul-09 4:49 
GeneralRe: Can-not play files Pin
Sacha Barber15-Jul-09 5:55
Sacha Barber15-Jul-09 5:55 
GeneralRe: Can-not play files Pin
r1ck11115-Jul-09 12:25
r1ck11115-Jul-09 12:25 
GeneralWhere is The Source Code Pin
MR_Sia6-Jan-09 7:59
MR_Sia6-Jan-09 7:59 
GeneralRe: Where is The Source Code Pin
Sacha Barber6-Jan-09 8:37
Sacha Barber6-Jan-09 8:37 
GeneralRe: Where is The Source Code Pin
Member 793259-Apr-09 10:17
Member 793259-Apr-09 10:17 
GeneralRe: Where is The Source Code Pin
Sacha Barber9-Apr-09 22:17
Sacha Barber9-Apr-09 22:17 
Generalsource code not available Pin
birjubirju24-Sep-08 10:47
birjubirju24-Sep-08 10:47 
QuestionSource @ http://www.vibrant-web-design.com/sacha/sb54_CSAI_Proj.htm Pin
tej dhawan18-Aug-08 7:23
tej dhawan18-Aug-08 7:23 
NewsWindows XP theme for .Net applications Pin
Mihai Maerean12-Mar-07 20:10
Mihai Maerean12-Mar-07 20:10 
GeneralRe: Windows XP theme for .Net applications Pin
Sacha Barber12-Mar-07 23:50
Sacha Barber12-Mar-07 23:50 
QuestionWhats wrong with remote desktop? Pin
Scope11-Feb-07 9:53
Scope11-Feb-07 9:53 
AnswerRe: Whats wrong with remote desktop? Pin
Sacha Barber11-Feb-07 22:40
Sacha Barber11-Feb-07 22:40 
AnswerRe: Whats wrong with remote desktop? Pin
only1chip23-Oct-09 14:09
only1chip23-Oct-09 14:09 
GeneralRe: Whats wrong with remote desktop? Pin
only1chip23-Oct-09 17:47
only1chip23-Oct-09 17:47 
GeneralRe: Whats wrong with remote desktop? Pin
Sacha Barber23-Oct-09 20:58
Sacha Barber23-Oct-09 20:58 
GeneralNice but ... Pin
Vertyg011-Feb-07 9:18
Vertyg011-Feb-07 9:18 
GeneralRe: Nice but ... Pin
Sacha Barber11-Feb-07 22:36
Sacha Barber11-Feb-07 22:36 
GeneralRe: Nice but ... Pin
mmeissa4-Jul-08 14:26
mmeissa4-Jul-08 14:26 
Generalvery nice Pin
V. Thieme11-Feb-07 9:02
V. Thieme11-Feb-07 9:02 
GeneralRe: very nice Pin
Sacha Barber11-Feb-07 22:35
Sacha Barber11-Feb-07 22:35 

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.