XBMC is an awesome media center solution but when you’re using it all over your house your library updates and watched-media lists get out of sync. Read on as we show how to keep all your media centers on the same page.
Why Should I Care and Who Is This Guide For?
XBMC has a built-in library system and it keeps track of media you’ve already watched. Unfortunately these things happen, in the default configuration, at the local level. If you have an XBMC unit in your living room and in your bedroom those two installations of XBMC don’t talk to each other. As a result if you watch some of your TV shows in the living room and some in the bedroom then the marked-as-watched function in XBMC will only show you what you watched on that specific television set. The pause/resume and bookmark functions are also local. If you pause a movie or set a bookmark to hold your place there is no way to access those things unless you’re sitting at the same media center you created them with.
Wouldn’t it be nice if you could stop watching a movie in the living room and resume watching it in the proper location somewhere else in the house? Wouldn’t it be awesome to not have to sit there and wait for each library to update but instead to have it load the library from a central location ensuring all your media is up to date and in sync? It sure would be pretty awesome and we’re going to show you how to do it with free tools.
Before we get to that, however, let’s clear up who will benefit from this the most and who can skip over it.
You should skip this project if…
- You only have one installation of XBMC in your house.
- You store your media on a local HDD attached to your XBMC installations and do not share that media across the network.
- You do not have an always-on (or nearly always on) desktop, HTPC, or server.
- You are running XBMC on the original Xbox hardware—only modern HTPC-based versions of XBMC are compatible with this technique.
You should take advantage of this project if…
- You have multiple installations of XBMC in your house.
- You store your media in a central location like a file server, always-on desktop, or a primary media center.
- You have a computer, such as the aforementioned media server, that is on whenever you’re watching media.
How Does It Work and What Do I Need?
The core of the synchronization magic we’re about to undertake is a MySQL database. Don’t panic if you’ve never used one before! While some of the HTG staff are old database pros I will confess to using MySQL for one thing and one thing alone—managing my media collection.
Follow along closely and you should have no problems. What we’re going to do is install a free version of MySQL database, create a database just for XBMC, and then instruct XBMC to start writing and reading all its library entries to the database. From that point forward when XBMC checks to see if you’ve seen a specific TV show episode or movie, paused media, or set a bookmark, it won’t just be answering for the specific media center you’re standing in front of but whether you’ve done those things anywhere in the house.
So what do you need for this project? You’ll need the following:
- More than one media center with XBMC installed (version 10.0 or above)
- A free copy of MySQL Community Server (version 5.5 as of this tutorial)
- An always on or nearly always on machine to run the MySQL server on.
You can install the MySQL server on any computer that will be consistently on while you’re using the media centers. In our case we’re going to install it directly to the media server itself as this means that anytime the media is available to our XBMC clients the database is too.
Installing and Configuring MySQL for XBMC
For this tutorial we will be installing MySQL on a media server running Windows Home Server. Our installation instructions should match for any version of Windows. For other operating systems please consult the MySQL 5.5 Manual.
The installation of MySQL is straight forward. Simply download the server installation app and run it. Accept the license agreement and, once it finishes installing, make sure “Launch the MySQL Instance Configuration Wizard” is checked before clicking Finish.
The MySQL configuration wizard will launch and present you with the option to select between Detailed and Standard Configuration. Select Standard Configuration and click Next.
On the next screen check Install As Windows Service, name it MySQL—or, if you’re running multiple MySQL servers for some purpose, give it a unique name—and check Launch the MySQL Server Automatically to ensure the MySQL server is always on when you need it.
On the next screen check Modify Security Settings, plug in a new root password, and check Enable root access from remote machines. Click through to the final screen and then click Execute to modify the database. Click finish to close the configuration wizard.
Now it’s time to create databases on the MySQL server for your media center. There’s one important note before we continue; XBMC does not store profile data in the library database and each profile has its own library. What this means in terms of this tutorial is that you need to create a MySQL database set for each specific profile you use. For example:
- If you use a single profile on each XBMC and/or are only concerned with syncing one library: Create one database set and use it for the single profile on every instance of XBMC. If every machine in your house automatically logs in or you enter the password for a single account, this is for you.
- If you use multiple profiles (one for you and one of your kids, for example): Create a database set for each profile you wish to sync across the network. If you
That said let’s get started creating the first profile (which will be your only if you’re a single profile user). Run the MySQL console; you should have an entry for it in your Start Menu if not look in the fire up the command prompt and paste in:
C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe” “–defaults-file=C:\Program Files\MySQL\MySQL Server 5.5\my.ini” “-uroot” “-p”
When the console opens enter the password you created in the previous step. You’ll then find yourself at the MySQL server prompt. Here’s where we roll up our sleeves and get busy creating users on the database servers and the actual databases. We’re going to create a pair of databases for each profile you want to synchronize—one for the video library and one for the music library. We’re going to start by creating a primary user and database set (which is as far as you’ll need to go if you’re a single profile user).
At the prompt type the following to create a user on the database server:
CREATE USER ‘xbmc’ IDENTIFIED BY ‘xbmc’;
The first quoted portion is the username and the second quoted portion is the password. While identical login/passwords are generally a huge security no-no in this case we’re comfortable using a matching pair for the sake of simplicity. A MySQL database, on a private server, that tracks which episodes of Dexter you’ve watched is hardly a high risk installation.
CREATE database xbmc_video CHARACTER SET latin1 COLLATE latin1_general_ci;
CREATE database xbmc_music CHARACTER SET latin1 COLLATE latin1_general_ci;The above command set creates two new databases: one for the video library and one for the music library. We also indicated what character set we want the databases to use—latin1 is necessary for XBMC to properly write to the databases. If you make a mistake and need to remove a database simply use the command “DROP DATABASE databasename;”—sans the quotation marks.
GRANT ALL ON xbmc_video.* TO ‘xbmc’;
GRANT ALL ON xbmc_music.* TO ‘xbmc’;In this step we’re granting the user ‘xbmc’ full access to both databases.
If you rely on XBMC for playback of your music collection there are a few additional tweaks you’ll want to make to the music database to improve performance.
ALTER TABLE xbmc_music.song ADD INDEX idx_idArtist(idArtist);
ALTER TABLE xbmc_music.song ADD INDEX idx_idGenre(idGenre);
ALTER TABLE xbmc_music.song ADD INDEX idx_idAlbum(idAlbum);The above edits are only necessary if you want to speed up access for certain functions while using XBMC as a music player.
If you’re a single-profile household then you’re all done. If you need an additional profile for your roommate, kid, or other individual, simply repeat the above steps substituting all instances of xbmc with an appropriate alternative like roommate or kids to create databases for each entity.
Before we leave this step, let’s double check that the users and databases we created are in fact within the MySQL server. Type the following commands:
SELECT host,user from mysql.user;
SHOW DATABASES;
You should see something like the screenshot above, adjusted for the number of users and new databases you created. Single-profile users should see the user ‘xbmc’ and the matching music and video databases. If everything looks good, we have one final step before going to configure XBMC: Make sure that Port 3306 (the MySQL server port) is open on the firewall of the machine you’ve installed MySQL onto. By default the Windows installer should open the port automatically but you’re going to save yourself a headache later on by double checking that now.
Configuring XBMC to Communicate with the MySQL Database
By default XBMC uses an internal SQLite database. In order for XBMC to communicate effectively across your home network we need to instruct it to use an external MySQL database. Before we get to that step, however, you’ll need to make an executive decision regarding whether or not you’re going to scrap your library and start fresh or backup and restore it.
If this is a brand new installation of XBMC and you’re configuring everything fresh you can simply skip to the next step. If you wish to save your existing library data you will need to export your library. From within your XBMC installation You’ll need to go to System –> Settings –> Video and System –> Settings –> Video and, at the bottom of the menu, select Export to export your library file. You should only export the library files from one machine on your network. Pick the machine with the most up to date libraries. When you are done configuring XBMC to accept the MySQL databases you will then repeat the above steps and choose to Import the libraries. Everyone else will just run a new scan on their media directories to repopulate the library.
Once you’ve backed up the library (or opted to not worry about it and start from scratch) you’re ready to start configuring. The specific file we’re interested in the the advancedsettings.xml. By default this file does not exist (although it is possible that, during the installation process, XBMC created one for you to deal with specific configuration issues). If the advancedsettings.xml file exists it will be in the following location, based on your OS:
Windows XP – C:\Documents and Settings\[username]\Application Data\XBMC\
Windows 7/Vista – C:\Users\[username]\AppData\Roaming\XBMC\
Linux/XBMC Live – $HOME/.xbmc/userdata
Mac OS X – /Users/[username]/Library/Application Support/XBMC/userdataCheck in that folder. Is there an advancedsettings.xml file there? Yes? Open it up. No? You’ll need to open a text editor and create one. Regardless of whether you’re editing the existing one or create a new one, cut and paste the following text into the file (note: if there is already some entries in your advancedsettings.xml file, leave those in place!):
<advancedsettings>
<videodatabase>
<type>mysql</type>
<host>192.168.1.120</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_video</name>
</videodatabase><musicdatabase>
<type>mysql</type>
<host>192.168.1.120</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_music</name>
</musicdatabase>
</advancedsettings>Edit the above text to reflect the IP address of your server on your LAN and the username/password of your MySQL database.
If you are using multiple profiles you need to create a unique advancedsettings.xml file for each profile. Edit advancedsettings.xml file separately and then place it in the /profiles/[profile name]/ folder—a subdirectory of the folder noted for your OS in the step above. The master profile’s advancedsettings.xml file goes in the root folder, the other profiles all go in /profiles/[profile name]/. Again, you must have a unique file for each profile.
Once you have created the file and placed it in the proper directory, it’s time to reboot your XBMC for the new file to load. Once you reboot, you’ll need to either import your library or rescan your sources to begin populating the MySQL database. Do that now.
When your libraries are imported and/or done scanning, you can do a simple check to see if XBMC is properly communicating with the database. Return to the MySQL command prompt and, to check on whether or not your movies and television shows are in the database, type the following commands:
SELECT COUNT(*) from xbmc_video.movie;
SELECT COUNT(*) from xbmc_video.tvshow;
Each query will return the total number of movies and television shows, respectively, contained in your library (according to the the MySQL database). See the screenshot above for an example of a query into the TV show count. If the number of entries is zero there is a problem somewhere along the line. Here’s is a quick trouble shooting checklist of common mistakes:
- Did you double check that a unique user and database pair were created for each profile?
- Did you use the GRANT ALL command to apply the proper permissions for each user and their database?
- Did you set the CHARACTER/COLLATION settings to Latin1 for all the databases?
- Are all your shares defined as Samba shares (//somehost/sharefolder) and not local shares (c:\media files\)? MySQL doesn’t play nice with the \ symbol found in local share names.
- Did you open port 3306 on the MySQL host machine?
- If you’re having problem with a sub-profile’s database, did you place the advancedsettings.xml file in /profiles/[profile name] ?
- Are your sources valid and scannable when you remove the advancedsettings.xml file and revert to the local database? If not, you’ll need to troubleshoot your sources independently of your MySQL problems.
If everything looks good and your SELECT COUNT query pans out, that means you’re ready to start taking advantage of the cross-media-center syncing. Let’s take a peek at what that looks like.
XBMC Syncing Across Multiple Machines
One of the first changes you’ll want to make, if you haven’t already toggled this setting to begin with, is to alter what XBMC does in response to you pressing play on a file. By default XBMC simply plays the file from the beginning. Since we now have an XBMC system that remembers our place across multiple machines, we want XBMC to prompt us.
Navigate to Settings –> Video –> File Lists and set the Default select action to Choose. We want XBMC to ask us what to do when we’re opening a file instead of automatically playing it from the start.
Now that we’ve flipped that toggle it’s time to play around with XBMC and see how we can resume play and check our watched files across the network at multiple XBMC consoles.
We’re going to navigate to our directory of HDTV demo reels and mark one as watched, set a bookmark in another, and watch and pause the third reel. Then we’re going to leave the office and go into the living room and check the three files to ensure XBMC has properly flagged the first, bookmarked the second, and can resume the third. Here are snapshots of each action:
Now, when we travel to another XBMC console, we can take a peek at what each one of these things looks like. Let’s check to see that our first file has been marked as watched:
Excellent, there it is with a check mark beside it. The remote XBMC console is aware the file has been watched.
What about bookmarks? Did the bookmarks carry across via the database too? Let’s check and see if the action our action packed scene with the fire breather and rugby player is still bookmarked:
Looking good so far. Finally let’s check to make sure that the video we paused in our office will resume in the correct location (1:13) when we select it in the living room:
Success! Simply pausing/stopping the movie file in the office was enough to mark it in the database and prompt us to resume from that location when we returned to the file at the remote location.
From this point forward you’ll be able to check what movie and TV shows you’ve watched, where you left off, and what bookmarks you set, from anywhere within your house. Your media and associated libraries will be up to date regardless of where you are—no more fussing with manually syncing your library contents again!
Wednesday, September 28, 2011
How to Sync Your Media Across Your Entire House with XBMC - How-To Geek
via howtogeek.com
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment