using System.Collections.Generic;
using LeanCloud.Storage;
namespace LeanCloud.Realtime {
///
/// 音频消息
///
public class LCIMAudioMessage : LCIMFileMessage {
///
/// 时长
///
public double Duration {
get; private set;
}
internal LCIMAudioMessage() {
}
public LCIMAudioMessage(LCFile file) : base(file) {
}
internal override Dictionary Encode() {
Dictionary data = base.Encode();
Dictionary fileData = data[MessageFileKey] as Dictionary;
Dictionary metaData = fileData[MessageDataMetaDataKey] as Dictionary;
if (File.MetaData.TryGetValue(MessageDataMetaDurationKey, out object duration)) {
metaData[MessageDataMetaDurationKey] = duration;
}
return data;
}
internal override void Decode(Dictionary msgData) {
base.Decode(msgData);
if (File.MetaData.TryGetValue(MessageDataMetaDurationKey, out object duration) &&
double.TryParse(duration as string, out double d)) {
Duration = d;
}
}
public override int MessageType => AudioMessageType;
}
}