Exemple #1
0
        public bool LoadPostProcessing(IGraphBuilder graphBuilder)
        {
            //LoadSettings();

            using (Settings xmlreader = new MPSettings())
            {
                audiodelayInterval = xmlreader.GetValueAsInt("FFDShow", "audiodelayInterval", 50);
            }

            IBaseFilter baseFilter = null;

            // No Postprocessing for FFDShow DXVA decoder
            DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);
            }
            if (baseFilter == null)
            {
                return(false);
            }
            ffdshowAPI        = new FFDShowAPI((object)baseFilter);
            hasPostProcessing = true;
            return(true);
        }
        /// <summary>
        /// Rewind through FFDShow
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FRewindButton_Click(object sender, EventArgs e)
        {
            using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
            {
                if (!ffdshowAPI.checkFFDShowActive())
                {
                    return;
                }
                int speed = ffdshowAPI.getFastForwardSpeed();
                switch (speed)
                {
                case 0:
                    speed = -6; break;

                case -6:
                    speed = -40; break;

                case -40:
                    speed = -240; break;

                default:
                    speed = 0; break;
                }
                ffdshowAPI.FastForward(speed);
            }
        }
    public static void EnableFFDShowSubtitles(IGraphBuilder graphBuilder)
    {
      // no instance of engine yet created or no ffdshow api, try to find it
      IBaseFilter baseFilter = null;
      DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
      if (baseFilter == null)
        DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoDXVAGuid, out baseFilter);
      if (baseFilter == null)
        DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);

      if (baseFilter != null)
      {
        IffdshowDec ffdshowDec = baseFilter as IffdshowDec;
        if (ffdshowDec != null)
        {
          // use a temporary instance of the API, as it is only used here, to disable subs
          FFDShowAPI tempffdshowAPI = new FFDShowAPI((object)baseFilter);
          tempffdshowAPI.DoShowSubtitles = true;
          Log.Info("FFDshow interfaces found -> Subtitles disabled");
          tempffdshowAPI.Dispose();
        }
        else
        {
          DirectShowUtil.ReleaseComObject(baseFilter);
        }
      }
    } 
Exemple #4
0
        public static void EnableFFDShowSubtitles(IGraphBuilder graphBuilder)
        {
            // no instance of engine yet created or no ffdshow api, try to find it
            IBaseFilter baseFilter = null;

            DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoDXVAGuid, out baseFilter);
            }
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);
            }

            if (baseFilter != null)
            {
                IffdshowDec ffdshowDec = baseFilter as IffdshowDec;
                if (ffdshowDec != null)
                {
                    // use a temporary instance of the API, as it is only used here, to disable subs
                    FFDShowAPI tempffdshowAPI = new FFDShowAPI((object)baseFilter);
                    tempffdshowAPI.DoShowSubtitles = true;
                    Log.Info("FFDshow interfaces found -> Subtitles disabled");
                    tempffdshowAPI.Dispose();
                }
                else
                {
                    DirectShowUtil.ReleaseComObject(baseFilter);
                }
            }
        }
 /// <summary>
 /// Sends a string to FFDShow OSD to be displayed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OSD_TextChanged(object sender, EventArgs e)
 {
     if (ffdshowAPI == null)
     {
         ffdshowAPI = new FFDShowAPI();
     }
     if (!ffdshowAPI.checkFFDShowActive())
     {
         return;
     }
     ffdshowAPI.displayOSDMessage(textBox1.Text);
 }
 /// <summary>
 /// Sets the FFDShow OSD position
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OSDX_ValueChanged(object sender, EventArgs e)
 {
     if (ffdshowAPI == null)
     {
         ffdshowAPI = new FFDShowAPI();
     }
     if (!ffdshowAPI.checkFFDShowActive())
     {
         return;
     }
     OSDX = trackBar1.Value;
     ffdshowAPI.setOSDPosition(OSDX, OSDY);
 }
        /// <summary>
        /// Retrieves audio and subtitle streams through FFDShow
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void getFFDShowStreams_Click(object sender, EventArgs e)
        {
            this.audioStreamlistBox.ItemCheck    -= new System.Windows.Forms.ItemCheckEventHandler(this.audioStreamlistBox_ItemCheck);
            this.subtitleStreamlistBox.ItemCheck -= new System.Windows.Forms.ItemCheckEventHandler(this.subtitleStreamlistBox_ItemCheck);
            audioStreamlistBox.Items.Clear();
            subtitleStreamlistBox.Items.Clear();
            using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
            {
                if (!ffdshowAPI.checkFFDShowActive())
                {
                    return;
                }
                SortedDictionary <int, FFDShowAPI.Stream> audioStreams    = ffdshowAPI.AudioStreams;
                SortedDictionary <int, FFDShowAPI.Stream> subtitleStreams = ffdshowAPI.SubtitleStreams;

                int currentAudioStream    = ffdshowAPI.AudioStream;
                int currentSubtitleStream = ffdshowAPI.SubtitleStream;

                foreach (KeyValuePair <int, FFDShowAPI.Stream> stream in audioStreams)
                {
                    NewCheckboxListItem chk = new NewCheckboxListItem();
                    chk.Text = stream.Value.name + "(" + stream.Value.languageName + ")";
                    chk.Tag  = stream.Key;
                    audioStreamlistBox.Items.Add(chk);
                    if (stream.Key == currentAudioStream)
                    {
                        audioStreamlistBox.SetItemChecked(audioStreamlistBox.Items.Count - 1, true);
                    }
                }

                foreach (KeyValuePair <int, FFDShowAPI.Stream> stream in subtitleStreams)
                {
                    NewCheckboxListItem chk = new NewCheckboxListItem();
                    chk.Text = stream.Value.name + "(" + stream.Value.languageName + ")";
                    chk.Tag  = stream.Key;
                    subtitleStreamlistBox.Items.Add(chk);
                    if (stream.Key == currentSubtitleStream)
                    {
                        subtitleStreamlistBox.SetItemChecked(subtitleStreamlistBox.Items.Count - 1, true);
                    }
                }
                subtitleStreamlistBox.Refresh();
                audioStreamlistBox.Refresh();
                tabControl1.SelectedTab               = tabPage3;
                this.audioStreamlistBox.ItemCheck    += new System.Windows.Forms.ItemCheckEventHandler(this.audioStreamlistBox_ItemCheck);
                this.subtitleStreamlistBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.subtitleStreamlistBox_ItemCheck);
            }
        }
        /// <summary>
        /// Switch of subtitle stream
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void subtitleStreamlistBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            NewCheckboxListItem item = (NewCheckboxListItem)subtitleStreamlistBox.SelectedItem;
            int streamNb             = (int)item.Tag;

            using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
            {
                if (!ffdshowAPI.checkFFDShowActive())
                {
                    return;
                }
                SortedDictionary <int, FFDShowAPI.Stream> subtitleStreams = ffdshowAPI.SubtitleStreams;
                ffdshowAPI.SubtitleStream = streamNb;
                getFFDShowStreams_Click(null, null);
            }
        }
 /// <summary>
 /// List external subtitle files
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void subtitleFiles_Click(object sender, EventArgs e)
 {
     using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
     {
         if (!ffdshowAPI.checkFFDShowActive())
         {
             return;
         }
         string   text = "Subtitle files :\nCurrent :" + ffdshowAPI.CurrentSubtitleFile + "\n";
         string[] subs = ffdshowAPI.SubtitleFiles;
         for (int i = 0; i < subs.Length; i++)
         {
             text += i + " : " + subs[i] + "\n";
         }
         MessageBox.Show(text);
     }
 }
 /// <summary>
 /// Sends an integer parameter to FFDShow (advanced users)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ffdshowParamButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
         {
             if (!ffdshowAPI.checkFFDShowActive())
             {
                 return;
             }
             ffdshowAPI.setIntParam((FFDShowConstants.FFDShowDataId) int.Parse(ffdshowParamBox.Text),
                                    int.Parse(ffdshowParamValueBox.Text));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace);
     }
 }
 /// <summary>
 /// Play/Pause
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void playButton_Click(object sender, EventArgs e)
 {
     using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
     {
         if (!ffdshowAPI.checkFFDShowActive())
         {
             return;
         }
         if (ffdshowAPI.getFastForwardSpeed() != 0)
         {
             ffdshowAPI.StopFastForward();
             return;
         }
         if (ffdshowAPI.getState() == FFDShowAPI.PlayState.PlayState || ffdshowAPI.getState() == FFDShowAPI.PlayState.FastForwardRewind)
         {
             ffdshowAPI.pauseVideo();
         }
         else
         {
             ffdshowAPI.startVideo();
         }
     }
 }
 /// <summary>
 /// Play/Pause
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void playButton_Click(object sender, EventArgs e)
 {
     using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
     {
         if (!ffdshowAPI.checkFFDShowActive()) return;
         if (ffdshowAPI.getFastForwardSpeed() != 0)
         {
             ffdshowAPI.StopFastForward();
             return;
         }
         if (ffdshowAPI.getState() == FFDShowAPI.PlayState.PlayState || ffdshowAPI.getState() == FFDShowAPI.PlayState.FastForwardRewind)
             ffdshowAPI.pauseVideo();
         else
             ffdshowAPI.startVideo();
     }
 }
 /// <summary>
 /// Sends a string to FFDShow OSD to be displayed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OSD_TextChanged(object sender, EventArgs e)
 {
     if (ffdshowAPI == null)
         ffdshowAPI = new FFDShowAPI();
     if (!ffdshowAPI.checkFFDShowActive()) return;
     ffdshowAPI.displayOSDMessage(textBox1.Text);
 }
        private void OSDY_ValueChanged(object sender, EventArgs e)
        {
            if (ffdshowAPI == null)
                ffdshowAPI = new FFDShowAPI();
            if (!ffdshowAPI.checkFFDShowActive()) return;

            OSDX = trackBar2.Value;
            ffdshowAPI.setOSDPosition(OSDX, OSDY);
        }
    public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
    {
      LoadSettings();

      //remove DirectVobSub
      DirectVobSubUtil.RemoveFromGraph(graphBuilder);
      {
        //remove InternalScriptRenderer as it takes subtitle pin
        IBaseFilter isr = null;
        DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
        if (isr != null)
        {
          graphBuilder.RemoveFilter(isr);
          DirectShowUtil.ReleaseComObject(isr);
        }
      }
      // Window size
      //Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);
      /*List<FFDShowAPI.FFDShowInstance> ffdshowInstance = FFDShowAPI.getFFDShowInstances();
      FFDShowAPI.FFDShowAPI api = new FFDShowAPI();*/


      IBaseFilter baseFilter = null;
      DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
      if (baseFilter == null)
        DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoDXVAGuid, out baseFilter);
      if (baseFilter == null)
        DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);
      if (baseFilter == null)
        return false;

      ffdshowAPI = new FFDShowAPI((object)baseFilter);

      IffdshowDec ffdshowDec = baseFilter as IffdshowDec;
      if (ffdshowDec == null)
      {
        Log.Error("FFdshow interfaces not found. Try to update FFDShow");
      }
      else
        Log.Info("FFdshow interfaces found");
      if (selectionOff)
      {
        Enable = false;
      }
      else
      {
        Enable = autoShow;
      }
      return true;
    }
 /// <summary>
 /// List external subtitle files
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void subtitleFiles_Click(object sender, EventArgs e)
 {
     using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
     {
         if (!ffdshowAPI.checkFFDShowActive()) return;
         string text = "Subtitle files :\nCurrent :" + ffdshowAPI.CurrentSubtitleFile + "\n";
         string[] subs = ffdshowAPI.SubtitleFiles;
         for (int i = 0; i < subs.Length; i++)
         {
             text += i + " : " + subs[i] + "\n";
         }
         MessageBox.Show(text);
     }
 }
 /// <summary>
 /// Switch of audio stream
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void audioStreamlistBox_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     NewCheckboxListItem item =  (NewCheckboxListItem) audioStreamlistBox.SelectedItem;
     int streamNb = (int)item.Tag;
     using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
     {
         if (!ffdshowAPI.checkFFDShowActive()) return;
         SortedDictionary<int, FFDShowAPI.Stream> audioStreams = ffdshowAPI.AudioStreams;
         ffdshowAPI.AudioStream = streamNb;
         getFFDShowStreams_Click(null, null);
     }
 }
 /// <summary>
 /// Sends an integer parameter to FFDShow (advanced users)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ffdshowParamButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
         {
             if (!ffdshowAPI.checkFFDShowActive()) return;
             ffdshowAPI.setIntParam((FFDShowConstants.FFDShowDataId)int.Parse(ffdshowParamBox.Text),
             int.Parse(ffdshowParamValueBox.Text));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace);
     }
 }
    public bool LoadPostProcessing(IGraphBuilder graphBuilder)
    {
      //LoadSettings();

      using (Settings xmlreader = new MPSettings())
      {
        audiodelayInterval = xmlreader.GetValueAsInt("FFDShow", "audiodelayInterval", 50);
      }

      IBaseFilter baseFilter = null;
      // No Postprocessing for FFDShow DXVA decoder
      DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
      if (baseFilter == null)
        DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);
      if (baseFilter == null) return false;
      ffdshowAPI = new FFDShowAPI((object)baseFilter);
      hasPostProcessing = true;
      return true;
    }
        /// <summary>
        /// Loads FFDShowAPI. First step to perform
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FFDShow_click(object sender, EventArgs e)
        {
            /* FFDShowAPI can be initialiazed in several ways :
             * If no parameters are given, FFDShowAPI will take for the first instance found
             * Otherwise if known the filename of the media beeing played can be passed to narrow the search
             **/

            // Method 1 : pick the first one we find
            ffdshowAPI = new FFDShowAPI();

            // Method 2 (commented) : retrieve all the running instances and pick the one you want
            /*
            List<FFDShowAPI.FFDShowInstance> ffdshowInstances =  FFDShowAPI.getFFDShowInstances();
            for (int i=0;i<ffdshowInstances.Count;i++)
            {
                string fileName = ffdshowInstances[i].fileName; // Is this the one ?
                ffdshowAPI = new FFDShowAPI(ffdshowInstances[i].handle);
                break;
            }
            */

            // Method 3 (commented) retrieve the instance corresponding to the file
            /*
            string fileNameToLookFor = "sampleVideo.avi";
            ffdshowAPI = new FFDShowAPI(fileNameToLookFor, FFDShowAPI.FileNameMode.FileName);
            */

            // Check wether an existing instance is running (and corresponding to the constructor parameters, here any instance)
            bool isFFDShowActive = ffdshowAPI.checkFFDShowActive();

            if (isFFDShowActive)
                this.Text = "FFDShow has been found (" + ffdshowAPI.FFDShowAPIRemote + " handle used)";
            else
            {
                this.Text = "FFDShow has not been found (" + ffdshowAPI.FFDShowAPIRemote + " handle used)";
                return;
            }

            // Request a string parameter
            MessageBox.Show("Filename played : " + ffdshowAPI.getFileName());

            string streamsStr = "Audio streams :\n";
            try
            {
                SortedDictionary<int, FFDShowAPI.Stream> audioStreams = ffdshowAPI.AudioStreams;
                int currentStream = ffdshowAPI.AudioStream;
                foreach (KeyValuePair<int, FFDShowAPI.Stream> stream in audioStreams)
                {
                    streamsStr += stream.Key + " : " + stream.Value.name + "(" + stream.Value.languageName + ")";
                    if (currentStream == stream.Key)
                        streamsStr += " Active";
                    streamsStr += "\n";
                }
                MessageBox.Show(streamsStr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while retrieving audio streams : " + ex.Message + "\n" + ex.StackTrace.ToString());
            }

            streamsStr = "Subtitle streams :\n";
            try
            {
                SortedDictionary<int, FFDShowAPI.Stream> subtitleStreams = ffdshowAPI.SubtitleStreams;
                int currentStream = ffdshowAPI.SubtitleStream;
                foreach (KeyValuePair<int, FFDShowAPI.Stream> stream in subtitleStreams)
                {
                    streamsStr += stream.Key + " : " + stream.Value.name + "(" + stream.Value.languageName + ")";
                    if (currentStream == stream.Key)
                        streamsStr += " Active";
                    streamsStr += "\n";
                }
                MessageBox.Show(streamsStr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while retrieving subtitle streams : " + ex.Message + "\n" + ex.StackTrace.ToString());
            }

            string chaptersStr = "Chapters :\n";
            try
            {
                Dictionary<int, string> chaptersList = ffdshowAPI.ChaptersList;
                foreach (KeyValuePair<int, string> kvp in chaptersList)
                {
                    chaptersStr += kvp.Key + " : " + kvp.Value + "\n";
                }
                MessageBox.Show(chaptersStr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while retrieving chapters : " + ex.Message + "\n" + ex.StackTrace.ToString());
            }
        }
Exemple #21
0
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            LoadSettings();

            //remove DirectVobSub
            DirectVobSubUtil.RemoveFromGraph(graphBuilder);
            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }
            // Window size
            //Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);

            /*List<FFDShowAPI.FFDShowInstance> ffdshowInstance = FFDShowAPI.getFFDShowInstances();
             * FFDShowAPI.FFDShowAPI api = new FFDShowAPI();*/


            IBaseFilter baseFilter = null;

            DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoGuid, out baseFilter);
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoDXVAGuid, out baseFilter);
            }
            if (baseFilter == null)
            {
                DirectShowUtil.FindFilterByClassID(graphBuilder, FFDShowAPI.FFDShowVideoRawGuid, out baseFilter);
            }
            if (baseFilter == null)
            {
                return(false);
            }

            ffdshowAPI = new FFDShowAPI((object)baseFilter);

            IffdshowDec ffdshowDec = baseFilter as IffdshowDec;

            if (ffdshowDec == null)
            {
                Log.Error("FFdshow interfaces not found. Try to update FFDShow");
            }
            else
            {
                Log.Info("FFdshow interfaces found");
            }
            if (selectionOff)
            {
                Enable = false;
            }
            else
            {
                Enable = autoShow;
            }
            return(true);
        }
 /// <summary>
 /// Rewind through FFDShow
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FRewindButton_Click(object sender, EventArgs e)
 {
     using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
     {
         if (!ffdshowAPI.checkFFDShowActive()) return;
         int speed = ffdshowAPI.getFastForwardSpeed();
         switch (speed)
         {
             case 0:
                 speed = -6; break;
             case -6:
                 speed = -40; break;
             case -40:
                 speed = -240; break;
             default:
                 speed = 0; break;
         }
         ffdshowAPI.FastForward(speed);
     }
 }
        /// <summary>
        /// Retrieves audio and subtitle streams through FFDShow
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void getFFDShowStreams_Click(object sender, EventArgs e)
        {
            this.audioStreamlistBox.ItemCheck -= new System.Windows.Forms.ItemCheckEventHandler(this.audioStreamlistBox_ItemCheck);
            this.subtitleStreamlistBox.ItemCheck -= new System.Windows.Forms.ItemCheckEventHandler(this.subtitleStreamlistBox_ItemCheck);
            audioStreamlistBox.Items.Clear();
            subtitleStreamlistBox.Items.Clear();
            using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
            {
                if (!ffdshowAPI.checkFFDShowActive()) return;
                SortedDictionary<int, FFDShowAPI.Stream> audioStreams = ffdshowAPI.AudioStreams;
                SortedDictionary<int, FFDShowAPI.Stream> subtitleStreams = ffdshowAPI.SubtitleStreams;

                int currentAudioStream = ffdshowAPI.AudioStream;
                int currentSubtitleStream = ffdshowAPI.SubtitleStream;

                foreach (KeyValuePair<int,FFDShowAPI.Stream> stream in audioStreams)
                {
                    NewCheckboxListItem chk = new NewCheckboxListItem();
                    chk.Text = stream.Value.name + "(" + stream.Value.languageName + ")";
                    chk.Tag = stream.Key;
                    audioStreamlistBox.Items.Add(chk);
                    if (stream.Key == currentAudioStream)
                    {
                        audioStreamlistBox.SetItemChecked(audioStreamlistBox.Items.Count - 1, true);
                    }
                }

                foreach (KeyValuePair<int, FFDShowAPI.Stream> stream in subtitleStreams)
                {
                    NewCheckboxListItem chk = new NewCheckboxListItem();
                    chk.Text = stream.Value.name + "(" + stream.Value.languageName + ")";
                    chk.Tag = stream.Key;
                    subtitleStreamlistBox.Items.Add(chk);
                    if (stream.Key == currentSubtitleStream)
                    {
                        subtitleStreamlistBox.SetItemChecked(subtitleStreamlistBox.Items.Count-1, true);
                    }
                }
                subtitleStreamlistBox.Refresh();
                audioStreamlistBox.Refresh();
                tabControl1.SelectedTab = tabPage3;
                this.audioStreamlistBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.audioStreamlistBox_ItemCheck);
                this.subtitleStreamlistBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.subtitleStreamlistBox_ItemCheck);
            }
        }
        /// <summary>
        /// Loads FFDShowAPI. First step to perform
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FFDShow_click(object sender, EventArgs e)
        {
            /* FFDShowAPI can be initialiazed in several ways :
             * If no parameters are given, FFDShowAPI will take for the first instance found
             * Otherwise if known the filename of the media beeing played can be passed to narrow the search
             **/

            // Method 1 : pick the first one we find
            ffdshowAPI = new FFDShowAPI();

            // Method 2 (commented) : retrieve all the running instances and pick the one you want

            /*
             * List<FFDShowAPI.FFDShowInstance> ffdshowInstances =  FFDShowAPI.getFFDShowInstances();
             * for (int i=0;i<ffdshowInstances.Count;i++)
             * {
             *  string fileName = ffdshowInstances[i].fileName; // Is this the one ?
             *  ffdshowAPI = new FFDShowAPI(ffdshowInstances[i].handle);
             *  break;
             * }
             */

            // Method 3 (commented) retrieve the instance corresponding to the file

            /*
             * string fileNameToLookFor = "sampleVideo.avi";
             * ffdshowAPI = new FFDShowAPI(fileNameToLookFor, FFDShowAPI.FileNameMode.FileName);
             */

            // Check wether an existing instance is running (and corresponding to the constructor parameters, here any instance)
            bool isFFDShowActive = ffdshowAPI.checkFFDShowActive();


            if (isFFDShowActive)
            {
                this.Text = "FFDShow has been found (" + ffdshowAPI.FFDShowAPIRemote + " handle used)";
            }
            else
            {
                this.Text = "FFDShow has not been found (" + ffdshowAPI.FFDShowAPIRemote + " handle used)";
                return;
            }

            // Request a string parameter
            MessageBox.Show("Filename played : " + ffdshowAPI.getFileName());


            string streamsStr = "Audio streams :\n";

            try
            {
                SortedDictionary <int, FFDShowAPI.Stream> audioStreams = ffdshowAPI.AudioStreams;
                int currentStream = ffdshowAPI.AudioStream;
                foreach (KeyValuePair <int, FFDShowAPI.Stream> stream in audioStreams)
                {
                    streamsStr += stream.Key + " : " + stream.Value.name + "(" + stream.Value.languageName + ")";
                    if (currentStream == stream.Key)
                    {
                        streamsStr += " Active";
                    }
                    streamsStr += "\n";
                }
                MessageBox.Show(streamsStr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while retrieving audio streams : " + ex.Message + "\n" + ex.StackTrace.ToString());
            }

            streamsStr = "Subtitle streams :\n";
            try
            {
                SortedDictionary <int, FFDShowAPI.Stream> subtitleStreams = ffdshowAPI.SubtitleStreams;
                int currentStream = ffdshowAPI.SubtitleStream;
                foreach (KeyValuePair <int, FFDShowAPI.Stream> stream in subtitleStreams)
                {
                    streamsStr += stream.Key + " : " + stream.Value.name + "(" + stream.Value.languageName + ")";
                    if (currentStream == stream.Key)
                    {
                        streamsStr += " Active";
                    }
                    streamsStr += "\n";
                }
                MessageBox.Show(streamsStr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while retrieving subtitle streams : " + ex.Message + "\n" + ex.StackTrace.ToString());
            }

            string chaptersStr = "Chapters :\n";

            try
            {
                Dictionary <int, string> chaptersList = ffdshowAPI.ChaptersList;
                foreach (KeyValuePair <int, string> kvp in chaptersList)
                {
                    chaptersStr += kvp.Key + " : " + kvp.Value + "\n";
                }
                MessageBox.Show(chaptersStr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while retrieving chapters : " + ex.Message + "\n" + ex.StackTrace.ToString());
            }
        }