NIMSDK-AOS  9.16.0
VideoAttachment.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.attachment;
2 
3 import com.netease.nimlib.session.MsgHelper;
4 import com.netease.nimlib.util.JSONHelper;
5 import com.netease.nimlib.util.storage.NimStorageType;
6 
7 import org.json.JSONObject;
8 
12 public class VideoAttachment extends FileAttachment {
13 
14  private int width;
15 
16  private int height;
17 
18  private long duration;
19 
20  public VideoAttachment() {
21 
22  }
23 
24  public VideoAttachment(String attach) {
25  super(attach);
26  }
27 
31  public int getWidth() {
32  return width;
33  }
34 
38  public void setWidth(int width) {
39  this.width = width;
40  }
41 
45  public int getHeight() {
46  return height;
47  }
48 
52  public void setHeight(int height) {
53  this.height = height;
54  }
55 
61  public long getDuration() {
62  return duration;
63  }
64 
68  public void setDuration(long duration) {
69  this.duration = duration;
70  }
71 
76  public String getThumbUrl() {
77  return MsgHelper.getThumbUrl(this, getUrl());
78  }
79 
80  @Override
81  protected NimStorageType storageType() {
82  return NimStorageType.TYPE_VIDEO;
83  }
84 
85  private static final String KEY_DURATION = "dur";
86  private static final String KEY_WIDTH = "w";
87  private static final String KEY_HEIGHT = "h";
88 
89  @Override
90  protected void save(JSONObject json) {
91  JSONHelper.put(json, KEY_WIDTH, width);
92  JSONHelper.put(json, KEY_HEIGHT, height);
93  JSONHelper.put(json, KEY_DURATION, duration);
94  }
95 
96  @Override
97  protected void load(JSONObject json) {
98  width = JSONHelper.getInt(json, KEY_WIDTH);
99  height = JSONHelper.getInt(json, KEY_HEIGHT);
100  duration = JSONHelper.getInt(json, KEY_DURATION);
101  }
102 }
String getUrl()
获取文件在服务器上的下载url。若文件还未上传,返回null
void setHeight(int height)
设置视频的高度
带有文件的附件类型的基类 描述文件的相关信息
void setDuration(long duration)
设置视频的播放时长
void setWidth(int width)
设置视频的宽度