Showing posts with label media center. Show all posts
Showing posts with label media center. Show all posts

Wednesday, 26 October 2011

Windows 7 Media Center (MCE) command line recording application

During a previous home automation project using Debian Linux, X10 power management, Asterisk PABX software and Windows Media Center I found a distinct lack of flexibility with Windows 7 MCE command line recording. I wanted to be able to phone my Asterisk VOIP phone number and have it schedule a recording on my behalf.

While Windows 7 MCE is amazing at recording scheduled shows you set via the UI, unfortunately there is no good way to record shows from the command line.

After doing some research I found information on the Microsoft ClickToRecord API and decided to have a crack at building an application with my limited (OK, almost non-existent) C# knowledge.

After toiling away for a few hours I was able to make a working code example.

Binary Link
Source Link

Feel free to take my source and do what you want with it, PLEASE clean it up and send it back to me.


How it works

This is a two step process, first to create the recording XML file, then import it into my schedule.exe.

1. Create an XML file as per below.

<?xml version="1.0" encoding="utf-8" ?>
<clickToRecord xmlns="urn:schemas-microsoft-com:ehome:clicktorecord">
    <body>
        <programRecord programDuration="30">
            <service>
                <key field="urn:schemas-microsoft-com:ehome:epg:service#mappedChannelNumber" match="exact">7</key>
            </service>
            <airing>
                <key field="urn:schemas-microsoft-com:ehome:epg:airing#starttime">2011-10-26T12:00:00+10:30</key>
            </airing>
        </programRecord>
    </body>
</clickToRecord>
You can see the XML file is very simple, I have set up a scheduled record on channel 7  for 30 minutes at 12:00PM on October 26, 2011.

 The key properties are:

The program duration, set as 30 minutes in my example.
<programRecord programDuration="30">

The channel number, set as channel 7 in my example.
<key field="urn:schemas-microsoft-com:ehome:epg:service#mappedChannelNumber" match="exact">7</key>

The start time, set as 12:00PM on October 26, 2011 (in UTC + 10:30 hours time zone)
<key field="urn:schemas-microsoft-com:ehome:epg:airing#starttime">2011-10-26T12:00:00+10:30</key>


2. Simply execute the XML with the following command
schedule.exe filename.xml


My Usage

I use an Asterisk script to generate the XML file when I call. First it prompts me for the channel, then program start time and date. Next the MCE is started with a wake-over-lan boot if it is switched off, then XML file is uploaded to the MCE and is then triggered with Sysinternals psexec on the MCE itself.

I hope you find this little utility as useful as I did!

Monday, 24 October 2011

Windows 7 Media Center is very slow to load after a reboot

I have had a media center (centre for those Australians out there) since Microsoft first brought out XPMCE, the product has come a long way from one that needed 1000 plugins to function, to something that can stand on its own as a good MCE.

These days I am running Windows 7 MCE with four tuners and I depend on it to record all my TV for me, after 5 years of skipping through advertisements, its hard to go back!

Every so often I find the Media Center because extremely slow, slow to load, slow to open channels or movies and slow to navigate any network paths.



The Solution

The fix (as long as you haven't contracted some nasty malware along the way) is to remove the MCE index. I have completed this process a few times and have observed a few drawbacks.
  • All your music and movies will need to be reindexed
  • You lose your channel favourites and ordering, but you don't have to rescan your tuners or reset scheduled records
  • This will also effect your Windows Media Player libraries


1. Open Windows Explorer and navigate to %LOCALAPPDATA%\Microsoft\
2. This will take you to a path something like c:\users\ <username>\AppData\Local\Microsoft\

3. The folder we need to remove is "Media Player" but before we do that we need to stop some services. Close any active Media Player or Media Center instances and then open a command prompt, you can do this by going to the start menu and clicking run and then typing cmd.exe and pressing enter.

4. Before you run the two below commands, please be aware that any current recordings will be stopped, so if your favourite show is recording you may want to delay this until later.

In the command prompt type:

net stop ehRecvr
net stop WMPNetworkSVC

 
 

4. Now we can rename the "Media Player" folder. I prefer to rename instead of deleting just in case I realize I need something from the directory later. Rename the "Media Player" directory to "Media Player.bak"

5. Now restart your computer. Alternatively you can restart those two services, but because running services might differ from machine to machine, a more conclusive option.

If your Media Center is still slow after doing this it might be worth looking at other programs you have running in the background. I have completed this process 2-3 times now and it perks up my MCE performance every time!