Developer Documentation

How do I access the live audio feed?

Sometimes, for example if you want to do lip-syncing or if you want to add an graphical equalizer representing the audio coming from ODIN, you need to get access to the AudioSource and AudioClipfrom ODIN.

This is how you can get access to those information. Somewhere in your code, you attach the ODIN playback component representing a user to the game object using the function OdinHandler.Instance.AddPlaybackComponent. This will return an instance of PlaybackComponent. Use this component to get access to the AudioClip:

Playback = gameObject.GetComponent<PlaybackComponent>();
AudioSource source = Playback.PlaybackSource;
AudioClip clip = Playback.PlaybackSource.clip;

What is UserData?

Every peer (i.e. player) connected to ODIN has it’s own user data. Within ODIN, this is just a byte array that you can use for everything. We provide a class that provides basic user data as a JSON object. CustomUserDataJsonFormat exposes that interface and provides convenience functions for serialization.

You can set the user data before joining a room or you can also update the user data afterwards:

// Generate a JSON User Data object with the players netId and name in the network
CustomUserDataJsonFormat userData = new CustomUserDataJsonFormat(name, "online");
userData.seed = netId.ToString();

// Join ODIN Room ShooterSample and send user data
OdinHandler.Instance.JoinRoom("ShooterSample", userData.ToUserData());

The method ToUserData serializes the data stored in the CustomUserDataJsonFormat instance to a JSON string and FromUserData will take the serialized JSON string and return an instance of CustomUserDataJsonFormat as shown in this code snippet:

public void OnMediaRemoved(object sender, MediaRemovedEventArgs eventArgs)
{
    OdinUserData userData = OdinUserData.FromUserData(eventArgs.Peer.UserData);
    PlayerScript player = GetPlayerForOdinPeer(userData);
    if (player)
    {
        RemoveOdinPlaybackFromPlayer(player);
    }
}

Please check out our guide on user data:

See also

Still need help?

Please check out support options like AI chatbot, Discord community and premium support packages.

Get in touch