Google+ Hangouts API

gapi.hangout

Provides basic information such as the list of participants, the locale, and whether the app is initialized and visible.

API Initialization
onApiReady, isApiReady
While all members of the gapi.hangout API will be available when your application code begins to execute, the API might not be fully initialized. Before initialization, the values returned by APIs might be unexpected (undefined). Modifications ('set*') might produce unexpected results. Adding event listeners before the API is initialized is possible, but the added event listeners might be called while the rest of the API is in an inconsistent state. We therefore strongly recommend delaying your application startup until the Hangouts API is fully initialized, by calling your app with something like this:

gapi.hangout.onApiReady.add(function(eventObj) {
  startMyApp();
});

Classes

Functions

Events

Classes in gapi.hangout

Class Description
class ApiReadyEvent(
  isApiReady
)
Contains information about the API becoming ready.
isApiReady : boolean
Indicates whether the API is ready.
class AppVisibleEvent(
  isAppVisible
)
Contains information about an an app becoming visible in a Hangout.
isAppVisible : boolean
Indicates whether the app is visible.
class EnabledParticipantsChangedEvent(
  enabledParticipants
)
Contains information about participants running this app.
enabledParticipants : Array.<Participant>
List of all participants who are running this app.
class Participant(
  id,
  displayIndex,
  hasMicrophone,
  hasCamera,
  hasAppEnabled,
  isBroadcaster,
  isInBroadcast,
  locale,
  person,
  person.id,
  person.displayName,
  person.image,
  person.image.url
)

A Participant instance represents a person who has joined a Google Hangout. Hangout participant fields should not be modified. Each Participant has a person field which is similar to a subset of Google+ API person. You can get a list of all participants using getParticipants.


id : string
A string uniquely identifying this participant in the Hangout. Each time that a user joins a Hangout, they are assigned a new participant ID. This ID is used to identify a participant throughout the API.
Example: 'hangout65A4C551_ephemeral.id.google.com^354e9d1ed0'
displayIndex : number
The index of the participant on the filmstrip, 0-based.
hasMicrophone : boolean
True if the participant has a microphone installed.
hasCamera : boolean
True if the participant has a video camera installed.
hasAppEnabled : boolean
True if the participant has this app enabled and running in this Hangout.
isBroadcaster : boolean
True if the participant is the broadcaster. The broadcaster is the owner of the Hangout, but only if it is a Hangout On Air.
isInBroadcast : boolean
True if the participant will appear in the Hangout On Air broadcast, if this is a Hangout On Air.
locale : string
The locale of the participant. Null if the locale is not known. Locale is always unknown for mobile participants. Example: 'en'
person : Object
The representation of the participant's Google+ person.
person.id : string
The Google+ ID uniquely identifying this participant. The Google+ ID will never change for a participant. Example: '123456789727111132824'
person.displayName : string
The name of the participant, which is suitable for display to the user.
person.image : Object
The representation of the participant's profile photo.
person.image.url : string
The URL to an image that is suitable for representing the participant. If the participant has not specified a custom image, then a generic image is provided.
class ParticipantsAddedEvent(
  addedParticipants
)
Contains information about participants who have joined the event.
addedParticipants : Array.<Participant>
List of the newly added participants.
class ParticipantsChangedEvent(
  participants
)
Contains information about a change of participants joining or leaving the hangout.
participants : Array.<Participant>
List of the participants currently in the Hangout.
class ParticipantsDisabledEvent(
  disabledParticipants
)
Contains information about participants who have stopped running this app.
disabledParticipants : Array.<Participant>
List of the participants that stopped running this app.
class ParticipantsEnabledEvent(
  enabledParticipants
)
Contains information about participants who have started running this app.
enabledParticipants : Array.<Participant>
List of the participants who started running this app.
class ParticipantsRemovedEvent(
  removedParticipants
)
Contains information about participants who have left the Hangout.
removedParticipants : Array.<Participant>
List of the participants who have left the Hangout.
class PreferredLocaleChangedEvent(
  preferredLocale
)
Contains information about a change to the Hangout's preferred locale.
preferredLocale : string
Indicates the new preferred locale for the hangout.
class PublicChangedEvent(
  isPublic
)
Contains information about the Hangout becoming open to the public.
isPublic : boolean
Indicates whether the Hangout is open to the public.
class TopicChangedEvent(
  topic
)
Contains information about the changing of a Hangout topic.
topic : string
The new hangout topic.

Functions in gapi.hangout

Function Returns Description & Parameter
getEnabledParticipants() Array.<Participant> Gets the participants who are running the app.
getHangoutUrl() string Gets the URL for the hangout.
Example URL: 'https://talkgadget.google.com/hangouts/_/1b8d9e10742f576bc994e18866ea'
getHangoutId() string Gets an identifier for the Hangout guaranteed to be unique for the Hangout's duration. The API makes no other guarantees about this identifier.
Example of Hangout ID: 'muvc-private-chat-99999a93-6273-390d-894a-473226328d79@groupchat.google.com'
getLocale() string
Deprecated:
Use gapi.hangout.getLocalParticipantLocale instead.
Gets the locale for the participant in the Hangout.
Example: 'en'
getLocalParticipantLocale() string Gets the locale for the local participant.
Example: 'en'
getPreferredLocale() string Gets the preferred locale for the Hangout. The user can set this locale prior to starting a Hangout. It may differ from gapi.hangout.getLocalParticipantLocale.
Example: 'en'
getStartData() string Gets the starting data for the current active app. This is the data passed in by the gd URL parameter (also available with gadgets.views.getParams). Returns null if no start data has been specified.
getParticipantById(
  participantId
)
Participant Gets the participant with the given ID. Returns null if no participant exists with the given ID.
participantId : string
The ID for a participant.
getParticipantId() string
Deprecated:
Use gapi.hangout.getLocalParticipantId instead.
Gets the ID of the local participant. A user is assigned a new ID each time they join a Hangout.
Example: 'hangout65A4C551_ephemeral.id.google.com^354e9d1ed0'
getLocalParticipant() Participant Gets the local participant.
getLocalParticipantId() string Gets the ID of the local participant. A user is assigned a new ID each time they join a Hangout.
Example: 'hangout65A4C551_ephemeral.id.google.com^354e9d1ed0'
getParticipants() Array.<Participant> Gets the participants in the Hangout. Note that the list of participants reflects the current state on the Hangouts server. There can be a small window of time where the local participant (returned from getParticipantId()) is not in the returned array.
getTopic() string Returns the current Hangout topic, or an empty string if a topic was not specified.
hasAgeRestriction() boolean Returns true if the Hangout is not open to minors, false if there are no age restrictions.
hideApp() undefined Sets the app as not visible in the main Hangout window. The app will continue to run while it is hidden.

See also: gapi.hangout.onAppVisible

isApiReady() boolean Returns true if the gapi.Hangout API is initialized; false otherwise. Before the API is initialized, data values might have unexpected values.
isAppVisible() boolean Returns true if the app is visible in the main Hangout window, false otherwise.
isPublic() boolean Returns true if the Hangout is open to the public, false otherwise.
setWillAutoLoad(
  autoLoad
)
undefined Sets whether an application should start automatically at the beginning of Hangouts. This should only be set by a user action, such as a checkbox in a settings dialog box, rather than be done automatically. The user will be notified and given a chance to cancel when an app sets itself to autoload.
autoLoad : boolean
Whether an application should automatically start at the beginning of a Hangout.
wasAutoLoaded() boolean Returns whether this application was started automatically at the beginning of the Hangout. If the application was closed and re-opened, this will return false.
willAutoLoad() boolean Returns whether this application will start automatically at the beginning of a Hangout.

Event Functions in gapi.hangout

Event Function Description
gapi.hangout.onApiReady
onApiReady.add(
  callback
)
Adds a callback to be called when the gapi.hangout API becomes ready to use. If the API is already initialized, the callback will be called at the next event dispatch.
callback : function(ApiReadyEvent)
The callback to add.
onApiReady.remove(
  callback
)
Removes a callback previously added by onApiReady.add.
callback : function(ApiReadyEvent)
The callback to remove.
gapi.hangout.onAppVisible
onAppVisible.add(
  callback
)
Adds a callback to be called when the app is shown or hidden. The argument to the callback is an event that holds the state that indicates whether the app is visible or not.

See also: gapi.hangout.hideApp


callback : function(AppVisibleEvent)
The callback to add.
onAppVisible.remove(
  callback
)
Removes a callback previously added by onAppVisible.add.
callback : function(AppVisibleEvent)
The callback to remove.
gapi.hangout.onAutoLoadChange
onAutoLoadChange.add(
  callback
)
Adds a callback to be called when the auto load setting for an application has changed.
callback : function(AutoLoadChangedEvent)
The callback to add.
onAutoLoadChange.remove(
  callback
)
Removes a callback previously added by onAutoLoadChange.add.
callback : function(AutoLoadChangedEvent)
The callback to remove.
gapi.hangout.onEnabledParticipantsChanged
onEnabledParticipantsChanged.add(
  callback
)
Adds a callback to be called whenever the set of participants who are running this app changes. The argument to the callback is an event that holds all participants who have enabled the app since the last time the event fired.
callback : function(EnabledParticipantsChangedEvent)
The callback to add.
onEnabledParticipantsChanged.remove(
  callback
)
Removes a callback previously added by onEnabledParticipantsChanged.add.
callback : function(EnabledParticipantsChangedEvent)
The callback to remove.
gapi.hangout.onParticipantsAdded
onParticipantsAdded.add(
  callback
)
Adds a callback to be called whenever participants join the Hangout. The argument to the callback is an event that holds the particpants who have joined since the last time the event fired.
callback : function(ParticipantsAddedEvent)
The callback to add.
onParticipantsAdded.remove(
  callback
)
Removes a callback previously added by onParticipantsAdded.add.
callback : function(ParticipantsAddedEvent)
The callback to remove.
gapi.hangout.onParticipantsChanged
onParticipantsChanged.add(
  callback
)
Adds callback to be called whenever there is any change in the participants in the Hangout. The argument to the callback is an event that holds holds the participants currently in the Hangout.
callback : function(ParticipantsChangedEvent)
The callback to add.
onParticipantsChanged.remove(
  callback
)
Removes a callback previously added by onParticipantsChanged.add.
callback : function(ParticipantsChangedEvent)
The callback to remove.
gapi.hangout.onParticipantsDisabled
onParticipantsDisabled.add(
  callback
)
Adds a callback to be called whenever a participant stops running this app. The argument to the callback is an event that holds the participants who have stopped running this app since the last time the event fired.
callback : function(ParticipantsDisabledEvent)
The callback to add.
onParticipantsDisabled.remove(
  callback
)
Removes a callback previously added by onParticipantsDisabled.add.
callback : function(ParticipantsDisabledEvent)
The callback to remove.
gapi.hangout.onParticipantsEnabled
onParticipantsEnabled.add(
  callback
)
Adds a callback to be called whenever a participant in the Hangout starts running this app. The argument to the callback is an event that holds the set of participants who have started running this app since the last time the event fired.
callback : function(ParticipantsEnabledEvent)
The callback to add.
onParticipantsEnabled.remove(
  callback
)
Removes a callback previously added by onParticipantsEnabled.add.
callback : function(ParticipantsEnabledEvent)
The callback to remove.
gapi.hangout.onParticipantsRemoved
onParticipantsRemoved.add(
  callback
)
Adds a callback to be called whenever participants leave the Hangout. The argument to the callback is an event that holds the participants who have left since the last time the event fired.
callback : function(ParticipantsRemovedEvent)
The callback to add.
onParticipantsRemoved.remove(
  callback
)
Removes a callback previously added by onParticipantsRemoved.add.
callback : function(ParticipantsRemovedEvent)
The callback to remove.
gapi.hangout.onPreferredLocaleChanged
onPreferredLocaleChanged.add(
  callback
)
Adds a callback to be called when the Hangout's preferred locale changes.
callback : function(PreferredLocaleChangedEvent)
The callback to add.
onPreferredLocaleChanged.remove(
  callback
)
Removes a callback previously added by onPreferredLocaleChanged.add.
callback : function(PreferredLocaleChangedEvent)
The callback to remove.
gapi.hangout.onPublicChanged
onPublicChanged.add(
  callback
)
Adds a callback to be called when the Hangout becomes public. A Hangout can change only from private to public.
callback : function(PublicChangedEvent)
The callback to add.
onPublicChanged.remove(
  callback
)
Removes a callback previously added by onPublicChanged.add.
callback : function(PublicChangedEvent)
The callback to remove.
gapi.hangout.onTopicChanged
onTopicChanged.add(
  callback
)
Adds a callback function to be called when the Hangout topic changes.
callback : function(TopicChangedEvent)
The callback to add.
onTopicChanged.remove(
  callback
)
Removes a callback function that was previously added by onTopicChanged.add.
callback : function(TopicChangedEvent)
The callback to remove.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.