Search code examples
unity-game-enginesdkvoiceagora.io

agora.io GetAudioMixingDuration always return -7


After I updated the voice SDK for Unity to 3.6.1 (previously 2.4) I tried to add the new parameter "filePath" at GetAudioMixingDuration instead of using the usual method with no parameters. For some reason, the same file played and then called GetAudioMixingDuration(), in the new method with the "filePath" parameter always returns -7.

What I did is to point to the very same path of the file in the "filePath" parameter instead of playing it and then call the no parameter method, but for some reason, it's not working.

I also tried both relative and absolute paths, point a file inside and outside the Asset folder, and check if Agora is connected to a channel.

I really don't know what is wrong and the documentation doesn't help at all.


Solution

  • This API is deprecated. Please check the code header for its documentation, especially look for the comment about Android if that's what you are running on. Quoted here:

        /**
         * Gets the total duration of the music file.
         *
         * @deprecated Deprecated from v3.6.1.1. Use {@link agora_gaming_rtc.IRtcEngine.GetAudioFileInfo GetAudioFileInfo} instead.
         *
         * @note Call this method after joining a channel.
         *
         * @param filePath The absolute path (including the filename extensions) of
         * the local music file. For example: `C:\music\audio.mp4`. Supported audio
         * formats include MP3, AAC, M4A, MP4, WAV, and 3GP. For more information,
         * see [Supported Media Formats in Media Foundation](https://learn.microsoft.com/en-us/windows/win32/medfound/supported-media-formats-in-media-foundation).
         * When you access a local file on Android, Agora recommends passing a
         * URI address or the path starts with `/assets/` in this parameter.
         *
         * @return
         * - ≥ 0: A successful method call. Returns the total duration (ms)
         * of the specified music file.
         * - < 0: Failure.
         */
         public int GetAudioMixingDuration(string filePath)