コード例 #1
0
        private void _Template_TemplateCommand(object sender, API.TemplateCommandEventArgs e)
        {
            if (e.TemplateCommand.Key == "CommandForMe")
            {
                string value = e.TemplateCommand.Value;

                //Do something

                e.TemplateCommand.ReturnResult("Some result to caller");
            }
        }
コード例 #2
0
        private void TemplateDataSet_TemplateDataSetChanged2(object sender, API.TemplateDataSetEventArgs e)
        {
            string masterIP = e.TemplateDataSet.GetTemplateDataSetItemAsText("MasterIP");

            if (_WarpSpace == null)
            {
                //Assume only one template per player
                _WarpSpace = _Template.GetWarpSpace("MyWarpSpaceChannel", masterIP);
                _WarpSpace.PeerRegistered += _WarpSpace_PeerRegistered;
                _WarpSpace.MessageReceived += _WarpSpace_MessageReceived;
            }
        }
コード例 #3
0
        private void Template_Loaded(object sender, API.LoadedEventArgs e)
        {
            try
            {
                m_Template.Debug(API.DebugLevel.High, API.DebugCategory.Information, "Mono template loaded");

                m_Template.SetState(API.State.Initializing, "Initializing MonoTemplate");

                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();
            }
        }
コード例 #4
0
        //private void Template_PreviewRequested(object sender, API.PreviewRequestEventArgs e)
        //{
        //    try
        //    {
        //        GeneratePreview();
        //        e.PreviewRequestFinished = true;
        //    }
        //    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 generate preview" + Environment.NewLine + ex.ToString());
        //        //No need to exit
        //    }
        //}
        private void TemplateDataSet_TemplateDataSetChanged(object sender, API.TemplateDataSetEventArgs e)
        {
            try
            {
                CheckDataSetChange(e.TemplateDataSet);

                //Make a call
                int files = m_Template.GetFiles().Count();
                m_Template.Debug(API.DebugLevel.High, API.DebugCategory.Information, "Player has " + files + " files available");
                Console.WriteLine("Player has " + files + " files available");
            }
            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 change dataset" + Environment.NewLine + ex.ToString());
                m_Template.MediaEnded();
            }
        }
コード例 #5
0
        private void CheckDataSetChange(API.ITemplateDataSet templateDataSet)
        {
            API.ITemplateFile templateFile = templateDataSet.GetTemplateDataSetItemAsFile(MediaFileKey);
            if (templateFile != null)
            {
                if (m_TemplateFile == null || !m_TemplateFile.FileName.Equals(templateFile.FileName, StringComparison.OrdinalIgnoreCase))
                {
                    //Media filename has changed
                    m_Template.Debug(API.DebugLevel.Low, API.DebugCategory.Information, "Media file changed to " + templateFile.FileName);

                    if (m_PlayRequested)
                    {
                        m_Template.Debug(API.DebugLevel.Low, API.DebugCategory.Information, "Restarting media");

                        //Restart play of new file
                        StopPlay();
                        ReleaseResources();
                        PrepareResources();
                        StartPlay(null, 0, 0);
                    }
                }
            }
        }
コード例 #6
0
 private void Template_Playing(object sender, API.PlayingEventArgs e)
 {
     try
     {
         CheckExecuteOnGUIThread(() => CheckParameters());
     }
     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 play " + Environment.NewLine + ex.Message);
     }
 }
コード例 #7
0
 private void m_TemplateFile_DownloadFileProgress(object sender, API.FileProgressEventArgs e)
 {
     if (e.State == API.TransferStatus.Aborted ||
         e.State == API.TransferStatus.Failed)
     {
         m_Template.SetState("Prepare", API.State.Error, "Download failed");
     }
     else if (e.State == API.TransferStatus.InProgress ||
         e.State == API.TransferStatus.Verifying)
     {
         m_Template.Debug(API.DebugLevel.Low, API.DebugCategory.Information, "Downloading file " + e.TemplateFile.Name + " " + e.State.ToString() + " " + e.Progress * 100 + " %");
     }
 }
コード例 #8
0
 private void Template_TemplateFileDeleted(object sender, API.TemplateFileEventArgs e)
 {
     m_Template.Debug(API.DebugLevel.High, API.DebugCategory.Information, "File deleted " + e.TemplateFile.Name);
     Console.WriteLine("File deleted " + e.TemplateFile.Name);
 }
コード例 #9
0
 private void Property1_TemplatePropertyChanged(object sender, API.TemplatePropertyEventArgs e)
 {
     try
     {
         CheckExecuteOnGUIThread(() => UpdateGUI());
     }
     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 on property changed" + ex.Message);
     }
 }
コード例 #10
0
 private void _WarpSpace_PeerRegistered(object sender, API.PeerRegisteredEventArgs e)
 {
     _Template.Debug(API.DebugLevel.Low, API.DebugCategory.Information, "New peer was registered from " + e.IP + " " + e.ID);
 }
コード例 #11
0
        private void _WarpSpace_MessageReceived(object sender, API.PeerMessageReceivedEventArgs e)
        {
            _Template.Debug(API.DebugLevel.Low, API.DebugCategory.Information, "WarpSpace message received from " + e.IP + " " + e.Id + " key: " + e.Key + " " + e.Value);

            e.Reply = "SomeReturnValue";
        }
コード例 #12
0
 private void Template_Stopped(object sender, API.StoppedEventArgs e)
 {
     try
     {
         CheckExecuteOnGUIThread(() => StopPlay());
     }
     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 stop" + Environment.NewLine + ex.ToString());
         m_Template.MediaEnded();
     }
 }
コード例 #13
0
 private void TemplateDataSet_TemplateDataSetChanged(API.TemplateDataSetEventArgs e)
 {
     try
     {
         CheckExecuteOnGUIThread(() => CheckDataSetChange(e.TemplateDataSet));
     }
     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 change dataset" + Environment.NewLine + ex.ToString());
         m_Template.MediaEnded();
     }
 }
コード例 #14
0
 private void m_TemplateFile_TemplateFileDeleted(object sender, API.TemplateFileEventArgs e)
 {
     if (e.TemplateFile.FileName == m_PlayingFilename)
     {
         StopPlay();
         ReleaseResources();
     }
 }
コード例 #15
0
 private void Template_Release(object sender, API.ReleaseEventArgs e)
 {
     try
     {
         ReleaseResources();
     }
     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 release resources" + Environment.NewLine + ex.ToString());
         m_Template.MediaEnded();
     }
 }
コード例 #16
0
 private void TemplateDataSet_TemplateDataSetChanged(API.TemplateDataSetEventArgs e)
 {
     try
     {
         CheckExecuteOnGUIThread(() => CheckParameters());
     }
     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 change dataset " + ex.Message);
     }
 }
コード例 #17
0
 private void Template_Stopping(object sender, API.StoppingEventArgs e)
 {
     try
     {
         StopPlay(e.Transition, e.Duration, e.Tuning);
     }
     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 stop" + Environment.NewLine + ex.ToString());
         m_Template.MediaEnded();
     }
 }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
 private void Template_Unload(object sender, API.UnloadEventArgs e)
 {
     try
     {
         Deinitialize();
     }
     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 unload" + Environment.NewLine + ex.ToString());
         m_Template.MediaEnded();
     }
 }
コード例 #20
0
 private void m_TemplateFile_DownloadFileFinished(object sender, API.TemplateFileEventArgs e)
 {
     m_Template.SetState("Prepare", API.State.OK, "Download done");
 }