Class MediaHelper
媒体辅助静态类
Namespace: Fleet.Mobile.Containers.Media
Assembly: FleetMobile.dll
Syntax
public static class MediaHelper
Fields
MaxAttachmentSingleLength
最大单个附件大小,单位字节,默认值 20_971_520 (MaxAttachmentSingleLengthMB * 1024 * 1024)
Declaration
public const int MaxAttachmentSingleLength = 20971520
Field Value
| int |
MaxAttachmentSingleLengthMB
MaxAttachmentVideoCount
MaxBitrateKb
MaxImageHeight
MaxImageWidth
MaxVideoLengthSec
MaxVideoLengthUs
最大视频长度,单位微秒,默认值 25_000_000 (MaxVideoLengthSec * 1000L * 1000L)
Declaration
public const long MaxVideoLengthUs = 25000000
Field Value
| long |
ScanDelay
Properties
MaxAttachmentLength
获取最大附件允许大小,单位字节,默认值 104_857_600 (MaxAttachmentLengthMB * 1024 * 1024)
Declaration
public static int MaxAttachmentLength { get; }
Property Value
| int |
MaxAttachmentLengthMB
获取最大附件允许大小,单位 MB,默认值 100
Declaration
public static int MaxAttachmentLengthMB { get; }
Property Value
| int |
Methods
GuessImageExtension(byte[])
根据数据内容获取相应格式的扩展名。
Declaration
public static string GuessImageExtension(byte[] data)
Parameters
|
byte[]
data
文件数据 |
Returns
|
string
返回格式的扩展名 |
IsPicture(string)
根据扩展名判断是否为图片格式。
Declaration
public static bool IsPicture(string ext)
Parameters
|
string
ext
扩展名 |
Returns
|
bool
true 则表示该类型为图片类型 |
IsUrlType(string)
根据字符串判断是否为 URL 类型。
Declaration
public static bool IsUrlType(string type)
Parameters
|
string
type
类型字符串 |
Returns
|
bool
true 则表示类型忽略大小写等于 "URL" |
IsVideo(string)
根据扩展名判断是否为视频格式。
Declaration
public static bool IsVideo(string ext)
Parameters
|
string
ext
扩展名 |
Returns
|
bool
true 则表示该类型为视频类型 |
PickMediaAsync(Action<float>, int)
弹出媒体选择器并返回选择结果。
Declaration
public static Task<IEnumerable<PickerFile>> PickMediaAsync(Action<float> step, int maxLimit = 50)
Parameters
|
Action<float>
step
进度处理回调 |
|
int
maxLimit
最大选择数量限制,默认 50 |
Returns
|
Task<IEnumerable<PickerFile>>
返回选择的文件枚举 |
ReadFromFileAsync(PickerFile, Stream, bool, long)
Declaration
public static Task<MediaItem> ReadFromFileAsync(PickerFile file, Stream fs, bool editing = false, long limit = 20971520)
Parameters
| PickerFile file |
| Stream fs |
| bool editing |
| long limit |
Returns
| Task<MediaItem> |
ResizeImage(byte[])
若图片数据大于 400KB,则压缩图片数据,压缩格式为 Jpeg,质量 90,最大分辨率不超过 (MaxImageWidth, MaxImageHeight)。
Declaration
public static byte[] ResizeImage(byte[] content)
Parameters
|
byte[]
content
图片数据 |
Returns
|
byte[]
返回压缩后的数据 |
ResizeImageOld(byte[])
若图片数据大于 400KB,则压缩图片数据,最大分辨率不超过 (MaxImageWidth, MaxImageHeight)。
Declaration
public static byte[] ResizeImageOld(byte[] content)
Parameters
|
byte[]
content
图片数据 |
Returns
|
byte[]
返回压缩后的数据 |
TakePhotoAsync()
弹出拍照页面并返回图片文件结果。
Declaration
public static Task<MediaPickerFile> TakePhotoAsync()
Returns
|
Task<MediaPickerFile>
返回图片文件 |
TakeVideoAsync(Action<float>)
弹出录像页面并返回视频文件结果。
Declaration
public static Task<MediaPickerFile> TakeVideoAsync(Action<float> step)
Parameters
|
Action<float>
step
进度处理回调 |
Returns
|
Task<MediaPickerFile>
返回视频文件 |