getTimelinePosition and getLength always return 0, and I am not entirely certain as to why

Trying to make a basic audio player for a very UI-heavy game, and the functions getTimelinePosition() and getLength() are used here to measure how much of the audio has been played through via a progress bar, which is measured in a separate function.

Both of these functions, no matter how many times I execute them, seem to always return with a 0, instead of the actual timeline position and event length. I don’t know if I’m doing something wrong in my code, or if there might just perhaps be a better way of executing this, but I am banging my head against my desk trying to look for others who have attempted something similar with these functions, and not getting an understandable or fitting answer. I’ve only recently gotten into using FMOD, probably around a month or so, and this is the first time I’m doing something a little more complicated than I usually tend to do.

Here is part of the code that I am having a lot of issues with. This function is called at the start of the audio player being booted up, and instance.getTimelinePosition(out int currentTime); is called every update cycle.

    public void StartSound()
    {
        instance = RuntimeManager.CreateInstance(actualAudio);
        instance.getDescription(out eventDescription);

        //director.playableAsset = actualSubtitle;

        isPaused = false;
        instance.start();
        //director.Play();

        res = instance.getTimelinePosition(out int currentTime);

        if (res != FMOD.RESULT.OK)
        {
            Debug.LogError("getTimelinePosition reported error: " + res);
        }

        res = eventDescription.getLength(out int totalTime);
        if (res != FMOD.RESULT.OK)
        {
            Debug.LogError("getLength reported error: " + res);
        }
    }

Any help or advice at all would be extremely appreciated, thanks!

Never mind, I only realized what the issue was after the fact. I have variables set up for currentTime and total time. But instead of using those variables, I am telling FMODUnity to output the result into a NEW variable instead of the one I had already set up. Kids, always double check your code to make sure silly mistakes like these don’t happen XD

1 Like