Seitenhierarchie

  Wiki Navigation

    Loading...


 Recently Updated


 Latest Releases

 MediaPortal 1.32
            Releasenews | Download
 MediaPortal 2.5
            Releasenews | Download


What APIs are supported for other plugins or applications ?

Background

To support other plugins and applications, My Films supports certain APIs for exchange of data.

Answer

My Films supports following APIs for load parameter, recently added movies, config, view and viewvalue info.

(Context MyFilmsPlugin.MyFilms.BaseMesFilms)

1. MediaPortal Load Parameters

config:<configname>|view:<viewname>|viewvalue:<viewvalue>|layout:<layoutID>|movieid:<movieid>|play:<bool>|search:<searchexpression>

  • config: Name of the My Films configuration - if you have multiple configurations created, you can select a specific one
  • view: Name of a view, e.g. "year", "category", "country"
  • viewvalue: preset Value for a view, e.g. "2011", "Germany"
  • layout: preset the layout (0 = listview, 1 = thumb view, etc.)
  • movieid: Id to jump to a selected movie
  • play: "true" when used with MovieID starts playback automatically
  • search: performs a global search with the searchexpression

Note: "config" can be used together with "view" and optionally "viewvalue" to select the config and the view.

Examples:

  • <hyperlinkParameter>view:year|viewvalue:2008</hyperlinkParameter>
    starts MyFilms with "current" configuration and a list of all movies from year 2008
  • <hyperlinkParameter>config:documentaries</hyperlinkParameter>
    starts MyFilms with "documentaries" configuration - no views set - so setup values used
  • <hyperlinkParameter>view:category</hyperlinkParameter>
    starts MyFilms with "current" configuration and the category list of all movies
  • <hyperlinkParameter>search:terminator</hyperlinkParameter>
    starts MyFilms with "current" configuration and performs a global search on 'terminator' resulting in a list of all results in all DB fields ("global search")
    This could be used e.g. in context skin buttons to launch a MyFilms search with the selecteditem from other places.
  • <hyperlinkParameter>layout:3</hyperlinkParameter>
    starts MyFilms with "current" configuration and sets layout to filmstrip
    possible values: 0, 1, 2, 3, 4 for ListView, SmallThumb, BigThumb, FilmStrip, CoverFlow

2. Get configurations and views

        /// <summary>
        /// returns an array of KeyValue ViewLists and name for each config
        /// .Name = config name
        /// .ViewList = List of KeyValues with view name and pretty name
        /// </summary>        
         public static ArrayList GetConfigViewLists()

3. Get possible view values

        /// <summary>
        /// returns a string List of available values for a given config & view
        /// use GetConfigViewLists() to get valid values for config and view
        /// returns <null> if no values can be evaluated - user should still be able to manually set a value for startparam
        /// </summary>        
         public static List<string> GetViewListValues(string config, string view)

4. Get 3 most recent movies

        /// <summary>
        /// returns the 3 most recent movies
        /// </summary>        
        public static List<MFMovie> GetMostRecent(MostRecentType type)

with type = MostRecentType.added

5. Get most recent movies with parameters

        /// <summary>
        /// returns the most recent movies based on conditions
        /// </summary>
        /// <param name="type">most recent type</param>
        /// <param name="days">number of days to look back in database</param>
        /// <param name="limit">number of results to return</param>        
         public static List<MFMovie> GetMostRecent(MostRecentType type, int days, int limit)

 

Note: You have to enable your config in MyFilms setup to answer to "recently added" requests. This setting is done "per config" - so you might enable it for your movies, but keep it disabled for private movies and documentaries.

6. How to implement editor support for My Films

You can integrate MyFilms settings in your BasicHome editor to provide customization options by using start parameters.

Code Snippets:

The following code gives a sample on how to handle the API and should be adapted for the use in your editor.

It populates the fields with valid data and creates the hyperlink parameters (startparams) based on the settings.

        private void btnLoadEditorValues_Click(object sender, EventArgs e)
        {
          tbEditorStartParamsOutput.Text = "";
          cbEditorConfigs.Items.Clear();
          cbEditorViews.Items.Clear();
          cbEditorViewValues.Items.Clear();
          cbEditorConfigs.Text = "";
          cbEditorViews.Text = "";
          cbEditorViewValues.Text = "";

          ArrayList MyFilmsEditor = BaseMesFilms.GetConfigViewLists();
          // cbEditorConfigs.Items.Add("");
          foreach (BaseMesFilms.MFConfig config in MyFilmsEditor)
          {
            cbEditorConfigs.Items.Add(config.Name);
          }
        }

        private void cbEditorConfigs_SelectedIndexChanged(object sender, EventArgs e)
        {
          ArrayList MyFilmsEditor = BaseMesFilms.GetConfigViewLists();
          tbEditorStartParamsOutput.Text = "";
          cbEditorViews.Items.Clear();
          cbEditorViewValues.Items.Clear();
          cbEditorViews.Text = "";
          cbEditorViewValues.Text = "";

          foreach (BaseMesFilms.MFConfig config in MyFilmsEditor)
          {
            if (config.Name == cbEditorConfigs.Text)
            {
              foreach (KeyValuePair<string, string> view in config.ViewList)
              {
                // key = viewname, value = translated viewname
                cbEditorViews.Items.Add(view.Value);
              }
            }
          }
        }

        private void cbEditorViews_SelectedIndexChanged(object sender, EventArgs e)
        {
          string viewCallName = "";
          tbEditorStartParamsOutput.Text = "";
          cbEditorViewValues.Items.Clear();
          cbEditorViewValues.Text = "";
          ArrayList MyFilmsEditor = BaseMesFilms.GetConfigViewLists();
          foreach (BaseMesFilms.MFConfig config in MyFilmsEditor)
          {
            if (config.Name == cbEditorConfigs.Text)
            {
              foreach (KeyValuePair<string, string> view in config.ViewList)
              {
                // key = viewname, value = translated viewname
                if (view.Value == cbEditorViews.Text)
                {
                  viewCallName = view.Key;
                }
              }
            }
          }

          if (!string.IsNullOrEmpty(cbEditorConfigs.Text) && !string.IsNullOrEmpty(viewCallName))
          {
            List<string> ViewValues = BaseMesFilms.GetViewListValues(cbEditorConfigs.Text, viewCallName);
            if (ViewValues != null)
            foreach (string value in ViewValues)
            {
              cbEditorViewValues.Items.Add(value);
            }
          }
        }

        private void cbEditorLayout_SelectedIndexChanged(object sender, EventArgs e)
        {
          if (cbEditorLayout.SelectedIndex < 0 || cbEditorLayout.SelectedIndex > 5)
            cbEditorLayout.SelectedIndex = 0;
          if (cbEditorLayout.SelectedIndex == 0)
            cbEditorLayout.Text = "";
        }

        private void btnSaveEditorStartParams_Click(object sender, EventArgs e)
        {
          string startParamOutput = "";
          ArrayList myFilmsEditor = BaseMesFilms.GetConfigViewLists();
          
          if (!string.IsNullOrEmpty(cbEditorConfigs.Text))
            startParamOutput += "config:" + cbEditorConfigs.Text;
          if (!string.IsNullOrEmpty(cbEditorViews.Text))
          {
            string viewCallName = "";
            if (!string.IsNullOrEmpty(startParamOutput)) startParamOutput += "|";
            foreach (BaseMesFilms.MFConfig config in myFilmsEditor)
            {
              if (config.Name == cbEditorConfigs.Text)
              {
                foreach (KeyValuePair<string, string> view in config.ViewList)
                {
                  if (view.Value == cbEditorViews.Text)
                    viewCallName = view.Key;
                }
              }
            }
            startParamOutput += "view:" + viewCallName;
          }
          if (!string.IsNullOrEmpty(cbEditorViewValues.Text))
          {
            if (!string.IsNullOrEmpty(startParamOutput)) startParamOutput += "|";
            startParamOutput += "viewvalue:" + cbEditorViewValues.Text;
          }
          if (!string.IsNullOrEmpty(cbEditorLayout.Text))
          {
            if (!string.IsNullOrEmpty(startParamOutput)) startParamOutput += "|";
            startParamOutput += "layout:" + cbEditorLayout.SelectedIndex;
          }
          if (!string.IsNullOrEmpty(tbEditorSearchExpression.Text))
          {
            if (!string.IsNullOrEmpty(startParamOutput)) startParamOutput += "|";
            startParamOutput += "search:" + tbEditorSearchExpression.Text;
          }
          tbEditorStartParamsOutput.Text = startParamOutput;
        }

 

   

 

This page has no comments.