private void Template_Loaded(object sender, API.LoadedEventArgs e)
 {
     try
     {
         Initialize();
     }
     catch (Exception ex) //Always catch exceptions in template calls. If not the template might restart in a new process.
     {
         m_Template.Debug(API.DebugLevel.High, API.DebugCategory.Error, "Failed to initialize " + ex.Message);
     }
 }
        private void Template_Loaded(object sender, API.LoadedEventArgs e)
        {
            try
            {
                m_Template.SetState(API.State.Initializing, "Initializing MediaTemplate");

                Initialize();
            }
            catch (Exception ex) //Always catch exceptions in template calls. If not the template might restart in a new process.
            {
                m_Template.Debug(API.DebugLevel.High, API.DebugCategory.Error, "Failed to initialize" + Environment.NewLine + ex.ToString());
                m_Template.MediaEnded();
            }
        }