Пример #1
0
    /// <summary>
    /// Play the previous song.
    /// </summary>
    void PlayPreviousSong()
    {
        _audioSource.Stop();
        _audioSource.timeSamples = 0;
        if (_currentSongIndex == 0)
        {
            _currentSongIndex = _files.Length - 1;
        }
        else
        {
            _currentSongIndex = _currentSongIndex < 0 ? _currentSongIndex = 0 : --_currentSongIndex;
        }

        _audioSource.clip = _clips[_currentSongIndex];

        _audioSource.Play();
        if (_songTitle != null)
        {
            SongTimer.Set(_songTitle, Path.GetFileNameWithoutExtension(_songsData[_currentSongIndex]._tempDir));
        }
        if (_songTime != null)
        {
            SongTimer.SetSongTime(_songTime, _audioSource.clip.length);
        }

        Debug.Log("Playing " + _songsData[_currentSongIndex]._tempDir);
    }
Пример #2
0
    /// <summary>
    /// Play the current song.
    /// </summary>
    public void PlayCurrentSong(int songIndex)
    {
        //StartCoroutine(LoadSong(_songsData[_currentSongIndex], true)); // Decomment if streaming audio data
        _currentSongIndex = songIndex;
        if (_clips.Count != 0)
        {
            _audioSource.clip = _clips[_currentSongIndex];
        }
        else
        {
            Debug.LogError("AudioFileLoader: AudioSource.clip could not be assigned.");
        }

        if (_audioSource.clip != null)
        {
            _audioSource.Play();
        }
        else
        {
            Debug.LogError("No AudioClip attached to Camera.main.AudioSource");
        }

        if (_songTitle != null)
        {
            SongTimer.Set(_songTitle, Path.GetFileNameWithoutExtension(_songsData[_currentSongIndex]._tempDir));
        }
        if (_songTime != null)
        {
            SongTimer.SetSongTime(_songTime, _audioSource.clip.length);
        }
        Debug.Log("Playing " + _songsData[_currentSongIndex]._tempDir);
    }
Пример #3
0
    /// <summary>
    /// Play the next song.
    /// </summary>
    void PlayNextSong()
    {
        _audioSource.Stop();
        _audioSource.timeSamples = 0;

        _currentSongIndex = (_currentSongIndex == _files.Length - 1) ? _currentSongIndex = 0 : ++_currentSongIndex;
        _audioSource.clip = _clips[_currentSongIndex];

        _audioSource.Play();
        if (_songTitle != null)
        {
            SongTimer.Set(_songTitle, Path.GetFileNameWithoutExtension(_songsData[_currentSongIndex]._tempDir));
        }
        if (_songTime != null)
        {
            SongTimer.SetSongTime(_songTime, _audioSource.clip.length);
        }

        Debug.Log("Playing " + _songsData[_currentSongIndex]._tempDir);

        //StartCoroutine(LoadSong(_songsData[_currentSongIndex], true)); // Decomment if streaming audio data
    }