NIMSDK-AOS  10.5.0
AudioAttachment.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.attachment;
2 
3 import com.netease.nimlib.util.JSONHelper;
4 import com.netease.nimlib.util.storage.NimStorageType;
5 
6 import org.json.JSONObject;
7 
11 public class AudioAttachment extends FileAttachment {
12 
13  private long duration;
14  private boolean autoTransform; //是否自动转换为文本消息发送
15  private String text;
16 
17  public AudioAttachment() {
18 
19  }
20 
21  public AudioAttachment(String attach) {
22  super(attach);
23  }
24 
29  public long getDuration() {
30  return duration;
31  }
32 
36  public void setDuration(long duration) {
37  this.duration = duration;
38  }
39 
40  public static final String KEY_DURATION = "dur";
41 
42  public boolean getAutoTransform() {
43  return autoTransform;
44  }
45 
46  public void setAutoTransform(boolean autoTransform) {
47  this.autoTransform = autoTransform;
48  }
49 
50  public String getText() {
51  return text;
52  }
53 
54  public void setText(String text) {
55  this.text = text;
56  }
57 
58  @Override
59  protected NimStorageType storageType() {
60  return NimStorageType.TYPE_AUDIO;
61  }
62 
63  @Override
64  protected void save(JSONObject json) {
65  JSONHelper.put(json, KEY_DURATION, duration);
66  }
67 
68  @Override
69  protected void load(JSONObject json) {
70  duration = JSONHelper.getInt(json, KEY_DURATION);
71  }
72 }
带有文件的附件类型的基类 描述文件的相关信息
void setDuration(long duration)
设置音频的播放时长