1
This commit is contained in:
@@ -479,23 +479,23 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
|
||||
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
|
||||
if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {
|
||||
sound := sounds[1]
|
||||
printer := model.Printer{}
|
||||
printer.Volume = 4
|
||||
printer.Sound = "sounda"
|
||||
//printer := model.Printer{}
|
||||
//printer.Volume = 4
|
||||
//printer.Sound = "sounda"
|
||||
//if printer, _ := dao.GetPrinter(dao.GetDB(), printMsg.PrintNo); printer != nil {
|
||||
//先把结束标签消了
|
||||
result = strings.ReplaceAll(result, byteSignSoundE, "")
|
||||
//fd 固定
|
||||
//001a (声音数据长度高八位低八位)
|
||||
//0101 固定
|
||||
soundPrefix := ""
|
||||
if printer.Sound != "" {
|
||||
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
|
||||
} else {
|
||||
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
|
||||
}
|
||||
hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
|
||||
hexPrefixStr := hex.EncodeToString(hexPrefix)
|
||||
//soundPrefix := ""
|
||||
//if printer.Sound != "" {
|
||||
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
|
||||
//} else {
|
||||
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
|
||||
//}
|
||||
//hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
|
||||
//hexPrefixStr := hex.EncodeToString(hexPrefix)
|
||||
|
||||
// 将语音包转换为十六进制
|
||||
voice := ""
|
||||
@@ -509,16 +509,16 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
|
||||
voiceData := hex.EncodeToString(voiceDataGBK)
|
||||
|
||||
//[8]sounda14 ->5b385d736f756e64613134
|
||||
realSound := hexPrefixStr + voiceData
|
||||
allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)
|
||||
//realSound := hexPrefixStr + voiceData
|
||||
realSound := voiceData
|
||||
allLen := fmt.Sprintf("%x", (len(realSound))/2)
|
||||
if len(allLen) < 2 {
|
||||
allLen = "0" + allLen
|
||||
}
|
||||
|
||||
//soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2))
|
||||
//result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr)
|
||||
result = strings.ReplaceAll(result, byteSignSound, hexSignSoundOld+hexPrefixStr)
|
||||
result = strings.ReplaceAll(result, byteSignSoundE, "")
|
||||
result = strings.ReplaceAll(result, byteSignSound, hexSignSoundOld+realSound)
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user