openimsdk / open-im-sdk-reactnative

IM ReactNative
https://openim.io
MIT License
39 stars 54 forks source link

[BUG] createVideoMessageFromFullPath return java.lang.NullPointerException #54

Closed OrrinHatch closed 13 hours ago

OrrinHatch commented 3 weeks ago

OpenIM Server Version

3.8.0

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Docker Deployment

Bug Description and Steps to Reproduce

log:

-----视频消息参数: {"duration": 4676, "snapshotPath": "/data/user/0/com.sass_crm_rn_cn/cache/VideoThumbnails/65e8900a-47b0-4545-a0b5-f5cf49736ba5.jpg", "videoPath": "/data/user/0/com.sass_crm_rn_cn/cache/ImagePicker/0096f501-412a-464d-ac11-2f63dba47a71.mp4", "videoType": "mp4"}

 OpenIMSDKRN.createVideoMessageFromFullPath(options, uuidv4()).then((data: MessageItem) => {
              console.log('创建视频消息,返回结果:', data);
              if(data) {
                sendMessage({ message: data });
              }
            });

android code:

 @ReactMethod
  public void createVideoMessage(ReadableMap options, String operationID, Promise promise) {
    String videoPath = options.getString("videoPath");
    String videoType = options.getString("videoType");
    int duration = options.getInt("duration");
    String snapshotPath = options.getString("snapshotPath");

    String message = Open_im_sdk.createVideoMessage(operationID, videoPath, videoType, duration, snapshotPath);
    try {
      JSONObject obj = JSON.parseObject(message);
      promise.resolve(emitter.convertJsonToMap(obj));
    } catch (Exception e) {
      // error: output: Connot convert argument of type class java.lang.NullPointerException
      promise.resolve(message);
    }
  }

  @ReactMethod
  public void createVideoMessageFromFullPath(ReadableMap options, String operationID, Promise promise) {
    String videoPath = options.getString("videoPath");
    String videoType = options.getString("videoType");
    int duration = options.getInt("duration");
    String snapshotPath = options.getString("snapshotPath");

    String message = Open_im_sdk.createVideoMessage(operationID, videoPath, videoType, duration, snapshotPath);
    try {
      JSONObject obj = JSON.parseObject(message);
      promise.resolve(emitter.convertJsonToMap(obj));
    } catch (Exception e) {
       // error: output: Connot convert argument of type class java.lang.NullPointerException
      promise.resolve(message);
    }
  }

TS Type definition error:

截屏2024-11-08 12 00 33

Screenshots Link

No response

lgz5689 commented 3 weeks ago

Ok, thank you for reminding me, this type error will be fixed in the next update.

OrrinHatch commented 2 weeks ago

好的,谢谢提醒,下次更新时会修复这个类型错误。

The most important thing is that video messages cannot be created.

lgz5689 commented 2 weeks ago
  1. Try to use createVideoMessageFromFullPath method, and in the android source code to modify the SDK, the method of confirm createVideoMessageFromFullPath return content at the same time is a JSON string image

  2. Regarding the type declaration, this issue has been updated in previous versions to use the latest version image

  3. If there is still a problem, please provide more logs about sdk-core, or you try adding more logs manually, otherwise the problem cannot be located.