我要评分
获取效率
正确性
完整性
易理解

Initializing and Registering the Touch Engine API

Application Scenario

Initialize and register the touch engine API.

Prerequisites

A video stream engine object has been created.

Development Process

  1. Create the DataPipe class to implement the TOUCHSENDHOOK interface function.
  2. Encapsulate the registration interface function of the DataPipe class and register the touch engine.
  3. Call the touch data sending function of the video stream engine in the TOUCHSENDHOOK implementation.

Encoding Instance

public class Activity implements BaseActivity {
    protected void onCreate(Bundle savedInstanceState) {
        // Set the video stream engine object.
        DataPipe.setVideoEngine(engine);
        // Register the touch engine.
        DataPipe.registerHookToTouch();
        // Register the audio engine.
        DataPipe.registerAudioSendHook();
   }
}

public class DataPipe extends BaseDataPipe implements TOUCHSENDHOOK, AUDIOSENDHOOK {
    // Register the touch engine API.
    public static void registerHookToTouch() {
        // Call the touch engine registration interface function.
        int ret = VmiTouch.getInstance().registerTouchSendHook(DataPipe.getInstance());
        if (ret == VmiTouch.VMI_SUCCESS) {
            // The touch engine is successfully registered.
        }
    }
    @Override
    public void touchSendData(byte[] data, int length) {
        // Call the touch data sending function of the video stream engine.
        VideoEngine.sendTouchEventArray(data, length);
    }
 }