Click here to Skip to main content
Click here to Skip to main content

Remote control media player

, 11 Feb 2007
Rate this:
Please Sign up or sign in to vote.
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

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

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

Share

About the Author

Sacha Barber
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 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 Pinmemberr1ck11114-Jul-09 10:44 
AnswerRe: Can-not play files PinmvpSacha Barber14-Jul-09 22:36 
GeneralRe: Can-not play files Pinmemberr1ck11115-Jul-09 0:05 
GeneralRe: Can-not play files PinmvpSacha Barber15-Jul-09 1:36 
GeneralRe: Can-not play files Pinmemberr1ck11115-Jul-09 5:49 
GeneralRe: Can-not play files PinmvpSacha Barber15-Jul-09 6:55 
GeneralRe: Can-not play files Pinmemberr1ck11115-Jul-09 13:25 
GeneralWhere is The Source Code Pinmembersiamak_mah6-Jan-09 8:59 
GeneralRe: Where is The Source Code PinmvpSacha Barber6-Jan-09 9:37 
GeneralRe: Where is The Source Code PinmemberMember 793259-Apr-09 11:17 
GeneralRe: Where is The Source Code PinmvpSacha Barber9-Apr-09 23:17 
Generalsource code not available Pinmemberbirjubirju24-Sep-08 11:47 
NewsWindows XP theme for .Net applications PinmemberMihai Maerean12-Mar-07 21:10 
GeneralRe: Windows XP theme for .Net applications PinmemberSacha Barber13-Mar-07 0:50 
QuestionWhats wrong with remote desktop? PinmemberScope11-Feb-07 10:53 
AnswerRe: Whats wrong with remote desktop? PinmemberSacha Barber11-Feb-07 23:40 
AnswerRe: Whats wrong with remote desktop? Pinmemberonly1chip23-Oct-09 15:09 
GeneralRe: Whats wrong with remote desktop? Pinmemberonly1chip23-Oct-09 18:47 
GeneralRe: Whats wrong with remote desktop? PinmvpSacha Barber23-Oct-09 21:58 
GeneralNice but ... PinmemberVertyg011-Feb-07 10:18 
GeneralRe: Nice but ... PinmemberSacha Barber11-Feb-07 23:36 
GeneralRe: Nice but ... Pinmembermmeissa4-Jul-08 15:26 
Generalvery nice PinmemberV. Thieme11-Feb-07 10:02 
GeneralRe: very nice PinmemberSacha Barber11-Feb-07 23:35 
Questionquestion Pinmemberrdsingh694-Dec-06 23:23 
AnswerRe: question PinmemberSacha Barber5-Dec-06 0:03 
GeneralRe: question Pinmemberrdsingh695-Dec-06 19:27 
GeneralRe: question PinmemberSacha Barber5-Dec-06 21:20 
AnswerRe: question PinmemberSyed Mazhar Hasan Qadri7-Feb-07 10:35 
GeneralRe: question Pinmembermmeissa4-Jul-08 15:29 
AnswerRe: question PinmemberKing_kLAx11-Feb-07 8:46 
GeneralRe: question PinmemberSyed Mazhar Hasan Qadri11-Feb-07 20:40 
QuestionQuestion PinmemberMario_F28-Nov-06 7:07 
AnswerRe: Question PinmemberSacha Barber28-Nov-06 7:31 
AnswerRe: Question Pinmembermmeissa4-Jul-08 15:32 
GeneralAwesome PinmemberSteve Hansen27-Nov-06 2:09 
GeneralRe: Awesome PinmemberSacha Barber27-Nov-06 2:57 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Feb 2007
Article Copyright 2006 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid