Kodi Community Forum

Full Version: Launching WMC directly from pvr.wmc EPG?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A quick thanks for all the hours of work/making my life better--my favorite latest development in the XBMC world!

Though I've switched to serverWMC and pvr.wmc entirely on one of my HTPCs, on the 'family friendly' TV, I'm still using WMC for live TV and its EPG (launching to and from XBMC w/ eventghost). However the pvr.wmc EPG is really nice looking and easily scriptable, and I'm wondering if there's a way to view the pvr.wmc EPG in XBMC to check if there's anything good on live TV and, when I select a channel, launch/switch into WMC and bring up that channel?
It would also give users a way of viewing content protected channels by launching wmc for these channels only. Unfortunately though, I don't think there is an easy way to do this because - as far as I know - wmc doesn't have a command line option to launch it into live tv on a particular channel. If it did, it might be possible to add something like this (famous last words). At least I would be willing to take a look at it.

As an aside, working on this project and playing with the low level com routines in windows, I have in the past been able to issue channel changes to wmc from outside of wmc. But it would require some ugly code and probably be buggy as hell, I don't think its a direction we'd want to take this project.
Thanks Krusty, digging around a bit following your lead, it looks like the most tractable options involve using some piece of code (.bat or python) to modify a value in the registry where the wmc "last channel" info is stored?

(I can see how calling some external code that modifies a user's registry might cause a little bit of a stir! Smile

If one wanted to modify the source to try this registry modification (hack) solution, would this be doable without too many lines of code--is there one section in one of the source files that handles the "EPG channel selection-to-live TV view" action?

Thought I'd post one kluge (of several floating around) that I think is similar to what Krusty might have been talking about, in case others are following this thread. This one uses a bit of python code to pass a channel to a .reg file that then overwrites a line in the Windows registry:

http://hmmtheresanidea.blogspot.com/2008...cular.html

Bummer that there's no simple 'startup tuned to channel X' command that can be passed directly to ehshell.exe by quickwmc or the like!
Good find, have you tried it?
Not yet, on my Mac at work but I'll try it once I get home later and share results. I think there's even a way to do the registry modification silently/sans Windows warnings, so looks like a start (already using python to automate a few other things, so should be easy to test).
So quick update that starting WMC in a specific channel by editing the registry on-the-fly works great on my Windows 8.1 machine at home.

It's a slight modification from the blog I posted the link to in the 3rd posting above (that blog was from 2008, so it looks like the difference is due to new registry settings in Windows 7/8). But the idea is:

1. Create a small .reg file that modifies the "last channel" # (and the channel ID) in the Windows registry. That .reg file will look like:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Media Center\Settings\VideoSettings]
"_tvChannel"="channel number"
"_tvChannelID"="channel ID"

2. Execute that file, which will update your registry. On my W8.1 machine, it actually did this automatically, without any "are you sure?!" prompts.

3. Launch WMC in LiveTV+fullscreen+etc. mode


Task #1 is pretty easily scriptable... a simple .bat file could probably do this? However I'll paste the python code below in case it's useful (full credit goes to that blog author linked above; some minor modifications for Windows 7/8 compatibility).

Code:
#python script to start WMC on a specific channel
#full credit to http://hmmtheresanidea.blogspot.com/2008/10/start-media-center-on-particular.html
#this code is just a slight modification of that author's code, adding _tvChannelID for Windows 7 and later
#execute via: python channelLaunch.ph [tv Channel #] [tv Channel ID]

import os, sys

#strings to write reg file
regStrings = []
regStrings.append("Windows Registry Editor Version 5.00")
regStrings.append("[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Media Center\Settings\VideoSettings]")

#make sure a channel was passed
if len(sys.argv) > 1:
    try:
      regStrings.append('"_tvChannel"="'+ sys.argv[1] + '"')
      regStrings.append('"_tvChannelID"="'+ sys.argv[2] + '"')
      regFile = open('regFile.reg','w')
      for i in range(len(regStrings)): #write lines to file
        regFile.writelines(regStrings[i])
        regFile.writelines('\r\n')
      regFile.close()
      os.system('regedit /s "' + os.path.join(sys.path[0], 'regFile.reg') + "") #edit registry
      os.system("start /MAX %systemroot%\ehome\ehshell.exe /homepage:VideoFullscreen.xml") #start media center
    except:
       print "Error caused by exacuting or writing file"
else:
   print "Invalid argument - specify a channel"


Whoops... the forum ate my python indents. Here's a screen cap:

Image
Cool, thanks for following up. This would be simple to add to quickwmc I think. But does just running the script do what you need?
It's half the battle... the other part is getting the channel # that is being selected from the EPG in XBMC. Can you suggest where I might look to do this? Is this something that is written to/could be easily parsed from an XBMC plain text file somewhere, or would it require going into e.g. the pvr.wmc source code and making changes there?
it would be in the XBMC log file if you wanted to scrape it but it would obviously be more seamless if we were to have an option in the pvr.wmc addon to launch an external script/program and pass it as an argument

also regarding posting your code, if you put [code ] [/ code] tags around it, you should be able to preserve the formatting
Aha, thanks Scarecrow, I edit my post including the tags so it should actually be copy-/paste-able!

I hadn't thought about scraping the XBMC log file--smart workaround. But I still need a way to trigger launching WMC from the XBMC EPG when I click on a channel. At least I think this is the case?

I'll start digging through pvr.wmc... I've never looked through that code and lots of c++ cobwebs, so if anyone has pointers on where to start looking please let me know.
You want to look at OpenLiveStream in the file pvr2wmc.cpp. OpenLiveStream also receives the channel info as an arg, so you can use this info rather than scrapping.

Is your plan to launch quickwmc to launch wmc? It would be easier to let quickwmc take the channel as an input arg and let it change the registry before it launches wmc into live-tv.
I think this is a great idea. Along the same lines, would it be possible to also have recorded copy-once movies open in wmc when selected from XBMC movies menu?
I think that's possible.