MediaPortal.MusicPlayer.BASS.BassAudioEngine.HandleCueFile C# (CSharp) Method

HandleCueFile() private method

Parse the Cue file. Return a Fake Cue track and adjest the playback position within the file.
private HandleCueFile ( string &filePath, bool endOnly ) : bool
filePath string
endOnly bool
return bool
    private bool HandleCueFile(ref string filePath, bool endOnly)
    {
      try
      {
        _cueTrackStartPos = 0;
        _cueTrackEndPos = 0;
        if (CueUtil.isCueFakeTrackFile(filePath))
        {
          Log.Debug("BASS: Playing CUE Track: {0}", filePath);
          _currentCueFakeTrackFileName = filePath;
          CueFakeTrack cueFakeTrack = CueUtil.parseCueFakeTrackFileName(filePath);
          if (!cueFakeTrack.CueFileName.Equals(_currentCueFileName))
          {
            // New CUE. Update chached cue.
            _currentCueSheet = new CueSheet(cueFakeTrack.CueFileName);
            _currentCueFileName = cueFakeTrack.CueFileName;
          }

          // Get track start position
          Track track = _currentCueSheet.Tracks[cueFakeTrack.TrackNumber - _currentCueSheet.Tracks[0].TrackNumber];
          Index index = track.Indices[0];
          _cueTrackStartPos = CueUtil.cueIndexToFloatTime(index);

          // If single audio file and is not last track, set track end position.
          if (_currentCueSheet.Tracks[_currentCueSheet.Tracks.Length - 1].TrackNumber > track.TrackNumber)
          {
            Track nextTrack =
              _currentCueSheet.Tracks[cueFakeTrack.TrackNumber - _currentCueSheet.Tracks[0].TrackNumber + 1];
            if (nextTrack.DataFile.Filename.Equals(track.DataFile.Filename))
            {
              Index nindex = nextTrack.Indices[0];
              _cueTrackEndPos = CueUtil.cueIndexToFloatTime(nindex);
            }
          }

          // If audio file is not changed, just set new start/end position and reset pause
          string audioFilePath = System.IO.Path.GetDirectoryName(cueFakeTrack.CueFileName) +
                                 System.IO.Path.DirectorySeparatorChar + track.DataFile.Filename;
          if (audioFilePath.CompareTo(_filePath) == 0)
          {
            SetCueTrackEndPosition(GetCurrentStream(), endOnly);
            return true;
          }
          filePath = audioFilePath;
        }
        else
        {
          _currentCueFileName = null;
          _currentCueSheet = null;
        }
      }
      catch (System.IO.FileNotFoundException)
      {
        // The CUE File may have been moved
        Log.Error("BASS: Cue File cannot be found at the expected location. aborting playback.");
      }
      return false;
    }