Ejemplo n.º 1
0
 public void TogglePlayPause()
 {
     if (songAudioPlayer.IsPlaying)
     {
         pauseOverlay.SetActive(true);
         songAudioPlayer.PauseAudio();
     }
     else
     {
         pauseOverlay.SetActive(false);
         songAudioPlayer.PlayAudio();
     }
 }
    private void PlayAudioInRangeOfNotes(List <Note> notes)
    {
        if (songAudioPlayer.IsPlaying)
        {
            return;
        }

        int    minBeat   = notes.Select(it => it.StartBeat).Min();
        int    maxBeat   = notes.Select(it => it.EndBeat).Max();
        double maxMillis = BpmUtils.BeatToMillisecondsInSong(songMeta, maxBeat);
        double minMillis = BpmUtils.BeatToMillisecondsInSong(songMeta, minBeat);

        songEditorSceneController.StopPlaybackAfterPositionInSongInMillis = maxMillis;
        songAudioPlayer.PositionInSongInMillis = minMillis;
        songAudioPlayer.PlayAudio();
    }
Ejemplo n.º 3
0
 private void StartAudioPreview(SongMeta songMeta, int previewStartInMillis)
 {
     songAudioPlayer.Init(songMeta);
     songAudioPlayer.PositionInSongInMillis = previewStartInMillis;
     songAudioPlayer.audioPlayer.volume     = 0;
     songAudioPlayer.PlayAudio();
 }
Ejemplo n.º 4
0
    private void StartAudioPreview(SongMeta songMeta, int previewStartInMillis)
    {
        try
        {
            songAudioPlayer.Init(songMeta);
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
            string errorMessage = $"Audio could not be loaded (artist: {songMeta.Artist}, title: {songMeta.Title})";
            uiManager.CreateNotificationVisualElement(errorMessage);
            return;
        }

        songAudioPlayer.PositionInSongInMillis = previewStartInMillis;
        songAudioPlayer.audioPlayer.volume     = 0;
        if (songAudioPlayer.HasAudioClip)
        {
            songAudioPlayer.PlayAudio();
        }
        else
        {
            string errorMessage = $"Audio could not be loaded (artist: {songMeta.Artist}, title: {songMeta.Title})";
            Debug.LogError(errorMessage);
            uiManager.CreateNotificationVisualElement(errorMessage, "error");
        }
    }
Ejemplo n.º 5
0
 private void ToggleAudioPlayPause()
 {
     if (songAudioPlayer.IsPlaying)
     {
         songAudioPlayer.PauseAudio();
     }
     else
     {
         songAudioPlayer.PlayAudio();
     }
 }
Ejemplo n.º 6
0
 private void StartAudioPreview(SongMeta songMeta, int previewStartInMillis)
 {
     songAudioPlayer.Init(songMeta);
     songAudioPlayer.PositionInSongInMillis = previewStartInMillis;
     songAudioPlayer.audioPlayer.volume     = 0;
     if (songAudioPlayer.HasAudioClip)
     {
         songAudioPlayer.PlayAudio();
     }
     else
     {
         uiManager.CreateNotification("Audio could not be loaded.", Colors.red);
     }
 }