How To Sync Your XBMC Media Centres

Wouldn't it be nice if you could pause or stop your media centre in the living room, head into the bedroom and pick up exactly where you left off without skipping a beat? You can with XBMC, and here's how it works.

We've shown you how to clean up your media, customise your install and emulate games in pursuit of making XBMC the ultimate media centre. Today we're going to show you how to synchronise all the XBMC consoles in your house.

XBMC is a fantastic open-source media centre application for Windows, Mac, Linux and (at least the old) Apple TV. If this is your first time hearing about XBMC, you really should check out our start-to-finish guide to setting up XBMC to see what XBMC is really capable of.

If you have more than one XBMC installation in your house — we're currently rocking five installations in this media centre-happy home — you might have noticed one seemingly small but annoying flaw in XBMC. If you paused, stopped or bookmarked a television show or movie in the living room and then went to resume watching it in the bedroom, the remote instance of XBMC had no idea where you left off. Bookmarks and resume points are stored on each local XBMC installation, as are any changes or annotations you make to your library. We're going to take care of that annoyance today with a little database wizardry. When we're done, you'll be able to pause Scarface in the living room and unpause it in the bedroom, and your network of XBMC centres will keep everything in sync.

Getting Started with XBMC Syncing

You're going to need a couple things to make this synchronisation magic happen. The foremost is multiple copies of XBMC running a current release — if you only have one XBMC install, you don't need to worry about all this syncing jazz. To enable synchronisation via a central database, you must be using SVN version R28117 or above. Check your release number in the System Info menu of XBMC if you're unsure which version you have. If you have a pre-R28117 release, the easiest way to upgrade — and enjoy some sweet new features in the process — is to grab a current release here.

The other component you'll need to bind all your XBMC installs together is a MySQL database. If you've never worked with databases or MySQL before, that might sound like a frightening proposition, but I assure you it's not. This is the first time I've ever played with MySQL, and despite a few hiccups with syntax (my fault) when I first set everything up, it was a breeze. Download a free copy for your OS of choice here. Stick with the Essentials package. Although our setup instructions below focus on Windows, the MySQL commands transfer across operating systems, so Linux and Mac users can easily follow along.

Once you've ensured your XBMC installations are up to date and you've grabbed a copy of MySQL, it's time to get started setting up your database.

Step One: Install and Configure MySQL

Where you choose to install MySQL is critical to the success of your synchronisation efforts. Whether you install it on a Windows, Mac or Linux machine is not as important as installing it on a machine that's running most often. I installed it on my home server, which runs 24/7.

Run the MySQL installer. When prompted to select a configuration type, choose "Standard Configuration". If you're a web developer or MySQL wiz, you've possibly already got it installed and configured; if you're new to MySQL — like I was — the standard installation is just fine for the simple media database we'll be creating. Enter a password for your database when you're prompted to do so and specify that you want your database to have network access. Leave the default port of 3306 alone — if you change it here, you'll just have to change it in the files we'll be working with in a few minutes. After the installation is complete, pull up the MySQL Command Line Client — look in the MySQL start menu entry for it — and run it. It will prompt you for your password and then dump you into a console that looks like the screenshot below.

Now it's time to create a user, some databases and assign our new user some privileges. First we'll be creating a user account for all of our XBMC installations. They'll be sharing the same login. At the commend prompt type in:

CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';

You've just created the login/password pair xbmc/xbmc. Since this database is just for a media centre and just for use on a private network, we're not going to concern ourselves with heavy security. You can, of course, go more secure if you like.

After you've created your user account, it's time to create some databases for XBMC. Type the following:

CREATE database xbmc_video; CREATE database xbmc_music;

Now we have user "xbmc" and two databases. XBMC requires a separate database for the video library and the music library.

Finally, we need to give our user access to the databases. Again, since we're not concerned with securing confidential records or the like, we'll take the easy way out here to minimise the amount of typing and fussing we need to do. Type the following command at the prompt:

GRANT ALL ON *.* TO 'xbmc';

Now user "xbmc" has access to all our databases. To confirm that everything's in order so far, fire off the following commands:

SELECT host,user from mysql.user; SHOW DATABASES;

If everything is in ship shape, you'll see results like those in the screenshot above. Now all that's left to do is tell XBMC how to access the database and start sharing information through it.

Step Two: Configure XBMC to Use Your New Database

As with any software-based tinkering, we recommend backing up before proceeding, so let's do that first.

Under the Settings menu in Video and Music, you'll find an Export Library button. Export the video and music library for safe keeping. We'll be importing them shortly.

Once you've exported your libraries, open up your favourite text editor and copy the following text into a new file:

<advancedsettings> <videodatabase> <type>mysql</type> <host>***.***.***.***</host> <port>3306</port> <user>xbmc</user> <pass>xbmc</pass> <name>xbmc_video</name> </videodatabase>

<musicdatabase> <type>mysql</type> <host>***.***.***.***</host> <port>3306</port> <user>xbmc</user> <pass>xbmc</pass> <name>xbmc_music</name> </musicdatabase> </advancedsettings>

Replace ***.***.***.*** with the IP address of the computer on your network that is hosting the MySQL database. If you altered the MySQL server port during the installation, make sure you change it. (If you didn't, the default was 3306.) In Windows, save this file as advancedsettings.xml in the %APPDATA%XBMCuserdata — just copy and paste that text into the Explorer address bar or the Run box. (On Linux, the path should look something like ~/.xbmc/userdata; on OS X, something like ~/Library/Application Support/XBMC/userdata.

Once you've copied the file to every XBMC installation on your network, start one of them up and import the music and video libraries you exported. This freshly imported — or freshly scanned, if you're starting from scratch — library will populate the database on your primary machine/server. From here on out your XBMC viewing habits will sync between machines and you'll be able to resume playback, access bookmarks and see what media you've already viewed from anywhere in your house. The first screenshot below is taken from the XBMC centre in one room, and the second was taken in another room; both XBMC installs feed from the central database.

Note how the second XBMC install knows that we already watched the first episode and that we paused the second one 45 seconds into the show. In addition to remembering which shows we've watched and where we left off, the database also remembers things like subtitle settings, if we've zoomed the screen in, video modes and more. If you're curious to see everything currently shared by the XBMC database, you can check out this developer's thread, complete with charts, that highlight all the variables that'll sync between installations.

One current shortcoming with the database system — although rumoured to be in the pipe for future releases — is that thumbnails and fan art are cached locally and not stored with the database. While creative users in the XBMC forums have come up with solutions to work around this, like using symbolic links and moving your thumbnail cache, there is a much easier solution. We'd strongly recommend you go check out our guide to whipping your movie and TV show art into shape for XBMC. The method we outline in the guide results in all your thumbnails, movie posters, fan art and more being stored with your media. It's the best way to do it, and it makes reinstalling XBMC or adding a new install to your network a breeze, since the "scraping" it does is from the local network and not a distant server. If you combine local artwork storage with a MySQL media database, you'll have the fastest home media network around.

Have a favourite XBMC tip, trick or add-on to share? Let's hear about it in the comments. We love a good media centre, especially a powerful and open-source one, and we always love to hear about new ways to make them better.


Comments

    Erm, "GRANT ALL ON *.* TO 'xbmc';"? No.

    Interesting. Thanks for this.

    Just one question... Can this work on PostgreSQL?

    Thanks

    Thanks very much for the guide. After installing MySQL on a WHS machine, I've managed to get this to work for XBMC running on Vista, Win7, Mac OSX & Ubuntu. I've only setup XBMC for Movies and TV shows, so I haven't tried music yet. But there are few things that I ran into which might be worth sharing.

    Your guide didn't cover XBMC Live CD which I used to install an a dedicated PC. My experience with Linux is pretty basic, so no doubt there's probably easier ways of doing it, but I was able to get it to work. When you exit XBMC it unloads the desktop and takes you to the command line. From there change the directory to ~/.xbmc/userdata and use vi (to avoid permissions issues, I prefixed the command line with sudo) to create/edit advancedsettings.xml (in my case XBMC had already created the file with settings specific to my graphics card). What I would love to try next is to see if I can get this to work on an Apple TV.

    An important thing to note is that the advancedsettings.xml file only partially populates the library, unless you add the sources under videos and specify the same paths as that on the original machine, you won't be able to playback any of the files (XBMC will report that it cannot find the file and prompt you to remove the entry from the library).

    I have my artwork and metadata stored with my media so I had no artwork issues with TV/Movies fanart or TV episode thumbnails on machines which did not originally create the library. However these machines exhibited a peculiar artwork issue with the Movie/TV thumbnail (i.e. the portrait image which links to folder.jpg). Movies displays the wrong image (a squashed version of fanart.jpg), I found by right clicking and selecting movie information and then backspace proved to be sufficient enough for XBMC to relink to the correct thumbnail. The issue with TV is that no thumbnail is displayed, even though right clicking and bringing up TV information shows that it is pointing to the right image. To resolve this I had to click on the get thumb option and switch from current to local thumb (even though they are both identical!). However doing this for each an every entry is going to take forever, so I'm still trying to find a better solution.

    Curiosity got the better of me, and I bought a 1st generation AppleTV from eBay. After hacking it to install XBMC from a patchstick, I can confirm that sync works on that version as well. But getting it setup wasn't as straightforward.

    Although I was able to connect to the ATV, I wasn't able to edit the file for some reason. To make my life easy I used CyberDuck to connect using SFTP protocol to appletv.local as frontrow (password is also frontrow). These values are the default details when you install via the patchstick. Once connected you need to navigate to Library/Application Support/XBMC/userdata/ to find advancedsettings.xml already there. You can edit the file by right clicking. You'll have to re-jig what's already in there, and then insert your mysql entries.

    As mentioned in my previous comment, you'll have to specify the paths of your sources. And just like before, the folder thumbnails aren't correct (still looking into a solution to that). Other that that, everything else works as expected. Perusing the media library on XBMC for AppleTV is quite sluggish, even on a wired network, and synching might make this worse. Given the limited amount of RAM, this is to be expected, I've found that certains skins/views are more resource hungry than others. The alternative is to run your AppleTV without it's Mac OS, and use a minimal installation of ubuntu infused with XBMC. But that's a subject for another time.

    Although XBMC is now available for ATV 2nd generation (black puck). XBMC on this platform is in it's infancy and there are a few key features missing. HDMI audio is limited to stereo (5.1 works over optical), despite being able to decode 1080p it can only output up to 720p, codecs are software decoded save for h264, and it can't playback DVD/BluRay ISO. But then XBMC for this platform has only been out a few weeks, so who knows.

    Please note, if you follow these instructions you will get errors from recentlyadded.py within xbmc.

    Please use the following to create the tables:-

    CREATE DATABASE xbmc_music CHARACTER SET latin1 COLLATE latin1_general_ci;
    CREATE DATABASE xbmc_video CHARACTER SET latin1 COLLATE latin1_general_ci;

    Having followed these instructions initially and it sort of works, but then xbmc would show an error every time it started until I rebuilt my database with these settings.

    Could the author of the article maybe update it to reflect this please!!

      Hi :)

      Even with those changes, I cannot save show states, so these instructions are not helping me :(

    Should this also sync the library? I can see files and they update, but the library on my second install is empty (library mode is greyed out).

    Ok, this is my 3rd attempt to make it work. I put my library on external drive, mapped on both computers as I:\

    Installed mysql, created user, verified, created databases and so on. Now: both machines correctly GET library from server and I'm able to play files accordingly on both machines.

    But bookmarking/syncing/deleting/adding new content does not work the way its supposed to.
    I cannot 'remove movie from library' - I click, then do clean database, still there, on both machines. I've been trying to make changes to titles and so on, still no luck with edit and then sync.

    Any idea whats wrong with this? I followed latin1 guideline, did not help. About to give up on this idea. I have done php&mysql projects before for uni but this simply does not work for me, may it be XBMC problem?

    if you are using windows vista and up you can use MKLINK.

    mklink /D "C:\Users\\AppData\Roaming\XBMC\userdata\Thumbnails" "<DIR To thumbnails"
    (for extra help http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/)

    for me it was mklink /D "C:\Users\\AppData\Roaming\XBMC\userdata\Thumbnails" "T:\Thumbnails\"
    T:\ is in my case a network dir.
    (make sure you data base is baset on smb share)

Join the discussion!

Trending Stories Right Now