Hi, when I use returned channel from PlayDialogVoice() and testing if played by isPlaying, when Unity editor is muted, it still return true, till I unmute editor. So this blocking flow according to isPlaying.
Exist any possibility how to isPlaying can reflect audio length with muted audio?
public static FMOD.Channel PlayDialogVoice(string dialogKey, out float length)
{
StopCurrentDialogue();
length = 0.0f;
string currentLanguage = LocalizationSettings.SelectedLocale.Identifier.Code;
string path = $"{BaseVoicesPath}/{currentLanguage}/{dialogKey}.voice.mp3";
DebugUtility.Log($"PlayDialogVoice:{dialogKey} from:{path}", DebugTag.TagAudio);
FMOD.MODE mode = FMOD.MODE.CREATESTREAM | FMOD.MODE.LOOP_OFF;
// Create streaming audio from mp3 file
FMOD.RESULT result = RuntimeManager.CoreSystem.createSound(path, mode, out _sDialogSound);
if (result != FMOD.RESULT.OK)
{
DebugUtility.LogError($"PlayDialogVoice cant load dialog from:{path} result:{result}", DebugTag.TagAudio);
return default;
}
// Get dialog group
result = _sDialogBus.getChannelGroup(out FMOD.ChannelGroup dialogueGroup);
DebugUtility.Log($"PlayDialogVoice getChannelGroup:{result}", DebugTag.TagAudio);
result = RuntimeManager.CoreSystem.playSound(_sDialogSound, dialogueGroup, false, out _sDialogChannel);
DebugUtility.Log($"PlayDialogVoice playSound:{result}", DebugTag.TagAudio);
if (result == FMOD.RESULT.OK)
{
_sDialogChannel.setPitch(1.0f);
// For tests, that voice reacts on bus changes
//dialogBus.setMute(true);
//dialogBus.setVolume(0.5f);
_sDialogSound.getLength(out uint lengthMs, FMOD.TIMEUNIT.MS);
length = lengthMs / 1000.0f;
DebugUtility.Log($"PlayDialogVoice length:{length}", DebugTag.TagAudio);
return _sDialogChannel;
}
else
{
return default;
}
}
Thanks for answer
Milan

Hi,
Thanks for the code and the info.
I don’t fully understand the issue.
With the Unity editor muted are you finding that this code:
_sDialogSound.getLength(out uint lengthMs, FMOD.TIMEUNIT.MS);
length = lengthMs / 1000.0f;
DebugUtility.Log($"PlayDialogVoice length:{length}", DebugTag.TagAudio);
Is not returning the expected values? I cannot see any IsPlaying() in the code provided, is this being called else where?
Hi.
the returned length is ok, no matter if is Unity editor muted or not.
We have dialogue sequences and we are testing end of dialog by this condition.
static bool IsFinished(QueuedEntry entry, float timeNow)
{
entry.Channel.isPlaying(out bool isPlaying);
return timeNow >= entry.MinCompletionTime && !isPlaying;
}
And when Unity editor is muted, isPlaying is always true, so no next dialog can play.
Of course, I can change condition to:
static bool IsFinished(QueuedEntry entry, float timeNow)
{
return timeNow >= entry.MinCompletionTime + entry.audioLength;
}
But I wonder, if is another possibility, how to keep isPlaying condition and it should work with muted Unity editor.
I hope, that this explains problem more deeply.
Best
Milan
Thanks for the clarification,
I made a test with your function and checking the isPlaying(), I am not able to reproduce the issue:
// My modified function
public FMOD.Channel PlayDialogVoice(out float length)
{
//StopCurrentDialogue();
length = 0.0f;
//string currentLanguage = LocalizationSettings.SelectedLocale.Identifier.Code;
//string path = $"{BaseVoicesPath}/{currentLanguage}/{dialogKey}.voice.mp3";
//Debug.Log($"PlayDialogVoice:{dialogKey} from:{path}", DebugTag.TagAudio);
FMOD.MODE mode = FMOD.MODE.CREATESTREAM | FMOD.MODE.LOOP_OFF;
// Create streaming audio from mp3 file
FMOD.RESULT result = RuntimeManager.CoreSystem.createSound(audioFilePath, mode, out sound);
if (result != FMOD.RESULT.OK)
{
Debug.LogError($"PlayDialogVoice cant load dialog from:{audioFilePath} result:{result}");//, DebugTag.TagAudio);
return default;
}
// Get dialog group
result = RuntimeManager.CoreSystem.getMasterChannelGroup(out FMOD.ChannelGroup master);
// Checking if the channel is still playing
if (channel.hasHandle())
{
FMOD.RESULT result = channel.isPlaying(out bool isPlaying);
if (result == FMOD.RESULT.OK)
{
Debug.Log($"Channel is playing {isPlaying}");
}
else
{
Debug.Log($"Failed to check if channel is playing with result: {result}");
}
Debug.Log($"Channel Handle {channel.handle}");
}
//result = _sDialogBus.getChannelGroup(out FMOD.ChannelGroup dialogueGroup);
Debug.Log($"PlayDialogVoice getChannelGroup:{result}");//, DebugTag.TagAudio);
result = RuntimeManager.CoreSystem.playSound(sound, master, false, out channel);
Debug.Log($"PlayDialogVoice playSound:{result}");//, DebugTag.TagAudio);
if (result == FMOD.RESULT.OK)
{
master.setPitch(1.0f);
// For tests, that voice reacts on bus changes
//dialogBus.setMute(true);
//dialogBus.setVolume(0.5f);
sound.getLength(out uint lengthMs, FMOD.TIMEUNIT.MS);
length = lengthMs / 1000.0f;
Debug.Log($"PlayDialogVoice length:{length}");//, DebugTag.TagAudio);
return channel;
}
else
{
return default;
}
}
and I am seeing the function returning false:
Are you able to create a reproduction project and upload it to your profile that I can test?
Hello,
I prepared repro case, but I am not able reproduce it too.
Probably some other things in project has dependency on it. Iam still investigate it.
One note, when isPlaying retuns still true the playing possion goes over mp3 length (4.9s), which is weird.
_channel.getPosition(out uint pos, FMOD.TIMEUNIT.MS);
Debug.Log($"isPlaying={isPlaying} | pos={pos}ms");
isPlaying=True | pos=6571ms
Milan
Thank you for testing that.
In your code example, the _channel is currently not playing but IsPlaying is still returning true? Could you share the full code example?