AllInOneYT / react-native-thermal-printer

MIT License
102 stars 51 forks source link

How can I play the printer sound #34

Closed gsolorzanob closed 2 years ago

gsolorzanob commented 2 years ago

Hey, I can't find how to play the beep sound while printing.

Any solution?

AllInOneYT commented 2 years ago

adding this two lines works for me

printerConnection.write(new byte[]{27, 66, 2, 1});
printerConnection.send(0);
gsolorzanob commented 2 years ago

Excuse me, where can I add these lines?

AllInOneYT commented 2 years ago

whetther here before printing

https://github.com/AllInOneYT/react-native-thermal-printer/blob/9d5df0358f7e2306f25f730b334ce14743b091b5/android/src/main/java/com/reactnativethermalprinter/ThermalPrinterModule.java#L182

or here after printing https://github.com/AllInOneYT/react-native-thermal-printer/blob/9d5df0358f7e2306f25f730b334ce14743b091b5/android/src/main/java/com/reactnativethermalprinter/ThermalPrinterModule.java#L190

or both

The reason it is not included in the library is that printer sound is originally intended for warnings and errors.

gsolorzanob commented 2 years ago

Thank u, it works!!!

thanhchuongbmd commented 2 years ago

adding this two lines works for me

printerConnection.write(new byte[]{27, 66, 2, 1});
printerConnection.send(0);

This sound is short. What the params for sound longer or volume greater?

AllInOneYT commented 2 years ago

adding this two lines works for me

printerConnection.write(new byte[]{27, 66, 2, 1});
printerConnection.send(0);

This sound is short. What the params for sound longer or volume greater?

you cannot change the volume of the sound as far as I know. refer to this issue https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/issues/142 for more information

thanhchuongbmd commented 2 years ago

adding this two lines works for me

printerConnection.write(new byte[]{27, 66, 2, 1});
printerConnection.send(0);

This sound is short. What the params for sound longer or volume greater?

you cannot change the volume of the sound as far as I know. refer to this issue DantSu/ESCPOS-ThermalPrinter-Android#142 for more information

Thank you!