Hi guys!
As you maybe know it's a pain in ... to find how to interact with MediaPortal and get needed data from plugin because of MP code's complexity and lack of comments and documentation sometimes. So what about sharing some useful method which could help new plugin devs to code?
Let me start from my noob point of view :
How to get Channel Groups from TV Server
How to check if another plugin is available and enabled:
Source https://code.google.com/p/mptvseries/source/browse/trunk/MP-TVSeries/Helper.cs#701
How to interact with trakt plugin
How to use TMDB provider from Moving Pictures:
Get Series List from MP-TVSeries:
How to create own custom GUI Dialog
1) Choose of existing dialog to modify it. https://github.com/MediaPortal/MediaPortal-1/tree/master/mediaportal/Dialogs/Dialogs
2) Create your own dialog by overriding one of them
Examples:
https://code.google.com/p/mediaport...k/LogoManager/LogoManager/GUIDIalogPreview.cs
https://code.google.com/p/mediaport...LogoManager/LogoManager/GUICheckListDialog.cs
https://code.google.com/p/moving-pictures/source/browse/trunk/Cornerstone.MP/GUIPinCodeDialog.cs
https://code.google.com/p/moving-pictures/source/browse/trunk/Cornerstone.MP/GUIGeneralRating.cs
https://code.google.com/p/mptvseries/source/browse/trunk/MP-TVSeries/GUIUserRating.cs
https://code.google.com/p/mptvseries/source/browse/trunk/MP-TVSeries/GUIPinCode.cs
3) Create skin files for your new dialog
Take skin file of Dialog you overrided and modify it for your needs. Change Windowd ID, add new control etc.
Skin files for standart skins (better start with supporting them) located here:
https://github.com/MediaPortal/MediaPortal-1/tree/master/mediaportal/MediaPortal.Base/skin/
4) Now you can use custom dialog just as like as standart one
How to create custom GUI Control (untested)
1) Create your control's code overridingone of existing controls or GUIControl class itself
Examples:
https://github.com/MediaPortal/Medi...portal/WindowPlugins/GUISudoku/CellControl.cs
https://github.com/MediaPortal/Medi...al/WindowPlugins/GUITetris/MyTetrisControl.cs
2) Register your custom control in Init:
3) ...
If you would like to continue my efforts, please, share your code samples!
Many thanks!
As you maybe know it's a pain in ... to find how to interact with MediaPortal and get needed data from plugin because of MP code's complexity and lack of comments and documentation sometimes. So what about sharing some useful method which could help new plugin devs to code?
Let me start from my noob point of view :
How to get Channel Groups from TV Server
C#:
using TvDatabase;
...
public static TvBusinessLayer layer = new TvBusinessLayer();
IList<ChannelGroup> tvGroups = ChannelGroup.ListAll();
IList<RadioChannelGroup> radioGroups = RadioChannelGroup.ListAll();
IList<Channel> channels = layer.GetChannelsInGroup(selectedGroup);
How to check if another plugin is available and enabled:
C#:
publicstatic bool IsAssemblyAvailable(string name,Version ver){
bool result =false;
Assembly[] assemblies =AppDomain.CurrentDomain.GetAssemblies();
foreach(Assembly a in assemblies)
try
{
if(a.GetName().Name== name && a.GetName().Version>= ver)
{
result =true;
break;
}
}
catch
{
}
if(!result){
try{
//Assembly assembly = AppDomain.CurrentDomain.Reflection(new AssemblyName(name));
Assembly assembly =Assembly.ReflectionOnlyLoad(name);
result =true;
}
catch(Exception e){
}
}
return result;
}
public static bool IsPluginEnabled(string name){
using (MediaPortal.Profile.Settings xmlreader =newMediaPortal.Profile.MPSettings()){
return xmlreader.GetValueAsBool("plugins", name,false);
}
}
How to interact with trakt plugin
C#:
using TraktPlugin.TraktAPI;
using TraktPlugin.TraktAPI.DataStructures;
...
IEnumerable<TraktSearchEpisode> myep = TraktAPI.SearchEpisodes("Scars");
IEnumerable<TraktMovie> searchmovie = TraktAPI.SearchMovies("Tron");
IEnumerable<TraktShow> searchshow = TraktAPI.SearchShows("eureka");
IEnumerable<TraktMovie> recmovies = TraktAPI.GetRecommendedMovies();
IEnumerable<TraktMovie> tronrelated = TraktAPI.GetRelatedMovies("tt0084827");
IEnumerable<TraktUserProfile> newfriend = TraktAPI.SearchForFriends("edalex");
How to use TMDB provider from Moving Pictures:
C#:
using MediaPortal.Plugins.MovingPictures.DataProviders.TMDbAPI;
...
MovieSearch mymovie = TheMovieDbAPI.SearchMovies("Tron");
Get Series List from MP-TVSeries:
C#:
using WindowPlugins.GUITVSeries;
...
List<DBOnlineSeries> myseries = DBOnlineSeries.getAllSeries();
foreach (DBOnlineSeries tvshow in myseries)
{
DBSeries mytv = Helper.getCorrespondingSeries(tvshow[DBOnlineSeries.cID]);
if (mytv != null)
{
string ishidden = mytv[DBSeries.cHidden];
if (ishidden != "1")
{
}
}
}
1) Choose of existing dialog to modify it. https://github.com/MediaPortal/MediaPortal-1/tree/master/mediaportal/Dialogs/Dialogs
2) Create your own dialog by overriding one of them
Examples:
https://code.google.com/p/mediaport...k/LogoManager/LogoManager/GUIDIalogPreview.cs
https://code.google.com/p/mediaport...LogoManager/LogoManager/GUICheckListDialog.cs
https://code.google.com/p/moving-pictures/source/browse/trunk/Cornerstone.MP/GUIPinCodeDialog.cs
https://code.google.com/p/moving-pictures/source/browse/trunk/Cornerstone.MP/GUIGeneralRating.cs
https://code.google.com/p/mptvseries/source/browse/trunk/MP-TVSeries/GUIUserRating.cs
https://code.google.com/p/mptvseries/source/browse/trunk/MP-TVSeries/GUIPinCode.cs
3) Create skin files for your new dialog
Take skin file of Dialog you overrided and modify it for your needs. Change Windowd ID, add new control etc.
Skin files for standart skins (better start with supporting them) located here:
https://github.com/MediaPortal/MediaPortal-1/tree/master/mediaportal/MediaPortal.Base/skin/
4) Now you can use custom dialog just as like as standart one
Code:
GUICheckListDialog dlg = (GUICheckListDialog)GUIWindowManager.GetWindow(GUICheckListDialog.ID);
if (dlg == null)
return;
dlg.Reset();
dlg.SetHeading(...);
dlg.Add(...);
dlg.Add(...);
}
dlg.DoModal(GUIWindowManager.ActiveWindow);
1) Create your control's code overridingone of existing controls or GUIControl class itself
Examples:
https://github.com/MediaPortal/Medi...portal/WindowPlugins/GUISudoku/CellControl.cs
https://github.com/MediaPortal/Medi...al/WindowPlugins/GUITetris/MyTetrisControl.cs
2) Register your custom control in Init:
C#:
GUIControlFactory.RegisterControl("cell", typeof (CellControl));
If you would like to continue my efforts, please, share your code samples!
Many thanks!
Last edited: