i want play notification sound vaadin based website on android , ios devices. notification sound works perfect on desktops. how work on mobile devices.
i using "audio" component, no controls displayed, , "play" when need it. short sound , small file.
edit 6/1/2017 ( current implementation ): first of all, in constructor simple form:
barcode.setinputprompt("barcode"); barcode.setcaption("barcode"); barcode.setmaxlength(22); barcode.setnullrepresentation(""); barcode.setrequired(true); submit = new button("submit"); addcomponents(barcode, facilityid, submit ); submit.setstylename(valotheme.button_primary); submit.setclickshortcut(keycode.enter); submit.addclicklistener(e->this.handlesubmit()); goodscan = new audio(null, new themeresource( "sounds/good-scan.mp3")); goodscan.setautoplay(false); goodscan.setshowcontrols(false); badscan = new audio(null, new themeresource( "sounds/bad-scan.mp3")); badscan.setautoplay(false); badscan.setshowcontrols(false); addcomponents( goodscan, badscan );
note turned auto-play , controls off, won't show on screen. actually, @ least in case, "setshowcontrtols(false)" hides things, seems. later, in submit method, have ( "..." unrelated code ):
private void submit() { try { ... barcode.setvalue(null); barcode.focus(); goodscan.play(); } catch (wmsexception e) { ... notification.show("consumption scan error", message, type.error_message); barcode.focus(); badscan.play(); } ... }
the above works on desktops, not work consistently ( if @ ) on android , ios devices. have not dug since original post because have had no ideas myself, , people have asked did not have new offer.
all said, above code should work vaadin 8 ( knock on wood ), might you, basil.
Comments
Post a Comment