示例#1
0
 private void StartAudioPreview(SongMeta songMeta, int previewStartInMillis)
 {
     songAudioPlayer.Init(songMeta);
     songAudioPlayer.PositionInSongInMillis = previewStartInMillis;
     songAudioPlayer.audioPlayer.volume     = 0;
     songAudioPlayer.PlayAudio();
 }
示例#2
0
    private IEnumerator StartAudioPlayback()
    {
        if (songAudioPlayer.IsPlaying)
        {
            Debug.LogWarning("Song already playing");
            yield break;
        }

        songAudioPlayer.Init(SongMeta);

        if (!songAudioPlayer.HasAudioClip)
        {
            // Loading the audio failed.
            SceneNavigator.Instance.LoadScene(EScene.SongSelectScene);
            yield break;
        }

        // The time bar needs the duration of the song to calculate positions.
        // The duration of the song should be available now.
        InitTimeBar();

        songAudioPlayer.PlayAudio();
        if (SceneData.PositionInSongInMillis > 0)
        {
            Debug.Log($"Skipping forward to {SceneData.PositionInSongInMillis} milliseconds");
            songAudioPlayer.PositionInSongInMillis = SceneData.PositionInSongInMillis;
        }
    }
示例#3
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");
        }
    }
示例#4
0
    void Awake()
    {
        Debug.Log($"Start editing of '{SceneData.SelectedSongMeta.Title}' at {SceneData.PositionInSongInMillis} ms.");
        songAudioPlayer.Init(SongMeta);
        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        songAudioPlayer.PositionInSongInMillis = SceneData.PositionInSongInMillis;
    }
示例#5
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);
     }
 }
    public void CheckAudioAndStartSingScene()
    {
        if (playerSelectOverlayContainer.IsVisibleByDisplay())
        {
            StartSingScene(SelectedSong);
        }
        else if (SelectedSong.VoiceNames.Count <= 1 &&
                 playerListControl.PlayerEntryControlControls.Count == 1 &&
                 micListControl.MicEntryControls.Count == 1)
        {
            // There is one mic for only one player and only one voice to sing.
            // Thus, there is no choice to make and the song can be started immediately.
            playerListControl.PlayerEntryControlControls[0].MicProfile = micListControl.MicEntryControls[0].MicProfile;
            playerListControl.PlayerEntryControlControls[0].SetSelected(true);
            StartSingScene(SelectedSong);
        }
        else
        {
            if (SelectedSong == null)
            {
                return;
            }

            // Check that the audio file exists
            if (!WebRequestUtils.IsHttpOrHttpsUri(SelectedSong.Mp3))
            {
                string audioUri = SongMetaUtils.GetAudioUri(SelectedSong);
                if (!WebRequestUtils.ResourceExists(audioUri))
                {
                    string message = "Audio file resource does not exist: " + audioUri;
                    Debug.Log(message);
                    uiManager.CreateNotificationVisualElement(message);
                    return;
                }
            }

            // Check that the used audio format can be loaded.
            songAudioPlayer.Init(SelectedSong);
            if (!songAudioPlayer.HasAudioClip)
            {
                string message = $"Audio file '{SelectedSong.Mp3}' could not be loaded.\nPlease use a supported format.";
                Debug.Log(message);
                uiManager.CreateNotificationVisualElement(message);
                return;
            }

            ShowPlayerSelectOverlay();
        }
    }
    public void CheckAudioAndStartSingScene()
    {
        if (SelectedSong != null)
        {
            // Check that the audio file exists
            string audioPath = SongMetaUtils.GetAbsoluteSongFilePath(SelectedSong);
            if (!File.Exists(audioPath))
            {
                UiManager.Instance.CreateWarningDialog("Audio Error", "Audio file does not exist: " + audioPath);
                return;
            }

            // Check that the used audio format can be loaded.
            songAudioPlayer.Init(SelectedSong);
            if (!songAudioPlayer.HasAudioClip)
            {
                UiManager.Instance.CreateWarningDialog("Audio Error", "Audio file could not be loaded.\nPlease use a supported format.");
                return;
            }

            StartSingScene(SelectedSong);
        }
    }