Commit 17b1863a92078d79b19164d6f9da1eca75173aa8
1 parent
4df339fb
no message
Showing
3 changed files
with
112 additions
and
1 deletions
CNLiveBusinessTools/Classes/CNLiveBusinessTools.h
| @@ -13,7 +13,12 @@ typedef NS_ENUM(NSInteger, CNStatType) { | @@ -13,7 +13,12 @@ typedef NS_ENUM(NSInteger, CNStatType) { | ||
| 13 | CNStatTypeContentDuration, //内容时长统计 | 13 | CNStatTypeContentDuration, //内容时长统计 |
| 14 | CNStatTypeShareCount //分享次数统计 | 14 | CNStatTypeShareCount //分享次数统计 |
| 15 | }; | 15 | }; |
| 16 | - | 16 | +#pragma mark 文件类型 |
| 17 | +typedef NS_ENUM(NSInteger, CNFileType) { | ||
| 18 | + CNFileTypeReadAndLook = 0,//识别和预览 | ||
| 19 | + CNFileTypeOnlyRead, //只能识别,不能预览 | ||
| 20 | + CNFileTypeUnkown, //未知文件 | ||
| 21 | +}; | ||
| 17 | @interface CNLiveBusinessTools : NSObject | 22 | @interface CNLiveBusinessTools : NSObject |
| 18 | #pragma mark -- 统计 | 23 | #pragma mark -- 统计 |
| 19 | /** | 24 | /** |
| @@ -38,6 +43,12 @@ typedef NS_ENUM(NSInteger, CNStatType) { | @@ -38,6 +43,12 @@ typedef NS_ENUM(NSInteger, CNStatType) { | ||
| 38 | + (BOOL)isGif:(id)asset; | 43 | + (BOOL)isGif:(id)asset; |
| 39 | + (BOOL)isGifWithImageData: (NSData *)data; | 44 | + (BOOL)isGifWithImageData: (NSData *)data; |
| 40 | #pragma mark -- | 45 | #pragma mark -- |
| 46 | +#pragma mark -- 文件 | ||
| 47 | +///文件类型 | ||
| 48 | ++ (NSDictionary *)fileTypeDic; | ||
| 49 | +//通过文件后缀名判断是否为可读文件 | ||
| 50 | ++ (CNFileType)isReadedFileByType:(NSString *)suffixType; | ||
| 51 | +#pragma mark -- | ||
| 41 | @end | 52 | @end |
| 42 | 53 | ||
| 43 | NS_ASSUME_NONNULL_END | 54 | NS_ASSUME_NONNULL_END |
CNLiveBusinessTools/Classes/CNLiveBusinessTools.m
| @@ -153,4 +153,104 @@ | @@ -153,4 +153,104 @@ | ||
| 153 | 153 | ||
| 154 | return nil; | 154 | return nil; |
| 155 | } | 155 | } |
| 156 | + | ||
| 157 | ++ (NSDictionary *)fileTypeDic | ||
| 158 | +{ | ||
| 159 | + NSDictionary *dic = | ||
| 160 | + @{ | ||
| 161 | + @".3gp" : @"video/3gpp", | ||
| 162 | + @".apk" : @"application/vnd.android.package-archive", | ||
| 163 | + @".asf" : @"video/x-ms-asf", | ||
| 164 | + @".avi" : @"video/x-msvideo", | ||
| 165 | + @".bin" : @"application/octet-stream", | ||
| 166 | + @".bmp" : @"image/bmp", | ||
| 167 | + @".c" : @"text/plain", | ||
| 168 | + @".class" : @"application/octet-stream", | ||
| 169 | + @".conf" : @"text/plain", | ||
| 170 | + @".cpp" : @"text/plain", | ||
| 171 | + @".doc" : @"application/msword", | ||
| 172 | + @".docx" : @"application/vnd.openxmlformats-officedocument.wordprocessingml.document", | ||
| 173 | + @".xls" : @"application/vnd.ms-excel", | ||
| 174 | + @".xlsx" : @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||
| 175 | + @".exe" : @"application/octet-stream", | ||
| 176 | + @".gif" : @"image/gif", | ||
| 177 | + @".gtar" : @"application/x-gtar", | ||
| 178 | + @".gz" : @"application/x-gzip", | ||
| 179 | + @".h" : @"text/plain", | ||
| 180 | + @".htm" : @"text/html", | ||
| 181 | + @".html" : @"text/html", | ||
| 182 | + @".jar" : @"application/java-archive", | ||
| 183 | + @".java" : @"text/plain", | ||
| 184 | + @".jpeg" : @"image/jpeg", | ||
| 185 | + @".jpg" : @"image/jpeg", | ||
| 186 | + @".js" : @"application/x-javascript", | ||
| 187 | + @".log" : @"text/plain", | ||
| 188 | + @".m3u" : @"audio/x-mpegurl", | ||
| 189 | + @".m4a" : @"audio/mp4a-latm", | ||
| 190 | + @".m4b" : @"audio/mp4a-latm", | ||
| 191 | + @".m4p" : @"audio/mp4a-latm", | ||
| 192 | + @".m4u" : @"video/vnd.mpegurl", | ||
| 193 | + @".m4v" : @"video/x-m4v", | ||
| 194 | + @".mov" : @"video/quicktime", | ||
| 195 | + @".mp2" : @"audio/x-mpeg", | ||
| 196 | + @".mp3" : @"audio/x-mpeg", | ||
| 197 | + @".mp4" : @"video/mp4", | ||
| 198 | + @".mpc" : @"application/vnd.mpohun.certificate", | ||
| 199 | + @".mpe" : @"video/mpeg", | ||
| 200 | + @".mpeg" : @"video/mpeg", | ||
| 201 | + @".mpg" : @"video/mpeg", | ||
| 202 | + @".mpg4" : @"video/mp4", | ||
| 203 | + @".mpga" : @"audio/mpeg", | ||
| 204 | + @".msg" : @"application/vnd.ms-outlook", | ||
| 205 | + @".ogg" : @"audio/ogg", | ||
| 206 | + @".pdf" : @"application/pdf", | ||
| 207 | + @".png" : @"image/png", | ||
| 208 | + @".pps" : @"application/vnd.ms-powerpoint", | ||
| 209 | + @".ppt" : @"application/vnd.ms-powerpoint", | ||
| 210 | + @".pptx" : @"application/vnd.openxmlformats-officedocument.presentationml.presentation", | ||
| 211 | + @".prop" : @"text/plain", | ||
| 212 | + @".rc" : @"text/plain", | ||
| 213 | + @".rmvb" : @"audio/x-pn-realaudio", | ||
| 214 | + @".rtf" : @"application/rtf", | ||
| 215 | + @".sh" : @"text/plain", | ||
| 216 | + @".tar" : @"application/x-tar", | ||
| 217 | + @".tgz" : @"application/x-compressed", | ||
| 218 | + @".txt" : @"text/plain", | ||
| 219 | + @".wav" : @"audio/x-wav", | ||
| 220 | + @".wma" : @"audio/x-ms-wma", | ||
| 221 | + @".wmv" : @"audio/x-ms-wmv", | ||
| 222 | + @".wps" : @"application/vnd.ms-works", | ||
| 223 | + @".xml" : @"text/plain", | ||
| 224 | + @".z" : @"application/x-compress", | ||
| 225 | + @".h" : @"text/h-text", | ||
| 226 | + @".m" : @"text/m-text", | ||
| 227 | + @".json": @"text/json-text", | ||
| 228 | + @".key" : @"application/vnd.ms-powerpoint", | ||
| 229 | + @".numbers" : @"application/vnd.ms-excel", | ||
| 230 | + @".pages" : @"application/vnd.openxmlformats-officedocument.wordprocessingml.document" | ||
| 231 | + }; | ||
| 232 | + | ||
| 233 | + return dic; | ||
| 234 | +} | ||
| 235 | ++ (CNFileType)isReadedFileByType:(NSString *)suffixType | ||
| 236 | +{ | ||
| 237 | + if ([[CNLiveBusinessTools fileTypeDic] objectForKey:[NSString stringWithFormat:@".%@",suffixType]]) { | ||
| 238 | + return CNFileTypeReadAndLook; | ||
| 239 | + } | ||
| 240 | + else if ([[CNLiveBusinessTools onlyReadFileType] objectForKey:[NSString stringWithFormat:@".%@",suffixType]]) | ||
| 241 | + { | ||
| 242 | + return CNFileTypeOnlyRead; | ||
| 243 | + } | ||
| 244 | + else | ||
| 245 | + return CNFileTypeUnkown; | ||
| 246 | +} | ||
| 247 | +// 文件知道其类型,但是无法预览 | ||
| 248 | ++ (NSDictionary *)onlyReadFileType | ||
| 249 | +{ | ||
| 250 | + NSDictionary *dic = @{ | ||
| 251 | + @".zip" : @"application/x-zip-compressed", | ||
| 252 | + | ||
| 253 | + }; | ||
| 254 | + return dic; | ||
| 255 | +} | ||
| 156 | @end | 256 | @end |
CNLiveBusinessTools/Classes/ReplaceMe.m deleted
100644 → 0