Note: You are viewing the Unity version of this topic. To view this topic for native development, see Parties and Party Chat (Native). To view this topic for Unreal development, see Parties and Party Chat (Unreal).
Parties allow users to voice chat with friends in Oculus Home. For example, a group of friends can start a party in Home and chat about the game that they want to play together. Then, when they launch the app their chat session continues while in that app.
You may wish to disable party chat if your multiplayer app also provides a voice chat feature.
Users can create a Party and start a voice chat with members of the party and they can invite friends to join them in Rooms. Party voice chat persists across apps in VR and users can continue to interact while navigating between apps. This can cause issues if your app has a voice chat feature.
Note that this feature accesses user data and may require you to complete the Data Use Checkup form prior to submitting your app to the Oculus Store. For more information, see Complete a Data Use Checkup.
No integration is required to support parties; however, there are some things you should consider if you are planning to use the microphone for commands or chat in your app. Following is a list of the kinds of chat a user could participate in.
This page reviews how your app can use the microphone for chat or commands in collaboration with Party/System VoIP.
If you’re planning implement VoIP in your application, either the Platform VoIP or Application VoIP, you’ll need to handle two chat streams.
Let’s walk through an example handling multiple chat streams:
Unless you handle this scenario, Aya will then be able to talk to Betty (on Party VoIP) and Kai (on Application or Platform VoIP), but Betty and Kai will not be able to hear each other.
One way to handle this is to suppress the Party VoIP stream and add Kai to the Application VoIP to avoid this conflict.
Oculus provides a System VoIP API that you can use to detect if the user is in a party and using (System VoIP), and allows you to disable a VoIP stream.
To use the System VoIP API, first check the status of the System VoIP to see whether the user status is active.
There are two ways to check the state of System VoIP. 1. check every frame and 2. listen for a notification.
Check Every Frame - To check whether System VoIP is active at any time, using the following function. Note that this is a synchronous function, not a request:
Voip.GetSystem VoIPStatus() == System VoIPStatus.Active
Listen for a Notification - To get a notification for changes in the VoIP state you can make the following request: In Unity listen for MessageType.Notification_Voip_System VoIPState
that has a Message<System VoIPState>
from which you can access the Status field, or call SetSystem VoIPStateNotificationCallback
with a Message<System VoIPState>
callback.
It’s possible for the state to change quickly. The values you extract from notification messages will be the state at the time the notification was added to the message queue, which may be different from the state then the message is processed. You may wish to listen for the notification, and then ignore its values and check the current state using the synchronous functions.
Next, you can suppress the VoIP stream that you don’t want the user to hear or allow the user to hear the stream that they choose.
If the System VoIP is active you can:
Platform.VoIP.SetSystemVoipSuppressed(bool suppressed)
, then use either Platform VoIP or your own VoIP service to run the app VoIP.System VoIP will be unsuppressed if the app that has it suppressed quits. You may also wish to stop suppressing a user’s party VoIP when they leave the multiplayer portion of your app, e.g. your home menu, so that they may resume chatting with their party.
You may also allow your users to toggle between System VoIP and your in-app VoIP. This allows users to choose if they want to keep talking to their party (in which case you would need to suppress your in-app VoIP), or if they want to use your in-app VoIP (in which case you would need to suppress the System VoIP).
Note: The following methods are intended for Android development.
There are two integrations that you may need to add to your mobile app.
If you’re planning to have some form of VoIP in your application, you’ll need a way to handle the two chat streams. For example, if User A and B are in a party and User A launches an application that User C is playing and invites User C to a multiplayer game; User A will then be able to talk to B (on Party VoIP) and C (on Application or Platform VoIP), but B and C will not be able to hear each other. You’ll want to suppress one of the chat streams to avoid this conflict.
Oculus provides System VoIP APIs that enables you to detect if the user is in a party and using System VoIP, and allows you to disable a VoIP stream.
To use the System VoIP API first check the status of the System VoIP. There are two ways to check the state of System VoIP (active means the user is using Party VoIP). One way is to check every frame, the other is to listen for a notification.
Check Every Frame - To check whether System VoIP is active at any time (these are synchronous functions, not requests):
Voip.GetSystem VoIPStatus() == System VoIPStatus.Active
Listen for a Notification - To get a notification for changes in the VoIP state you can make the following request:
In Unity listen for MessageType.Notification_Voip_System VoIPState
which has a Message<System VoIPState>
from which you can access the Status field, or call SetSystem VoIPStateNotificationCallback
with a Message<System VoIPState>
callback.
It’s possible for the state to change quickly. The values you extract from notification messages will be the state at the time the notification was added to the message queue, which may be different from the state then the message is processed. You may wish to listen for the notification, and then ignore its values and check the current state using the synchronous functions.
Next, you can suppress the VoIP stream that you don’t want the user to hear or allow the user to hear the stream that they choose.
If the System VoIP is active you can:
Platform.VoIP.SetSystemVoipSuppressed(bool suppressed)
, then use either Platform VoIP or your own VoIP service to run the app VoIP.System VoIP will be unsuppressed if the app that has it suppressed quits. You may also wish to unsupress a user’s party VoIP when they leave the multiplayer portion of your app, e.g. your home menu, so that they may resume chatting with their party.
You may also allow your users to toggle between System VoIP and your in-app VoIP. This allows users to choose if they want to keep talking to their party (in which case you would need to suppress your in-app VoIP), or if they want to use your in-app VoIP (in which case you would need to suppress the System VoIP).
Android only allows one device to access the microphone at a time. So, Oculus has developed an application layer that allows multiple applications to access the microphone at the same time.
The following functions can be used to access microphone data on an Android device. These functions allow the microphone to be accessed by multiple services. These functions should be used if you plan to use your own VoIP service or if you plan to use the microphone for voice commands in your application. Detail about each function can be found in the Platform SDK Reference Content.
Create an Microphone
object and receives a handle to it. The caller owns this memory and is responsible for freeing it. Use Platform.Microphone.Destroy()
to free the object.
Platform.Microphone.Create()
Start gathering microphone data. After this is called PCM data can be extracted. This function can be safely called from any thread.
Platform.Microphone.Start()
Retrieve all available samples of microphone data and copies it into the outputBuffer. The microphone will generate data at roughly the rate of 480 samples per 10ms. The data format is 16 bit fixed point 48khz mono. This function can be safely called from any thread.
Platform.Microphone.GetPCM()
Retrieve all available samples of microphone data and copies it into the outputBuffer. The microphone will generate data at roughly the rate of 480 samples per 10ms. The data format is 32 bit floating point 48khz mono. This function can be safely called from any thread.
Platform.Microphone.GetPCMFloat()
Stop gathering microphone data. This function can be safely called from any thread.
Platform.Microphone.Stop()
Stop and free a previously created microphone object.
Platform.Microphone.Destroy()
In general, creating a microphone object may resemble the following:
Platform.Microphone.Create()
.Platform.Microphone.Start()
.Platform.Microphone.GetPCMFloat()
to retrieve the PCM data off the buffer and use as needed in your application.Platform.Microphone.Stop()
if you intend to start again at some point, or Platform.Microphone.Destroy()
to destroy the microphone object.