internal void SetPosition(MusicTrack track, int position)
 {
     SetTrack(track);
     if (IsPaused)
     {
         pausePosition = Math.Min(position, CurrentLengthInSamples);
     }
     else if (IsPlaying)
     {
         PlayAtPoint(PlayingTrack.SamplesToSeconds(position), numberOfLoopsLeft);
     }
 }
        /// <summary>
        /// Plays the current track starting at the given play position.
        /// </summary>
        /// <param name="samplePosition">The play position, in samples</param>
        /// <param name="numberOfLoops">The number of times to loop the track. Set to 0 for endless play.</param>
        private void PlayAtPosition(int samplePosition, int numberOfLoops)
        {
            if (PlayingTrack != null)
            {
                if (samplePosition <= IntroSource.clip.samples)
                {
                    IntroSource.timeSamples = samplePosition;
                    LoopSource.timeSamples  = 0;
                    IntroSource.Play();
                    LoopSource.PlayDelayed(PlayingTrack.SamplesToSeconds(IntroSource.clip.samples - samplePosition));
                }
                else
                {
                    LoopSource.timeSamples = samplePosition - IntroSource.clip.samples;
                    LoopSource.Play();
                }

                numberOfLoopsLeft = numberOfLoops;
                InvokeRepeating("OnTrackEndOrLoop",
                                PlayingTrack.SamplesToSeconds(PlayingTrack.LengthInSamples - samplePosition),
                                PlayingTrack.SamplesToSeconds(PlayingTrack.LoopLength));
            }
        }