0
How to start/stop barcode scanning
I have added barcode reading functionality to my app, but the camera seems to be continuously scanning, even when the camera panel is hidden. In order to prevent multiple scans, I was trying to implement a button to show the camera panel and start scanning, and upon a successful scan, show another panel (which I thought would stop the scanning, but apparently not).
Edited code:
Edited code:
<wire>
<main>
<panel name="background" alias="BACK" height="100%" width="100%" background="#0000ee">
<toolbar name="toolbar" height="10%" width="100%" align="left" valign="top">
<panel name="button" width="30%" height="80%" align="left" margin="10" valign="center" background="#888888" cornerradius="5" onclickup="camera-return">
<text name="back" width="90%" height="90%" color="#000000" font="" size="9" align="center" valign="center" text="Scan"></text>
</panel>
</toolbar>
<panel name="camerapanel" alias="CAMERA-PANEL" height="90%" width="100%" valign="bottom" hidden="yes">
<camera alias="CAMERA" name="panel" type="barcodescan" onscan="qrcode_action"
background="#FFFFFF" height="100%" width="100%" align="center" valign="bottom">
<panel name="box" height="150" width="50%" align="center" ypos="30%" borderwidth="2" bordercolor="ff0000" />
</camera>
<text name="title1" text="Scanning..." font="helvetica" size="24" width="100%" height="10%" alignment="center" valign="bottom" align="left" color="#FFFFFF" background="#000000" alpha="0.5"/>
</panel>
<panel name="splash" alias="SPLASH" height="90%" width="100%" valign="bottom" hidden="no" background="#ffffff">
<text name="back" width="90%" height="90%" color="#000000" font="" size="9" align="center" valign="center" text="This is a splash panel"></text>
</panel>
</panel>
</main>
<actions>
<action name="qrcode_action">
<!-- set some values -->
<play action="splash-return"/>
<!-- prevent another scan while dealing with the qr code info -->
</action>
<action name="camera-return">
<replace type="flipleft" target="CAMERA-PANEL" replacement="SPLASH" time="1"/>
</action>
<action name="splash-return">
<replace type="flipleft" target="SPLASH" replacement="CAMERA-PANEL" time="1"/>
</action>
</actions>
</wire>
Kundesupport af UserEcho
To do this you will want to move your camera tag into a class and use create and delete actions to place it and remove it from your CAMERA-PANEL object.
Let me know if you have any more questions.
My shortened code below, with creating and deleting of classes:
If this doesn't work, feel free to add me as a collaborator to the project and I will take a look at the code. (icahill@rarewire.com)