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

SeekToTimePosition() public method

Seek to a specific position in the stream
public SeekToTimePosition ( int position ) : bool
position int
return bool
    public bool SeekToTimePosition(int position)
    {
      Log.Debug("BASS: SeekToTimePosition: {0} ", Convert.ToString(position));

      bool result = true;

      try
      {
        MusicStream stream = GetCurrentStream();

        if (stream.IsPlaying)
        {
          if (_currentCueSheet != null)
          {
            position += (int)_cueTrackStartPos;
          }

          bool isWASAPI = false;
          // For WASAPI output we need to Stop / Start for skipping to work
          if (BassWasapi.BASS_WASAPI_IsStarted())
          {
            isWASAPI = true;
            BassWasapi.BASS_WASAPI_Stop(true);
          }
          
          BassMix.BASS_Mixer_ChannelSetPosition(stream.BassStream, Bass.BASS_ChannelSeconds2Bytes(stream.BassStream, position));
          Bass.BASS_ChannelSetPosition(_mixer.BassStream, 0, BASSMode.BASS_POS_BYTES); // reset the mixer
          _mixer.SetSyncPos(stream, position);
          
          if (isWASAPI)
          {
            BassWasapi.BASS_WASAPI_Start();
          }
        }
      }

      catch
      {
        result = false;
      }

      return result;
    }