tulir / whatsmeow

Go library for the WhatsApp web multidevice API
https://go.mau.fi/whatsmeow
Mozilla Public License 2.0
2.15k stars 400 forks source link

Audio VN (PTT) cant play in iOS #599

Closed azickri closed 2 months ago

azickri commented 4 months ago

Hello, Whatsmeow Team.

I have used whatsmeow for our application, it is lighter to run than other packages. We experienced problems when we wanted to send an Audio Message when ptt was true, our audio file was .ogg. But, when the receiver is Android as well as Web it works fine.

Code example

seconds := helper.GetAudioDuration(filepath)
ptt := false
audiotype := "audio/mpeg"

if mimetype == "audio/ogg" {
    audiotype = "audio/ogg; codecs=opus"
    ptt = true
}

AudioMessage: &waProto.AudioMessage{
    Url:              proto.String(uploaded.URL),
    DirectPath:       proto.String(uploaded.DirectPath),
    MediaKey:         uploaded.MediaKey,
    Mimetype:         proto.String(audiotype), // audio/ogg for ptt is true
    FileEncSha256:    uploaded.FileEncSHA256,
    FileSha256:       uploaded.FileSHA256,
    FileLength:       proto.Uint64(uint64(len(data))),
    Seconds:          &seconds,
    Ptt:              &ptt,
    ContextInfo:      messageContextInfo,
    StreamingSidecar: []byte(*proto.String("QpmXDsU7YLagdg==")),
    Waveform:         []byte(*proto.String("OjAnExISDgsKCAkJBwgkHAQEBBEFAwMNAxAcKCgkFzM0QUE4Jh4eKAoKChcLCwkeFgkJCQo3JiQmIiIRPz8/Ow==")),
},
ahmedRSA commented 4 months ago

invalid encoded audio msg me on telegeram @ahmedarsai know a solution

mikhikhi commented 2 months ago

hi thanks for awesome work, anyone can find solution for "no longer available media" in IOS?

azickri commented 2 months ago

I forgot to close this issue, for those looking for a solution the audio must be converted to 16000kHz frequency so it can be played on iOS

https://github.com/tulir/whatsmeow/issues/517

azickri commented 2 months ago

hi thanks for awesome work, anyone can find solution for "no longer available media" in IOS?

Do you mean that for all Media Messages? Like Images, Videos or Documents?