How To: Use Gamertags and Gamer Pictures

Demonstrates how to retrieve gamertags and pictures using a technique that can be applied to retrieve other gamer profile information.

Using Gamertags and Gamer Pictures

To retrieve the gamertag and profile picture of a player in a game

  • Use Gamer.GetProfile to retrieve the profile information for any player in the game.

    Note that this method will complete quickly when you use it with a locally signed-in profile. However, this method can take some time if you call it on a remote gamer instance. In the remote case, you might use the non-blocking alternative Gamer.BeginGetProfile.

    The GamerProfile returned by Gamer.GetProfile also contains such information as the motto, gamerscore, and more.

    If the gamer is a SignedInGamer, you can retrieve the local player's preferred settings for gameplay using the SignedInGamer.GameDefaults property. You can also retrieve the local player's privileges using SignedInGamer.Privileges. Unlike Gamer.GetProfile, which can be slow for remote players, the properties of a SignedInGamer return instantly.

    foreach (NetworkGamer gamer in session.AllGamers)
    {
        string text = gamer.Gamertag;
        GamerProfile gamerProfile = gamer.GetProfile();
        Texture2D picture = gamerProfile.GamerPicture;
    }
    

Community Additions

ADD
Show: