At first I thought I'd be able to use some 'off the shelf' software to do this, such as Gmote for the Android. However, all sorts of annoying issues arose, mainly stemming from bugs with the fairly old version of VLC available for the Debian/Xandros Etch release modified for the EEE. Nor could I use the http interface for VLC, at least the standard one, because of a serious playlist bug, which I'll mention later. In any case, this interface isn't suitable for a mobile device, with its restricted screen size.
Still, by then I'd become fascinated with the idea and decided to pursue it anyway.
Now, I know I could have installed Windows XP on the machine. But this didn't feel right. Firstly there would be the cost of a copy, unless I felt like being a pirate - and this would bump the cost (free) up rather considerably. Secondly it felt wrong. Linux on this machine runs very nicely and it can be factory reset in just a minute or so. A Linux solution felt much more natural.
The EEE is a reasonably powerful machine, even by modern netbook standards; it uses a Celeron chip underclocked which compares reasonably favourably to the Atom, despite the higher clock speed of the latter, and it certainly can play MP3s without breaking a sweat. And you can pick one up second-hand very cheaply. Since it has a solid-state drive, there's not much to go wrong with it and it seems to be a reliable piece of hardware.
Here is a step-by-step guide to the whole process. It was an interesting exercise, because much of the information on the internet is either plain wrong, contradictory or fragmented. All in all it took me a couple of days but you should be able to do the whole thing in just a couple of hours, or less.
I used a model 701 with a 4G filesystem. Since we are going to use an external hard drive for the main music library, there's no reason this shouldn't work on the 2G model either, and you could probably pick one of these up even cheaper. Incidentally, this exercise doesn't affect the EEE in any way, as regards normal use, so if you still want to use it as a netbook, you can simply unplug it and walk off with it. All the new services run as background tasks and don't affect the operation of the netbook in any way.
These instructions assume you have a main, Windows-based PC, and a home wireless network. However, there's nothing Windows-centric about this exercise and you could just as easily use a Linux PC, or even a Mac, to control the EEE. You also, ideally, need either an iPhone, an iPod Touch or an Android phone to control the media player. The interface is entirely web-based, so you don't have to install any software on these devices.
Of course, being web based, you can control the media player from any PC. But using your phone or iPod is much more impressive.
0. Getting started.
I strongly recommend that the EEE be reset to factory defaults. This is an amazingly quick and simple process, taking only a minute or so. BE SURE to back anything vital up from the machine first.
Press F9 while booting and reset to factory defaults
Note the user name and password that you enter during this process. We will need this information later
Reconfigure wifi and get this working. That's fairly obvious so I won't dwell on the process, it's all GUI driven.
1. Add additional repository for software
We need some software not in the standard 701 repository. Luckily software for Debian Etch works on this machine, so we'll add that repository
Start a terminal window by pressing ctrl+alt+T
Add
deb http://http.us.debian.org/debian/ etch main contrib non-free
to /etc/apt/sources.list
using the command
sudo nano /etc/apt/sources.list
Note: Nano is a simple terminal-based editor. Press ctrl-X to save changes and Y to confirm them. Later on in this exercise we'll install gedit, the Gnome Editor, which works just like Windows notepad, so that future editing tasks will be somewhat less painful. However we can't do that until we've added this repository first.
Now do an update to refresh the local package list
sudo apt-get update
Note: this produced a verification error on a missing public key at the end of the update - I think this can safely be ignored
2. Install VNC so that you don't have to use the tiny keyboard and screen for the remaining processes. Unless you really want to, of course. Otherwise, why not do everything from the comfort of your main PC and keyboard.
sudo apt-get install vncserver
sudo vncserver :1
(the :1, I found, is important, because otherwise VNC starts spawning new instances, often spontaneously. Eventually this brings the EEE to its knees and it stops responding)
Enter an appropriate password. You'll need to enter this every time you connect via the VNC client on your main PC. Making it the same as the password you used for the installation user would probably be a good idea. You only have to do this during the initial install, after that it will remember it.
Assuming you don't have VNC on your main PC, install it now (I used free VNC 4.1.3)
Run the VNC client on the PC and verify that you can connect to the EEE
Now the remaining steps can be carried out using the VNC session on your main screen and keyboard
3. Ensure EEE won't suspend when lid closed
Obviously you want to tuck it on the shelf with the lid closed, so we need it not to shutdown when the lid is closed.
The easiest way is just to move /etc/acpi/lidbtn.sh out of the way. The EEE will then remain powered up when the lid is closed
i.e, from the terminal window
sudo mv /etc/acpi/lidbtn.sh /etc/acpi/lidbtn.sn.sav
Now verify that the EEE stays running when you shut the lid
Note: I found some software that purported to do this (lidman) but couldn't get it to work. This approach has the merit of simplicity and reversibility.
4. Install VLC.
Unfortunately the version compiled for this release of Xandros is a little old (0.8.6a) but it does work. Getting a newer version is non-trivial and involves comments on the net like 'simply compile a new release'. Yeah, on a 4G filesystem, loading all the source and compilers and headers is, like, a great idea. Not!. But this version will suffice for our needs. If some lovely person wants to build an apt-installable package for the latest VLC on Etch, well, you'll be very popular, people will laugh at your jokes, you will grow rich and famous... anyway... pressing on with what we have for now....
sudo apt-get install vlc
Since we're probably using VNC to do all this, you need to allow external hosts to create X-Window sessions, by issuing
sudo xhost +
Otherwise vlc will fail to create its UI over VNC when we run it
Note: this should only be required just the once. From now on in, you won't have to do this.
Then run VLC by typing
vlc
Some suitably cheesy test media files can be found at
/home/user/My Documents/My Music
Unless you're a lover of elevator music, you'll tire of these pretty quickly!. Luckily that big hard drive full of music is waiting to be connected....
Having established that VLC is working, the next step is probably not necessary for most of you, and can be skipped
5. Configure external USB sound device
My home entertainment system is almost out of input ports. Only the optical port is free, so I need a suitable audio device with an optical output. Fortunately (here in the UK), Maplin's sell a very cheap little USB to audio device. It has a single 3.5mm stereo headphone socket which provides a standard line out, plus an optical port. We need to get this working as an audio device. For once, this proved to be quite painless. It really was 'plug and play' under Linux. This is also a useful device under Windows as it doesn't require any drivers to be installed, should you need an optical out.
First plug it in.
Then, go into VLC's settings (Settings/Preferences) and select audio/output modules and then ALSA.
The ALSA device name will probably be 'default'. Drop down the list and select the USB interface from the list. I found afterwards I had to restart VLC. After that, the device should show as hw:1,0 in that list
VLC should now play through the new interface. As I said, you won't need to worry about this unless you don't want to use the built-in audio or need an optical interconnect, as I did.
6. Connect external hard drive with music repository
Obviously the EEE's internal 4G filesystem is far too small for any reasonable music library, so a USB external hard drive is needed. Assuming it was originally formatted as an NTFS drive, you may prefer to keep it that way (I did), since then you can obviously plug it back into a Windows PC and easily copy files onto it. We're going to set things up so that you can, of course, move new music onto the drive via the network, since at some point soon all this kit will be tucked away on a shelf as part of the home entertainment system.
I used an 80G, 7200rpm drive. Nothing fancy, just happened to be something I already had. It should comfortably store at least 1,000 CDs, and I don't own that many. If your music collection is truly awesome, you may want to consider a larger drive.
Unfortunately keeping the drive NTFS exposes a few complications. While the EEE can expose its filesystems as Samba shares, performance accessing these seems to be very poor from Windows explorer, and the whole experience of trying to copy information across got very flakey. I resorted instead to good old FTP for the job, which seems to work reliably. Well, once I found the right FTP server. See later.
Anyway, at this stage, just verify the drive mounts and that you can browse it and VLC will play media from it. It should appear under your home directory (/home/user).
Note: you could of course use an SDHC card in the card slot. However, an external drive provides a much larger amount of storage for hugely lower costs - 1 terabyte drives are now very reasonably priced and would store tens of thousands of CDs. Let's see, 10,000 CDs at approximately 1 hr each would take over a year at 24 hours a day, 7 days a week, to play. That should do it!
7. Configure an FTP connection
FTP is probably the easiest way to get stuff onto the main hard drive from other PCs on the home network. It's possible to mount the drive as a windows share, but performance isn't as good.
First we need to pick the right FTP server for the job. There are several to choose from, the big three, as far as I could tell being vsftp, proftp and pure-ftp. I have also used ncftp in the past, but didn't get to it this time.
There are issues with vsftp and proftp that aren't worth fighting to resolve, in my opinion - in the case of vsftp,paranoid 'out of the box' security settings that make life impossible and which are extremely hard to bypass. Great for Megacorp's online ftp repository, not so great for us. Proftp didn't fair much better. It's picky about its config file, didn't seem to be able to browse the external NTFS disk, and will fail to start under unpredictable circumstances when you make config changes. Not good. Pure-ftp works very well, however, and requires absolutely no configuration.
For the main PC ftp client, FileZilla is the one you want. It's free and has a well-designed GUI. FileZilla has an FTP server as well, for Linux, but not, as far as I know, for the rather old version of Debian that the EEE runs, which is why I used pure-ftp. Otherwise if you want an 'end-to-end' FTP solution e.g between Windows machines, Filezilla is an excellent solution.
Install FileZilla on your main PC and verify that the GUI launches.
Now, on the EEE, install pure-ftp
sudo apt-get install pure-ftpd
Now, we'll launch it, and attempt to connect to it
sudo pure-ftpd -B
This flag launches pure-ftpd in the background
(note: we're going to set things up at the end so the ftp server, the vnc server and vlc all start automatically).
From the FileZilla client, specify the hostname or IP address of the EEE, and logon as 'user' (literally 'user', not the user that you defined when resetting the EEE earlier), and with the password that you set up for the standard user when the EEE was reset to its factory default settings.
You should successfully connect. Your FTP home directory will be /home/user on the EEE and you should see the external hard drive underneath this tree and be able to browse it.
8. Connect to VLC using the default HTTP interface
run vlc with
vlc -I http
(that's a capital I, just to be sure)
Then, using your browser, connect to the EEE either by its server name - which will be eeepc-
i.e
http://eeepc-joe:8080
or
http://192.168.1.4:8080
assuming that it has that ip address. If you have trouble accessing it by name and are not sure what IP address it has, you can find this out by going into the wifi details on the EEE, which should show you the currently allocated IP. If you want to access it by IP permanently, it might be worth changing the wireless settings to set up a fixed IP address. This is pretty obvious and very similar to how you do it under Windows, so I won't discuss it further here.
You should see the default VLC HTTP interface in all its glory. (this is actually the file index.html in the /usr/share/vlc/http directory)
NOW STOP HERE... DON'T TOUCH THAT DIAL!
Tempting though it might be to play with the default VLC browser interface, DON'T. This is because the version of VLC we are using has a bug with the playlist clear command which will lock up VLC. The new interface we're going to use in a minute works around this problem by clearing the playlist one entry at a time in a loop. (I found all this out the hard way, it's not documented, as far as I can determine).
9. Copy the new HTML interface over
Download the HTML document from the link at the end of this post. Save it as something, e.g, play.htm
Now use filezilla to transfer it to the EEE, to the /home/user directory. Permissions will be a problem regarding getting it to its final resting place, we'll do that in a minute with VNC and a terminal window
Note: you could also transfer this file by any number of other obvious ways, putting it on a USB stick, unplugging the external music hard drive and putting it on your PC and copying it, or even extracting it by surfing directly on EEE and extracting the HTML
Note: a proper text editor would be handy for this. Why not stop for a moment and install the Gnome Editor (gedit). This works pretty much like Windows Notepad and is somewhat less of a pain than terminal-based editors like nano, (which comes installed on the EEE already)
sudo apt-get install gedit
then to test it, just run
gedit
Now in a terminal window, copy the file (assuming it was called play.htm)
sudo cp /home/user/play.htm /usr/share/vlc/http/play.htm
We need to stop and restart VLC in order for it to pick up the new file's existence. (however, we can make changes to this file later without having to restart VLC)
to stop VLC, either just restart the EEE, or type
ps -ef | grep vlc
the | is a vertical bar, or pipe symbol, which is usually the shifted backslash (\) on a standard PC keyboard.
Ok, now you'll see, probably, two lines with VLC on them (plus the grep command). Note the leftmost number on the first line. This is the process ID (PID) for VLC.
Now type
kill -15
where
kill -15 17449
Then repeat
ps -ef|grep vlc
You should now see that VLC isn't running any more
Now restart it with
vlc -I http
and then, in your browser, type in (assuming, as before, that your machine is called eeepc-joe)
http://eeepc-joe:8080/play.htm
and you should see the new interface. Note that under Firefox, the buttons will look rather small; this is because unlike Internet Explorer or the Webkit-based browsers used in most mobile phones and the iPod Touch, the cascading style sheet 'zoom' attribute is not supported; these buttons will appear larger on those devices, for which this interface was designed.
You can now have a play and determine that all is working well. Click on a directory to browse into it and click on the .. line to go back up a directory. When you get to some music files, click on any file to add it to the playlist. If it is the first file to be added, it should start playing immediately. As you click other files they are added to the playlist without disturbing the currently-playing file. As you can see, entries change colour when they are added to the playlist (blue) and the currently-playing file is shown in green. Note that this is NOT updated in real-time, you need to refresh the page. This is because to get a real-time update, a lot of information needs to be requested from VLC each time. I need to create a special XML file which doesn't come with VLC - I'm looking at that.
The + icon will add all the current directory entries to the playlist. The playlist icon toggles you between playlist view and browse view. Finally, you can clear all playlist entries. You will be asked to confirm this operation.
10. Trying it from your mobile device.
Using an Android phone or an iPhone or iPod touch, simply browse to the above page. It's as simple as that, no software to install!.
11. Getting everything started automatically
Now we need to configure the EEE so all the services automatically start up at reboot time. For this I am indebted to the instructions at
http://wiki.eeeuser.com/howto:startupscript
Before proceeding, it would be wise to check the wireless connection settings. You need to be sure that the EEE will reconnect to the home Wifi access point on reboot. To ensure this is so, click on the wifi icon in the system tray - oddly, the one WITHOUT the setup spanner - and select the active connection. Then, in the properties dialogue, ensure that the start mode is set to 'on boot'.
First we need to create our startup script. To do this, go to the /home/user directory and execute the following commands
sudo mkdir .icewm
sudo chmod 755 .icewm
cd .icewm
sudo gedit startup
and enter the following
#! /bin/sh
sleep 16
sudo pure-ftpd -B
sleep 5
sudo vncserver :1
sleep 5
sudo vlc -I http
save this file
then
sudo chmod 755 startup
Now we need to add this file to the simple mode startup script
cd /usr/bin
sudo cp startsimple.sh startsimple.sh.orig
sudo gedit startsimple.sh
Locate the comment
# we are switching from full to easy mode
go down to the line about 3 down from this that reads
fi
AFTER that line, add the following
# Media startup
if [ -x /home/user/.icewm/startup ]; then
/home/user/.icewm/startup &
fi
# end Media startup
CAUTION: This step has the potential to cause you great grief if you get it wrong.
Fortunately if you do, and for some reason cannot restart the EEE,the instructions at
http://wiki.eeeuser.com/howto:installrescuemode
should allow you to recover from the situation. Since you made a backup copy of the original startup script, you can easily restore it via the recovery
console and then have another go. But let's not be pessimistic....
Now restart the EEE. All being well, you should find that VLC, VNC and pure-ftpd are all restarted at boot time, and that wireless mode is re-established.
After confirming all these services still work, you're ready to go live. Or are you?....
11a. A world of hurt and pain....
For the impatient: you probably should at this point install the updates from the Settings tab in Add/Remove programs before continuing. Then skip to step 12. For more detail on what went wrong, read this section.
As with almost all software and hardware projects, this is the point where things are most likely to go wrong. All seems well, so you decide to go live. Then.... well, it all goes pear-shaped, as we say in the UK.
Sure enough, after about an hour of flawless playback, while I was copying some files down from the upstairs PC, the EEE crashed. It locked up so solidly that only holding down the power button for 10 seconds would reset it. And then, during boot, it locked up to a black screen again. After cycling power for the second time, it booted.
At this point I recalled my partner telling me that this had happened to her during a presentation. This was one of the reasons the EEE got replaced by my old laptop, an IBM T40. (another was that she needed more raw power, to show audiovisual presentations).
At the time I'd discovered a known issue reported against Open Office for lockups, applied the patch available from the EEE's software updates and thought no more of it. But this looked serious. It looked, in fact, like a hardware problem.
But optimism always prevails in these situations. Perhaps it was a one-off, a glitch. I set it back up and continued copying files down. It ran perfectly. I left it idle and went out for a couple of hours, came back and found it locked up again.
In these situations the first thing is to try and establish if we have a software or a hardware issue. In this case, it sure looked like a hardware issue and my suspicion was that it was temperature-related. Rule 1 is to start with memory tests, so I dug out an external USB optical drive and plunked a copy of Ubuntu 9.10 in there, and booted the EEE to run memtest86 for a while.
This found no issues. Hmmmm....
Perhaps a BIOS update would be a good idea. There have been several updates since the machine was built, and the EEE has the easiest BIOS update functionality I've ever seen, just pick the BIOS from the Add/Remove software updates listing and it's applied automatically. So I did this. But the problem wasn't fixed.
The next step was to try stressing the CPU. That should provoke any thermally-related issues. This was easily done by writing a one-line Perl program that looped endlessly (perl is included in the standard Xandros distribution on the EEE).
To monitor things, I installed gkrellm (sudo apt-get install gkrellm) and enabled the on-board temperature sensor (sudo modprobe thermal). It reported a CPU temperature hovering around 50 degrees, which seemed about right, at 100% CPU utilisation.
Just to really hammer the machine, I also did a cat from the main hard drive to /dev/null, which would read tens of gigabytes from the drive and stress the I/O subsystem nicely.
But this, too, ran flawlessly. This cast doubt on the hardware theory. Could it be software?. I hadn't bothered to install the upgrades after resetting the EEE to factory defaults
So, visiting the Add/Remove software utility again, and going to the 'settings' tab, I applied all the updates. I didn't bother with the security fixes, but applied all the other updates, most notably the 1.0.5 desktop update. I didn't apply updates to any other categories, figuring that since we aren't using that software, there's not much point.
After this, I noticed firstly that the media drive had been renamed and now appeared in the directory tree as 'D:'. Everything appeared to work
I wanted to share the drive and see how Windows managed it, but found that the default name, D: was not acceptable. Fair enough, so I renamed it to HardDrive under File Manager and then shared it. Windows Explorer seemed to work ok, and the terrible browse performance seemed to be fixed. I tried copying some music across and it worked, although considerably more slowly than FTP, taking nearly 5 minutes to copy a single CD. Still, this was encouraging.
After a day of solid running, it looks like the lockup problems have been vanquished.
Note: There is one small quirk now. When I connect via VNC I don't see the EEE desktop, just a checkered background. I can still invoke terminal sessions with ctrl+alt+T so this is only really a minor nuisance, and at some point I might investigate further. After all, in the worst case, all I have to do is grab the EEE off the shelf, open it up and do whatever I have to do directly on the machine.
Note also: you need to run
sudo xhost +
after the updates to re-allow VLC to run when invoked from a VNC session.
12. Modifying the user interface
The HTML is designed to be reasonably easy to change. CSS styles are used to manage the visual appearance so you could easily modify the look and feel.
VLC supports other functionality I didn't feel was essential for a media player. Volume I can control from the main stereo remote control, so I preferred not to introduce confusion by adding a volume slider to the HTML UI. In addition, VLC allows you to control track position externally. Again, this isn't something you normally do when listening to music, so I skipped it.
VLC is a tremendously powerful media player. Unfortunately, as with many open source projects, the documentation is somewhat less than comprehensive and coherent.
We are exploiting VLC's HTTP interface here. What may not be immediately apparent is that the XML and HTML files it returns can be extensively customised and new files created. This would be handy - if time permits it would be useful to add a new XML file that just returns the ID of the currently playing playlist entry. Then the HTML UI could periodically request it, allowing the display to update in real time. Although we could request the full playlist to determine the currently-playing song, this would request a lot of information, especially with a large playlist, and I was concerned this might introduce dropouts, so I haven't implemented it.
VLC has a powerful macro facility to allow these files to return all sorts of information. The learning curve looks rather steep, but I'm sure its doable.
13. What about a Windows server?
Could this be done with a Windows server instead of the EEE?. Well, I had a quick look and discovered that there seems to be a problem with the XML returned by both the browse and playlist functions. The backslashes which separate out the path components aren't being returned. Ideally, I think on both platforms the XML should return identical results i.e use forward slashes. I'm looking into it....
14. Accessing the music library from another computer
It's possible to set up VLC to stream across the network, but the simplest way is just to open the shared media drive across the network. This seems to work well without glitches here, even with two PCs independently streaming audio while the main stereo is also playing something else. I measured CPU usage hovering around 11-15% on the EEE under these circumstances.
15. Adding new music
To be honest, the easiest way is just to pop CDs into iTunes, on whatever machine you're sitting at, having set it to automatically import CDs. Then with a FileZilla window open as well, each time iTunes completes a CD, just drag and drop it over to the media drive on the EEE. Of course, iTunes is sometimes rather wilful about how it categorises CDs, often preferring to do so by artist rather than composer, for classical music, but again FileZilla makes it painless to rename things or move files around on either the local machine or the EEE.
16. Finding stuff
With hundreds or thousands of CDs, the basic UI for the HTML interface starts to involve a lot of scrolling to find stuff. One easy way round this is to add folders for each letter of the alphabet and then drag and drop stuff so that your directory structure looks like this
music
...A
......Abba
......Air
...B
......Bloodhound Gang
......Blur
etc
(names chosen randomly and not to reflect musical taste in any way!).
However I'm looking at adding search functionality to the UI, once I've figured out the best way to make it work. Watch this space....
Appendix. The HTML for the user interface.
Note the line after the //change this... comment
You can change the root point at which browsing starts by changing this line. This is probably a good idea, to get you straight into an album list.
Of course, you could also create copies of this page with different root points. This would let you immediately go to a particular point in the directory tree of your music disk, and set up bookmarks in the browser for each one.
Download the HTML file from Google Docs
Nice post
ReplyDeleteThanks for posting this informative article in fact I'm looking mens trousers for my dad in this coming fathers day.
ReplyDelete