Sequential play of audiofiles (3 posts)

  • Profile picture of DulcetTone DulcetTone1p said 5 months, 4 weeks ago:

    I am trying to get AudioNode to handle sequential play of audio files so characters can speak via concatenated speech files.

    However, there seems to be a limitation I do not understand.

    I see that setAudioData hints that what I am trying to do is somehow verboten — taking an existing AudioNode and handing it a new audio file I’d like it to play after the first has completed.

    public void setAudioData(AudioData audioData, AudioKey audioKey) {
            if (data != null) {
                throw new IllegalStateException("Cannot change data once its set");
            }
    
            data = audioData;
            this.audioKey = audioKey;
        }
    

    What is the prescribed method for such a trick?

    I already have spent some time adding a callback so that an AudioNode can alert a listener object when its playback has just completed, but it appears as if I have to toss each audio node after each individual file’s play, which seems inefficient.

    tone

  • Profile picture of glaucomardano glaucomardano252p said 5 months, 4 weeks ago:

    Have you even seen the AudioNode.getStatus() method? You can check if it’s playing : if(audioNode.getStatus().equals(AudioNode.Status.Playing)).

  • Profile picture of normen normen1291p said 5 months, 4 weeks ago:

    You can just check if the audio is playing each frame. jME3 update-loop based / state based, listeners don’t really fit in this scheme, though they are available in some places.