Closed gerlim29 closed 5 years ago
I traced and checked the response from the HandleDocumentMessage
and I was able to find out that the Type for these media files are
Documents
.DOCX/.DOC = application/vnd.openxmlformats-officedocument.wordprocessingml.document
.XLSX = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.PDF = application/pdf
Zip Files
.DEB = application/vnd.debian.binary-package
.GZ = application/gzip
.ZIP = application/zip
.7z = application/x-7z-compressed
PS: I can't still figure out how mp3 attachments are sent
any update on this ? should i create new issue ? hope this feature (at least send video, document) are available in go-whatsapp
this work for me:
audio, err := os.Open("audio.wav") //<--- msg2 := whatsapp.AudioMessage{ Info: whatsapp.MessageInfo{ RemoteJid: "5547***@s.whatsapp.net", }, Type: "audio/ogg; codecs=opus", //<--- Content: audio, }
i need send on ogg format but can't make this on chrome + angular + opus-media-recorder =/
@codenoid , @Valdenirmezadri
You need to format the media files first before sending it. apparently web.whatsapp.com
formats their media files first in the front-end before sending it through their REST API.
Yes, That's exactly what I can't do in the angular
@Valdenirmezadri
You need to format the media files first before sending it
what kind of format ? can you give me example like sending mp4 file ?
You need to format the media files first before sending it
what kind of format ? can you give me example like sending mp4 file ?
to send for whatsapp, the audio need to be a .ogg file
Good news!!!
After a whole day, I was able to stream audio to .ogg on angular
@Valdenirmezadri
as long as whatsapp suppports the codec even if it isn't .ogg file it will work. even .webm is supported. the only problem I have is for .mp3 which is not also allowed in whatsapp web and application
https://www.videoconverterfactory.com/tips/whatsapp-video-format.html
Sometimes .ogg also won't work if the codec is not correct. whatsapp in my knowledge only accepts a codec of opus for .ogg audio. try download different .ogg files from google and test
i make a test sending the ogg that my angular saved and worked
Hi @Valdenirmezadri! I'm facing this problem rigth now :( could you said us how do you do it with "chrome + angular + opus-media-recorder" please? Perhaps some part of your code help more thanks! :)
Hi @Valdenirmezadri! I'm facing this problem rigth now :( could you said us how do you do it with "chrome + angular + opus-media-recorder" please? Perhaps some part of your code help more thanks! :)
Good morning!
My code:
import OpusMediaRecorder from 'opus-media-recorder';
const options = { mimeType: 'audio/ogg; codecs=opus' }; const workerOptions = { encoderWorkerFactory() { return new Worker('assets/opus/encoderWorker.umd.js'); }, OggOpusEncoderWasmPath: 'OggOpusEncoder.wasm', }; @Component({ ...
private _initiateRecording(): void { navigator.mediaDevices.getUserMedia(this.mediaConstraints).then((stream) => { if (this.recorder && this.recorder.state !== 'inactive') { throw new Error('Stop the recorder first'); } this._createMediaRecorder(stream); }).catch(err => this._errorCallback(err)); }
private _createMediaRecorder(stream: any): void { this.recorder = new OpusMediaRecorder(stream, options, workerOptions);
this.recorder.onstart = () => { this.dataChunks = []; };
this.recorder.ondataavailable = (e: any) => {
this.dataChunks.push(e.data);
};
this.recorder.onstop = () => {
this.blob = new Blob(this.dataChunks, {type: this.recorder.mimeType});
this._processRecording();
};
this._startRecord();
}
private _startRecord(): void { this.recorder.start(); }
private _stopRecording() { this.recorder.stop(); }
private _processRecording() { if (this.sendAudio) { this.recording$.emit(this.blob); } else { this.recording$.emit(new Blob()); } }
private _errorCallback(error: string) { this.error = 'Não foi possível rodar o audio neste navegador'; }
with version 0, 4, 2080 video messages are not sent
notice: for recordings- you MUST use OOG with OPUS codec, mono, sample-rate of 16kHz, bitrate of 21kbs.
Hello i have compiled some of the Type that a certain media file to be sent but I can't seem to figure out what are the other ones for example in this repo you can send image by using this code
This is the code that was currently in the project
and these are the
msg
that I compiled in order to send different types of media filesFor mp4
For ogg
Hope somehow this will help other go-whatsapp devs here
My concern is that i can't seem to figure out what is the type when sending these kinds of file 1) audio (mp3) 2) documents (docx/doc/pdf) any possible document
My code for mp3
This is the error message that I'm receiving when sending mp3
error sending file: message sending responded with %!d(float64=400)
My code for document
I can send the document. The problem is that when viewing it on the receiver phone i can't seem to open it. I believe also that i have a docx/pdf opener on the receiver phone since I can open pdf and docx file from that phone that was downloaded from the internet.