Questions on writing my first plugin (1 Viewer)

huha

Extension Developer
January 3, 2008
890
556
Home Country
Germany Germany
  • Thread starter
  • Moderator
  • #11
Albert,
with your help i got my first listitem skin working. It does everything i want for focusing and clicking on an item, but throws an exception in the log file
whenever I change the focus of an item.

I am using now "Name" and Style="{ThemeResource MenuListViewStyle}" which results in a nice list item menu list.
whenever I change the focus the following function is executed correctly:

public void FocusedItemChanged(ListItem focusedListItem)
{
if (focusedListItem == null)
return;
mylogger.Debug("FocusedItemChanged: Focused item=" + focusedListItem.Labels["Name"]);

//update label
FocusedItem = LocalizationHelper.Translate(FOCUSED_ITEM_RESOURCE, focusedListItem.Labels["Name"]);
mylogger.Debug("FocusedItemChanged: Completed");
}

However, after "FocusedItemChanged: Completed" it throws an exception

[2012-04-07 20:29:19,112] [12236 ] [InputMgr ] [DEBUG] - FocusedItemChanged: Completed
[2012-04-07 20:29:19,125] [12249 ] [InputMgr ] [ERROR] - CommandBaseMarkupExtension: Error executing command '{CommandStencil Source=MyTestPlugin.Models.MyTestPluginScreen2,Path=FocusedItemChanged}'
System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei MyTestPlugin.Models.MyTestPluginScreen2.FocusedItemChanged(ListItem focusedListItem)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bei MediaPortal.UI.SkinEngine.MarkupExtensions.CommandBaseMarkupExtension.Execute(IEnumerable`1 parameters)

My screen file is:

<Include.Resources>

<!-- Header -->
<ResourceWrapper x:Key="Header_Text" Resource="[MyTestPluginScreen2.ScreenTitle]"/>

<!-- SlimTvClient model -->
<Model x:Key="MyTestPluginScreen2" Id="cefc2f41-8a0d-4f92-b2e7-c7fa2194e90d"/>

<!-- Contents -->
<ControlTemplate x:Key="Contents_Template">
<DockPanel Context="{Model Id=cefc2f41-8a0d-4f92-b2e7-c7fa2194e90d}" LastChildFill="False">
<Label Content="{Binding FocusedItem}" Color="{ThemeResource TextColor}" FontSize="22" DockPanel.Dock="Top" HorizontalAlignment="Left"/>
<Label Content="{Binding SelectedItem}" Color="{ThemeResource TextColor}" FontSize="22" DockPanel.Dock="Top" HorizontalAlignment="Left"/>
<ListView Name="TestListView" DockPanel.Dock="Center" Height="300" Width="600" ItemsSource="{Binding MyListViewItems}" SelectionChanged="{CommandStencil Source={StaticResource MyTestPluginScreen2}, Path=FocusedItemChanged}" Style="{ThemeResource MenuListViewStyle}">
<ListView.Resources>
<CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/>
</ListView.Resources>
</ListView>
</DockPanel>
</ControlTemplate>


</Include.Resources>

Any idea what could causing this?
 

Attachments

  • Step3.zip
    1.1 MB

huha

Extension Developer
January 3, 2008
890
556
Home Country
Germany Germany
  • Thread starter
  • Moderator
  • #12
Albert,
the problem disappeared after i recompiled. It could be that i accidently did not copy the correct .dll file into the plugin directory. Thanks again for your help. It is now working without errors.
 

huha

Extension Developer
January 3, 2008
890
556
Home Country
Germany Germany
  • Thread starter
  • Moderator
  • #13
I completed Step 3 and uploaded the source code. Moving on to the last one.
 

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    I think most of your planned features are already implemented inside the slimtv plugin. So if you need some ideas you can look there.

    Thank you for your efforts, this will help others to step into MP2 development!

    Gesendet von meinem GT-I9000 mit Tapatalk
     

    huha

    Extension Developer
    January 3, 2008
    890
    556
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #15
    Morpheus_xx,
    i will document more details in the future. I believe to understand the programs, groups and schedules from the slimtvclient plugin (the older alfa version). I guess that some features are in progress there and that you are not implementing the identical MP1 classes from the tvserver.
    What's not clear to me is how to get the general (MP1) settings from the tv server data base or how to do a direct sql query to the Tv server database in MP2.
    I was looking at slimtvclient, slimtvinterfaces and slimtv4homeprovider.
    I still could use the old gentle .dll interfaces from MP1, but believe this is not the expected way to handle this.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Huha,
    you are right, SlimTV currently supports only programs, groups and schedules. And it's also not intended to build everything the same way as the MP1 TvServer. My approach is to have a generic abstraction layer between MP2 and the MP1 TV features. The connection is done using the MPExtended (or Tv4home) services, that provide such kind of abstraction.

    For your work on an example this means, you can look into the MPExtended (or Tv4home) services for missing features like reading/writing settings. I have no plans to add this into SlimTV.

    I would not recommend to add the old gentle stuff into any MP2 plugin. In MP2 only the server does use a direct SQL connection to its database, all communication with MP2 client is done over the UPNP protocol.
     

    huha

    Extension Developer
    January 3, 2008
    890
    556
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #17
    morpheus_xx,
    I needed to change to the easter version. I was able to complete all the functions I wanted to use for a base skeleton. Thanks again for your help.
    I did post the updated source code.
     

    huha

    Extension Developer
    January 3, 2008
    890
    556
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #18
    I believe I found an issue in the Slim TV plugin (I am still using the Easter built!)

    Whenever i declare a dependency on the SlimTv plugin in plugin.xml with
    <!-- SlimTvClient -->
    <!-- <PluginReference PluginId="{63040BB4-4638-49b7-A82F-F4530D4D43B9}"/> -->

    and remove the comment in the dependency section I am getting an error message if I am not using the default skin:

    [2012-06-09 18:28:47,498] [28912 ] [AMQ 'ScreenManager'] [INFO ] - SkinResources: Loading style resource 'styles\othercontrols.xaml' from file 'C:\Program Files (x86)\Team MediaPortal\MP2-Client\Plugins\SkinBase\Skin\default\themes\default\styles\OtherControls.xaml'
    [2012-06-09 18:28:47,558] [28972 ] [AMQ 'ScreenManager'] [ERROR] - ThemeResourceMarkupExtension: Resource 'OSDCurrentPlayerControlStoryboard' not found
    [2012-06-09 18:28:47,558] [28972 ] [AMQ 'ScreenManager'] [ERROR] - ThemeResourceMarkupExtension: Resource 'OSDContainer' not found
    [2012-06-09 18:28:47,578] [28992 ] [AMQ 'ScreenManager'] [ERROR] - ScreenManager: Error applying skin 'RisingSkin', theme 'Silver'
    MediaPortal.Utilities.Exceptions.EnvironmentException: Error loading style resource 'C:\Program Files (x86)\Team MediaPortal\MP2-Client\Plugins\SlimTvClient\Skin\RisingSkin\themes\Silver\styles\SlimTvStyles.xaml' ---> MediaPortal.UI.SkinEngine.Xaml.Exceptions.XamlLoadException: XAML loader: Error parsing file 'C:\Program Files (x86)\Team MediaPortal\MP2-Client\Plugins\SlimTvClient\Skin\RisingSkin\themes\Silver\styles\SlimTvStyles.xaml' ---> MediaPortal.UI.SkinEngine.Xaml.Exceptions.XamlBindingException: Could not evaluate markup extension 'ThemeResource ResourceKey=OSDCurrentPlayerControlStoryboard'
    bei MediaPortal.UI.SkinEngine.Xaml.EvaluatableMarkupExtensionActivator.Activate()
    bei MediaPortal.UI.SkinEngine.Xaml.Parser.Parse()
    bei MediaPortal.UI.SkinEngine.SkinManagement.XamlLoader.Load(TextReader reader, ISkinResourceBundle actualResourceBundle, IModelLoader loader)
    --- Ende der internen Ausnahmestapelüberwachung ---
    bei MediaPortal.UI.SkinEngine.SkinManagement.XamlLoader.Load(String skinFilePath, ISkinResourceBundle actualResourceBundle, IModelLoader loader)
    bei MediaPortal.UI.SkinEngine.SkinManagement.SkinResources.LoadStyleResource(String resourceKey, Boolean searchInheritedResources)
    --- Ende der internen Ausnahmestapelüberwachung ---
    bei MediaPortal.UI.SkinEngine.SkinManagement.SkinResources.LoadStyleResource(String resourceKey, Boolean searchInheritedResources)
    bei MediaPortal.UI.SkinEngine.SkinManagement.SkinResources.LoadAllStyleResources()
    bei MediaPortal.UI.SkinEngine.SkinManagement.SkinManager.InstallSkinResources(SkinResources skinResources)
    bei MediaPortal.UI.SkinEngine.ScreenManagement.ScreenManager.PrepareSkinAndTheme(String skinName, String themeName)
    It may be fixed in the newer version, but I thaught I better post it.
    Greetings, huha
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    45
    Freiburg im Breisgau, Germany
    Home Country
    Germany Germany
    That error seems to me as if you are overwriting a theme file but in a wrong way. The parser which loads the theme didn't parse the style "OSDCurrentPlayerControlStoryboard" yet when it loads the SlimTvStyles.xaml file. That problem might arise if you overwrite MediaStyles.xaml and don't declare that style in your file or if you add a dependency to the SlimTV style file before the parser had a chance to load MediaStyles.xaml, or something like that.
     

    huha

    Extension Developer
    January 3, 2008
    890
    556
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #20
    Albert, I did a fresh install of the Easter build in the program folder. I have none of my plugins installed. Now i copied the HelloWorld plugin and included in plugin.xml:

    <DependsOn>
    <!-- SlimTvClient -->
    <!--<PluginReference PluginId="{63040BB4-4638-49b7-A82F-F4530D4D43B9}"/>-->
    </DependsOn>

    With the comments everything works fine.
    If I remove the comment I am getting now a different error message

    [2012-06-19 22:26:13,608] [592 ] [Main ] [INFO ] - PluginManager: Plugin 'Media' (id '15fb35f7-8c85-4404-bc67-bff28446158a') enabled.
    [2012-06-19 22:26:13,608] [592 ] [Main ] [DEBUG] - PluginManager: Trying to activate plugin 'Media' (id '15fb35f7-8c85-4404-bc67-bff28446158a')
    [2012-06-19 22:26:13,608] [592 ] [Main ] [DEBUG] - PluginManager: Checking activation of plugin dependency '1aff4467-64b0-4ca1-af28-9aedf3525bce' for plugin 'Media'
    [2012-06-19 22:26:13,608] [592 ] [Main ] [DEBUG] - PluginManager: Checking activation of plugin dependency 'b765a4b6-f455-4941-bdae-2ce45208bfeb' for plugin 'Media'
    [2012-06-19 22:26:13,608] [592 ] [Main ] [DEBUG] - PluginManager: Checking activation of plugin dependency '5d239050-02b8-4f58-8301-7630a1c4cf85' for plugin 'Media'
    [2012-06-19 22:26:13,655] [639 ] [Main ] [FATAL] - Error executing application
    MediaPortal.Common.PluginManager.Exceptions.PluginLockException: Plugin 'SkinBase' (id: '5d239050-02b8-4f58-8301-7630a1c4cf85') cannot be locked for state dependency - it's currently changing its state ---> System.Threading.LockRecursionException: Eine Aktualisierungssperre kann bei aktivierter Lesesperre nicht eingerichtet werden.
    bei System.Threading.ReaderWriterLockSlim.TryEnterUpgradeableReadLock(Int32 millisecondsTimeout)
    bei System.Threading.ReaderWriterLockSlim.TryEnterUpgradeableReadLock(TimeSpan timeout)
    bei MediaPortal.Common.PluginManager.PluginRuntime.LockForStateDependency(Boolean upgradableToWriteLock)
    --- Ende der internen Ausnahmestapelüberwachung ---
    bei MediaPortal.Common.PluginManager.PluginRuntime.LockForStateDependency(Boolean upgradableToWriteLock)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.LockPluginStateDependency(PluginRuntime plugin, Boolean upgradableToWriteLock, PluginState[] statesToLock)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.TryActivate(PluginRuntime plugin)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.TryActivate(PluginRuntime plugin)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.TryEnable(PluginRuntime plugin, Boolean doAutoActivate)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.TryEnable(PluginRuntime plugin, Boolean doAutoActivate)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.TryEnable(PluginRuntime plugin, Boolean doAutoActivate)
    bei MediaPortal.Common.Services.PluginManager.PluginManager.Startup(Boolean maintenanceMode)
    bei MediaPortal.Client.ApplicationLauncher.Main(String[] args)

    I am not able to get any plugin to run with the dependency setting on the SlimTvclient
     

    Users who are viewing this thread

    Top Bottom