GUIListControl - Simple Example (1 Viewer)

GF__74

Portal Member
June 8, 2008
16
1
Akl, NZ
Home Country
New Zealand New Zealand
I am trying to create a plugin that displays a list of movie items in a specific directory. Each item has an XML file that has its details, a movie file and at thumbnail image.

I have looked through the documentation for MediaPortal and the source code for the 'My Videos' section of MP that uses this control, but the complexity of the code is a little mind-boggling to some one who is very new to this sort of development.

Does anyone have a simple code listing that scans a folder to create a list of files that are then displayed in MP as a simple list ?

Thanks

GF
 

kroko

Portal Pro
February 4, 2007
428
420
55
Itzehoe
Home Country
Germany Germany
Hi GF__74,

here is small sample..

Define you facade

[SkinControlAttribute(50)]
protected GUIFacadeControl facadeView = null;

private void LoadDir() // called OnLoad

// facade clear
GUIControl.ClearControl(GetID, facadeView.GetID);

// add ".."
GUIListItem item = new GUIListItem();
item.Label = "..";
item.Path = currentFolder;
item.IsFolder = true;
item.MusicTag = null;
item.ThumbnailImage = string.Empty;
MediaPortal.Util.Utils.SetDefaultIcons(item);
facadeView.Add(item);

// all other items
for (int i = 0; i < currentPlayList.Count; ++i)
{
item = new GUIListItem();

item.Label = currentPlayList.Description;
item.Path = currentPlayList.FileName;
item.IsFolder = false;
item.MusicTag = null;
// see other props also

// thumbnail handling
item.ThumbnailImage = string.Empty;
item.IconImageBig = "DefaultMyradioStreamBig.png";
item.IconImage = "DefaultMyradioStream.png";

string thumbnail = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Radio, item.Label);
if (System.IO.File.Exists(thumbnail))
{
item.IconImageBig = thumbnail;
item.IconImage = thumbnail;
item.ThumbnailImage = thumbnail;
}
facadeView.Add(item);
}

For the action use the Onclicked override

if (control == facadeView)
{
GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, controlId, 0, 0, null);
OnMessage(msg);
int itemIndex = (int)msg.Param1;
if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
{
OnClick(itemIndex);
}
}

(source from Streamradio V2)


Regards
kroko
 

GF__74

Portal Member
June 8, 2008
16
1
Akl, NZ
Home Country
New Zealand New Zealand
FacadeView Control - Runtime error

I have managed to create a simple facadeView from the code above and other sources within the MediaPortal source code, but I am now getting runtime errors when attempting to configure/run the plugin.

The MP error log shows this:
2009-03-16 11:35:42.362146 [ERROR][MPMain]: Exception :confused:ystem.NullReferenceException: Object reference not set to an instance of an object.
at MPPlugin.Class1.LoadListItems()
2009-03-16 11:35:42.363147 [ERROR][MPMain]: Exception :Object reference not set to an instance of an object.
2009-03-16 11:35:42.364147 [ERROR][MPMain]: site :Void LoadListItems()
2009-03-16 11:35:42.365147 [ERROR][MPMain]: source :AppleTrailersPlugin
2009-03-16 11:35:42.366147 [ERROR][MPMain]: stacktrace: at MPPlugin.Class1.LoadListItems()
2009-03-16 11:35:42.393153 [ERROR][MPMain]: Exception while loading GUIWindows instances: MPPlugin.Class1
2009-03-16 11:35:42.394153 [ERROR][MPMain]: Exception has been thrown by the target of an invocation.
2009-03-16 11:35:42.397153 [ERROR][MPMain]: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at MediaPortal.GUI.Library.PluginManager.LoadWindowPlugin(String strFile)
2009-03-16 11:35:42.399154 [ERROR][MPMain]: Exception :confused:ystem.NullReferenceException: Object reference not set to an instance of an object.
at MPPlugin.Class1.LoadListItems()
2009-03-16 11:35:42.400154 [ERROR][MPMain]: Exception :Object reference not set to an instance of an object.
2009-03-16 11:35:42.400154 [ERROR][MPMain]: site :Void LoadListItems()
2009-03-16 11:35:42.401154 [ERROR][MPMain]: source :AppleTrailersPlugin
2009-03-16 11:35:42.402154 [ERROR][MPMain]: stacktrace: at MPPlugin.Class1.LoadListItems()
2009-03-16 11:35:42.405155 [ERROR][MPMain]: Exception while loading ISetupForm instances: MPPlugin.Class1
2009-03-16 11:35:42.406155 [ERROR][MPMain]: Exception has been thrown by the target of an invocation.
2009-03-16 11:35:42.407155 [ERROR][MPMain]: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at MediaPortal.GUI.Library.PluginManager.LoadWindowPlugin(String strFile)

I am assuming this is something to do with either the plugin or skin code.

My skin file is fairly simple:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<window>
    <id>5678</id>
    <defaultcontrol>2</defaultcontrol>
    <allowoverlay>yes</allowoverlay>
    <define>#header.label:5678</define>
    <define>#header.image:trailers_logo.png</define>
    <define>#header.hover:hover_my trailers.png</define>
    <controls>
        <import>common.window.xml</import>
        <import>common.facade.video.xml</import>
        <import>common.time.xml</import>
    </controls>
</window>

The code for the plugin follows the same path as the above.

My guess is there is something missing from my instantiation of the facadeview control, but i am little lost.

Any help appreciated.

GF
 

GF__74

Portal Member
June 8, 2008
16
1
Akl, NZ
Home Country
New Zealand New Zealand
I have managed to get it all going following recommendations from kroko :D and reviewing the source from MP.

When i have this project all finished i think a new development document may be in order to assist other in this process.

GF
 

Users who are viewing this thread

Top Bottom