logo
On this page

Implement live comment-based games on PCs as a host


This topic describes how to start and implement a live comment-based game on a PC as a host. The live comment-based game "TinyLoveWar" is used as an example for description.

Modes of a live comment-based game

Two modes are provided: free-trial mode and formal mode. Different modes correspond to different gaming procedures. The following table compares the two modes.

ModeWhether a game start code is requiredWhether connection to the server is requiredApplicable scenario
Free-trial modeNo. You can start a game without a game start code. No. You can use the live comment and gift features without the need to connect to the server. Game effect experience scenarios
Formal modeYes. Yes. You need to connect to the server to actually experience the live comment and gift features.Actual live streaming scenarios
Warning

The free-trial mode is applicable only to specific games.

Prerequisites

Before you start live streaming for a live comment-based game on a PC as a host, make sure that the following prerequisites are met:

  • The computer hardware of the host satisfies the requirements that are shown in the following table. This is required in both modes. The requirements may differ based on different games.

    ItemRequirement
    Operating systemWindows 10 or later.
    Screen resolution1080P or higher. The 2K or 4K resolution is better.
    CPUIntel Core i3 with four or more cores.
    GPUGTX 750 Ti or later with an 8-GB or larger memory.
  • A project is created in the ZEGOCLOUD console, and the application ID is obtained. This is optional in free-trial mode. For more information, see How to create project in the "Console" documentation.

  • The server secret of the created project is obtained. This is optional in free-trial mode. For more information, see How to view project information in the "Console" documentation.

  • The ZEGOCLOUD MiniGameEngine service is activated through ZEGOCLOUD technical support, and the required game permissions are granted. This is optional in free-trial mode.

  • The secret and the signature are obtained. This is optional in free-trial mode. For more information, see the "Signature method" section of the Make API requests topic.

Procedure

1. (Server) Connect to the ZEGOCLOUD server

Note

If you want to only try the game effects and pay no attention to stream ingestion and pulling, you can select the free-trial mode and skip this step.

  1. Connect to the ZEGOCLOUD MiniGameEngine server.

    For more information about how to connect to the ZEGOCLOUD MiniGameEngine server, see Server API - Make API requests. For more information about how to implement game features on your server such as obtaining a game start code, see Obtain a game start code. This way, the host can start a live comment-based game in formal mode.

    ZEGOCLOUD provides sample server code for your reference. For your data security, do not use the sample code in a production environment.

  2. Connect to the ZEGOCLOUD Cloud Communication Service server.

    You can contact ZEGOCLOUD technical support team to obtain the required real-time messaging protocol (RTMP) permissions. Then, you can connect to the ZEGOCLOUD Cloud Communication Service server. For more information, see the Make API requests topic in the "API V2" documentation. In addition, you can implement RTMP-based stream scheduling on your server and obtain an RTMP URL. This way, you can configure the ingest URL based on the obtained RTMP URL during Open Broadcaster Software (OBS) live streaming. For more information, see RTMP stream publishing and pulling scheduling.

2. (Client and Server) Start a game

  1. (Client) Obtain and start the game client.

    Contact ZEGOCLOUD technical support team or business staff to obtain the game client of the latest version.

    Double-click the game client to start a game.

  1. (Server) Obtain a game start code.

    Note

    If your game is in free-trial mode, skip this step.

    The game start code is obtained when you are Connect to the ZEGOCLOUD server. In this case, you need to configure how to use these features on the server as needed and how to send the game start code to the host.

    Note

    In addition, you need to specify a portal for the host to obtain the game start code. You can specify a custom portal as needed. For example, the portal can be a webpage or outside your business application.

  2. (Client) Start a game.

    Warning

    The procedure for starting a game is described below by using "TinyLoveWar" as an example. The procedure for starting other games may be different, which depends on the actual interfaces of the games.

    You need to perform different operations in different gaming modes. The following table shows the interfaces of the game in different modes.

    ModeStart interfaceGame interface
    Free-trial mode
    Formal mode

3. (Client) Start live streaming

  1. Download and install OBS.

    For more information about how to download and install OBS, visit the OBS official website.

  2. Configure a game source.

    1. Open OBS.
    2. On the Sources tab, click the plus (+) icon. Then, click Create new. The Properties dialog appears.
    3. In the dialog, set the Modeparameter to "Capture specific window" and select a game.
  3. Configure a video image.

    Note

    The following parameter settings are merely examples. Set parameters based on the actual game, network configuration, and PC model. You can contact ZEGOCLOUD presales or delivery experts to achieve the expected effects.

    1. Click File. In the menu that appears, select Settings. The Setting dialog box appears.
  1. In the Settingdialog box, perform the following operations:

    • Click the "Output" tab. On this tab, set the video bitrate to 7,000 Kbit/s.

    • Click the "Video" tab. On this tab, set the Base (Canvas) Resolution parameter and the Output (Scaled) Resolution parameter to 720×1080, and set the Common FPS Values parameter to 30.

  2. Configure an ingest URL for OBS live streaming.

    Note

    If your game is in free-trial mode, skip this step.

In the Setting dialog box, click the Stream tab. Then, set the Server parameter to the URL that you obtained by removing the stream name from the RTMP URL obtained in Step 1, and set the Stream Key parameter to the stream name.

Example:
The obtained RTMP URL is in the format of rtmp://xx.xxx.xxx.xxxx:xxx/xxxxxx/ABC, where ABC indicates the stream name.
In this case, set the Server parameter to rtmp://xx.xxx.xxx.xxxx:xxx/xxxxxx.
Set the Stream Key parameter to ABC.

Previous

Integrate the SDK

Next

Implement live comment-based games on mobile devices as a host