NIMSDK-AOS  10.9.80
V2NIMMessageVideoAttachmentBuilder.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.attachment.builder;
2 
5 import com.netease.nimlib.v2.message.impl.attachment.V2NIMMessageVideoAttachmentImpl;
6 
7 /**
8  * 视频消息附件构建器类
9  * 用于构建视频消息附件对象
10  */
12 
13  /**
14  * 文件路径
15  */
16  private String path;
17  /**
18  * 文件显示名称
19  */
20  private String name;
21  /**
22  * 文件大小
23  */
24  private long size;
25  /**
26  * 文件存储场景名
27  * 默认为{@link com.netease.nimlib.sdk.v2.storage.V2NIMStorageSceneConfig#DEFAULT_IM}的getSceneName()值
28  */
29  private String sceneName = V2NIMStorageSceneConfig.DEFAULT_IM.getSceneName();
30  /**
31  * 文件MD5
32  */
33  private String md5;
34  /**
35  * 文件上传服务器路径
36  */
37  private String url;
38  /**
39  * 文件后缀名
40  */
41  private String ext;
42  /**
43  * 视频宽度
44  */
45  private int width;
46  /**
47  * 视频高度
48  */
49  private int height;
50  /**
51  * 视频时长
52  */
53  private int duration;
54 
55  /**
56  * 私有构造函数
57  */
59  }
60 
61  /**
62  * 创建一个新的视频消息附件构建器实例
63  * @return 新的视频消息附件构建器实例
64  */
67  }
68 
69  /**
70  * 设置文件路径
71  * @param path 文件路径
72  * @return 当前构建器实例
73  */
75  this.path = path;
76  return this;
77  }
78 
79  /**
80  * 设置文件显示名称
81  * @param name 文件显示名称
82  * @return 当前构建器实例
83  */
85  this.name = name;
86  return this;
87  }
88 
89  /**
90  * 设置文件大小,如果小于0,则不设置
91  * @param size 文件大小
92  * @return 当前构建器实例
93  */
95  if (size >= 0) {
96  this.size = size;
97  }
98  return this;
99  }
100 
101  /**
102  * 设置文件存储场景名,默认为{@link com.netease.nimlib.sdk.v2.storage.V2NIMStorageSceneConfig#DEFAULT_IM}的getSceneName()值
103  * @param sceneName 存储场景名
104  * @return 当前构建器实例
105  */
107  this.sceneName = sceneName;
108  return this;
109  }
110 
111  /**
112  * 设置文件MD5
113  * @param md5 文件MD5
114  * @return 当前构建器实例
115  */
117  this.md5 = md5;
118  return this;
119  }
120 
121  /**
122  * 设置文件上传服务器路径
123  * @param url 文件上传服务器路径
124  * @return 当前构建器实例
125  */
127  this.url = url;
128  return this;
129  }
130 
131  /**
132  * 设置文件后缀名
133  * @param ext 文件后缀名
134  * @return 当前构建器实例
135  */
137  this.ext = ext;
138  return this;
139  }
140 
141  /**
142  * 设置视频宽度,如果小于0,则不设置
143  * @param width 视频宽度
144  * @return 当前构建器实例
145  */
147  if(width >= 0){
148  this.width = width;
149  }
150  return this;
151  }
152 
153  /**
154  * 设置视频高度,如果小于0,则不设置
155  * @param height 视频高度
156  * @return 当前构建器实例
157  */
159  if(height >= 0){
160  this.height = height;
161  }
162  return this;
163  }
164 
165  /**
166  * 设置视频时长,如果小于0,则不设置
167  * @param duration 视频时长
168  * @return 当前构建器实例
169  */
171  if(duration >= 0){
172  this.duration = duration;
173  }
174  return this;
175  }
176 
177  /**
178  * 构建视频消息附件对象
179  * @return 构建的视频消息附件对象
180  */
182  return new V2NIMMessageVideoAttachmentImpl(path, size, md5, url, ext, name, sceneName, null, duration, width, height);
183  }
184 }
V2NIMMessageVideoAttachmentBuilder withHeight(int height)
设置视频高度,如果小于0,则不设置
V2NIMMessageVideoAttachmentBuilder withSceneName(String sceneName)
设置文件存储场景名,默认为com.netease.nimlib.sdk.v2.storage.V2NIMStorageSceneConfig#DEFAULT_IM的getSc...
V2NIMMessageVideoAttachmentBuilder withDuration(int duration)
设置视频时长,如果小于0,则不设置
V2NIMMessageVideoAttachmentBuilder withSize(long size)
设置文件大小,如果小于0,则不设置
static final V2NIMStorageScene DEFAULT_IM
默认文件类型等场景 默认不过期
V2NIMMessageVideoAttachmentBuilder withName(String name)
设置文件显示名称
static V2NIMMessageVideoAttachmentBuilder builder()
创建一个新的视频消息附件构建器实例
V2NIMMessageVideoAttachmentBuilder withUrl(String url)
设置文件上传服务器路径
V2NIMMessageVideoAttachmentBuilder withWidth(int width)
设置视频宽度,如果小于0,则不设置