/// <summary>
    /// Gets chapters from the given BDTitleInfo object
    /// </summary>
    /// <param name="titleInfo">BDTitleInfo object</param>
    /// <returns>chapters as an array consisting of the start time in seconds</returns>
    protected virtual double[] GetChapters(BDTitleInfo titleInfo)
    {
      double[] chapters = new double[titleInfo.chapter_count];
            
      if (chapters.Length > 2) // only two chapters means beginning and end - no real chapters
      {
        for (int i = 0; i < chapters.Length; i++)
        {
          unsafe
          {
            double s = titleInfo.chapters[i].start / 90000;
            chapters[i] = s;
            TimeSpan ts = TimeSpan.FromSeconds(s);
            Log.Debug("BDPlayer: Chapter info #{0}: start time: {1}", titleInfo.chapters[i].idx, String.Format("{0:D2}:{1:D2}:{2:D2}", ts.Hours, ts.Minutes, ts.Seconds));
          }
        }
        if (chapters[chapters.Length - 1] < 300) // 5 min sanity check
          chapters = null;
      }
      else
        chapters = null;

      return chapters;
    }
      public TitleInfo(IBDReader reader, int index)
      {
        _reader = reader;
        _nativeTitle = new BDTitleInfo();

        try
        {
          _nativePtr = reader.GetTitleInfo(index);
          _nativeTitle = (BDTitleInfo) Marshal.PtrToStructure(_nativePtr, typeof (BDTitleInfo));
        }
        catch
        {
          Log.Error("BDPlayer: TitleInfo({0}) construction failed.", index);
        }
      }
    /// <summary>
    /// Gets the title info for the specified index
    /// </summary>
    /// <param name="reader">IBDReader object</param>
    /// <param name="index">index of the title</param>
    /// <returns></returns>
    protected virtual BDTitleInfo GetTitleInfo(IBDReader reader, int index)
    {
      BDTitleInfo titleInfo = new BDTitleInfo();
      IntPtr ptr = IntPtr.Zero;
      try
      {
        ptr = reader.GetTitleInfo(index);
        titleInfo = (BDTitleInfo)Marshal.PtrToStructure(ptr, typeof(BDTitleInfo));
      }
      catch
      {
        Log.Error("BDPlayer: GetTitleInfo({0}) failed.", index);
      }
      finally
      {
        if (ptr != IntPtr.Zero)
        {
          reader.FreeTitleInfo(ptr);
        }
      }

      return titleInfo;
    }