2020-03-18 16:21:29 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using LeanCloud.Storage;
|
2020-03-18 11:41:13 +08:00
|
|
|
|
|
|
|
|
|
namespace LeanCloud.Realtime {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 音频消息
|
|
|
|
|
/// </summary>
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public class LCIMAudioMessage : LCIMFileMessage {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 时长
|
|
|
|
|
/// </summary>
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public double Duration {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
get; private set;
|
2020-03-18 11:41:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 16:21:29 +08:00
|
|
|
|
internal LCIMAudioMessage() {
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public LCIMAudioMessage(LCFile file) : base(file) {
|
2020-03-18 16:21:29 +08:00
|
|
|
|
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
2020-03-18 16:21:29 +08:00
|
|
|
|
|
|
|
|
|
internal override Dictionary<string, object> Encode() {
|
|
|
|
|
Dictionary<string, object> data = base.Encode();
|
2020-04-27 17:44:14 +08:00
|
|
|
|
Dictionary<string, object> fileData = data[MessageFileKey] as Dictionary<string, object>;
|
|
|
|
|
Dictionary<string, object> metaData = fileData[MessageDataMetaDataKey] as Dictionary<string, object>;
|
2020-04-28 11:12:25 +08:00
|
|
|
|
if (File.MetaData != null &&
|
|
|
|
|
File.MetaData.TryGetValue(MessageDataMetaDurationKey, out object duration)) {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
metaData[MessageDataMetaDurationKey] = duration;
|
2020-03-24 17:42:04 +08:00
|
|
|
|
}
|
2020-03-18 16:21:29 +08:00
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 17:44:14 +08:00
|
|
|
|
internal override void Decode(Dictionary<string, object> msgData) {
|
|
|
|
|
base.Decode(msgData);
|
2020-04-28 11:12:25 +08:00
|
|
|
|
|
|
|
|
|
if (File.MetaData == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-27 17:44:14 +08:00
|
|
|
|
if (File.MetaData.TryGetValue(MessageDataMetaDurationKey, out object duration) &&
|
|
|
|
|
double.TryParse(duration as string, out double d)) {
|
|
|
|
|
Duration = d;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int MessageType => AudioMessageType;
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|