Get current program (1 Viewer)

hbrotan

Portal Member
November 22, 2006
5
0
Hey!

I am writing a plugin that will store userprofiles based on what they are watching in MediaPortal. To do this, I have created a plugin. It is based on GUITvGuide and inherits GUITvGuideBase. It overrides the method OnAction, so I can save to file when a programme is selected.

I have one problem though. I want to save the TVProgram information,
but this is stored in a private variable in the GUITvGuideBase (_currentProgram).

Is there any way I can access this variable, or is there another way yo get the TVProgram object for the programme that is selected??

Any help is appreciated!
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
I'm assuming you're using the code for the new TV engine (the client/server one) - try using the methods in the TvControl.dll assembly. IIRC, there are methods in there that allow you to access the database. The tvGuide may put the selected program's ID in the property manager class, so you may be able to check it out from there. Unfortunately there's no easy way to browse through the propertymanager properties, so I'd check through the source code for the tv guide for calls to a class called PropertyManager.

That said, I haven't played around with the new TV engine yet, so I'm not 100% sure.

Sam
 

hbrotan

Portal Member
November 22, 2006
5
0
Thanks for replying!

Hm. Sounds a bit complicated for me..

I was thinking I could create my own GUITvGuideBase. I tried doing this, but when I clicked on myplugin in MediaPortal, I went back to the main screen instead of entering myplugin.

So suddenly I have a GUI problem. But GUITvGuideBase doesn't have a skin xml file or window ID right? So why does it go back to the main screen? I've copy-pasted the code directly from the original GUITvGuideBase. (changed namespace and class name of course..)
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
I just had a quick look at GUITVGuideBase. From what I can see the UpdateCurrentProgram() method is called whenever the user changes the selected program. I assume that if you find that method, you will be able to find where it stores the currently selected program (I think its _CurrentProgram from just looking in the online SVN).

You will have to specify a new windowID as well as a skin file. Just implement it like GUITVGuide.cs.

Sam
 

hbrotan

Portal Member
November 22, 2006
5
0
Thanks again for replying.

You're right about the UpdateCurrentProgram() method and the _currentProgram variable. Unfortunately, they're both private, so I can't access them.
I tried to use the TVDatabase for public methods, but noone seemed to return the last TVProgram object.

Concerning the GUITvGuideBase.cs. You say I have to specify a new windowID and a skin file, but I can't find that GUITvGuideBase uses a skin file. It does use GetID, but it is not set anywhere. The way I perceive it, is that GUITvGuideBase uses the same skin and id as GUITvGuide..

My situation now is that I have:
- main.cs (based on GUITvGuide.cs)
- GUITvGuideBase_EPG.cs (based on GUITvGuideBase).
main.cs inherits GUITvGuideBase.cs.
They're in the same namespace.

In MediaPortal, when I click on myplugin, I go back to the main screen.
If I change main.cs to inherit the original GUITvGuideBase, enter MediaPortal and click on myplugin, the customized EPG window appears.

I would be very happy if you could explain to me what I have to change in GUITvGuideBase_EPG.cs to make it work :)
 

samuel337

Portal Pro
August 25, 2004
772
0
Melbourne, Australia
You have to specify a skin file and a Windows ID in your class that implements GUITVGuideBase, not in GUITVGuideBase itself.

My situation now is that I have:
- main.cs (based on GUITvGuide.cs)
- GUITvGuideBase_EPG.cs (based on GUITvGuideBase).
main.cs inherits GUITvGuideBase.cs.

I'm confused here. If main.cs inherits from GUITVGuideBase.cs, what's the point of GUITVGuideBase_EPG.cs? and does GUITVGuideBase_EPG inherit from GUITVGuideBase?

In any case, you might be interested to know that GUITVGuideBase actually puts all the values of the currently selected program in the PropertyManager class. So to access info about the currently selected program, use this code:

GUIPropertyManager.GetProperty(<tag string>);

Valid <tag string> values are (they're pretty self-explanatory):
#TV.Guide.Title
#TV.Guide.Time
#TV.Guide.Description
#TV.Guide.Genre
#TV.Guide.Duration
#TV.Guide.TimeFromNow
#TV.Guide.EpisodeName
#TV.Guide.SeriesNumber
#TV.Guide.EpisodeNumber
#TV.Guide.EpisodePart
#TV.Guide.Date
#TV.Guide.StarRating
#TV.Guide.Classification
#TV.Guide.EpisodeDetail
#TV.Guide.thumb

If you want to know when a the selected program has changed, listen in on eithe the Actions or Messages sent.

Sam
 

hbrotan

Portal Member
November 22, 2006
5
0
I'm sorry, that was a typo on my behalf.
GUITvGuideBase_EPG is my version of GUITvGuideBase, and main.cs (my version of GUITvGuide) inherits GUITvGuideBase_EPG, without getting the GUI right..
And yes, I have a new window id (5679) and skin file for main.cs.

Anyway, your tip of using the GUIPropertyManager worked!
Now, I can overrid the OnAction method and get the information I need.
(This way I don't have to have my own version of GUITvGuideBase)


Big thanks to you Sam!!!
 

Users who are viewing this thread

Top Bottom