12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Camera Example</title>
- <script src="js/mui.js"></script>
- <link href="css/mui.css" rel="stylesheet" />
- <script type="text/javascript">
- // 扩展API加载完毕后调用onPlusReady回调函数
- document.addEventListener( "plusready", onPlusReady, false );
- // 扩展API加载完毕,现在可以正常调用扩展API
- function onPlusReady() {
- console.log("plusready");
- }
- var cmr=null;
- // 摄像
- function videoCapture(){
- cmr = plus.camera.getCamera();
- var res = cmr.supportedVideoResolutions[0];
- var fmt = cmr.supportedVideoFormats[0];
- console.log("Resolution: "+res+", Format: "+fmt);
- cmr.startVideoCapture( function( path ){
- alert( "Capture video success: " + path );
- },
- function( error ) {
- alert( "Capture video failed: " + error.message );
- },
- {resolution:res,format:fmt}
- );
- // 拍摄10s后自动完成
- setTimeout( stopCapture, 10000 );
- }
- // 停止摄像
- function stopCapture(){
- console.log("stopCapture");
- cmr.stopVideoCapture();
- }
- </script>
- </head>
- <body>
- <button onclick="videoCapture()">摄像</button><br/>
- <button onclick="stopCapture()">停止摄像</button>
- <button type="button" data-loading-text="获取验证码" class="mui-btn" id="btn" >确认</button>
- </body>
- <script>
- var i=10;
- mui(document.body).on('tap', '.mui-btn', function(e) {
- debugger
- mui(this).button('loading');
- var interval=setInterval(function() {
- document.getElementById("btn").innerHTML=i;
- i--;
- if(i==0){
- i=10;
- mui(this).button('reset');
- document.getElementById("btn").innerHTML="获取验证码";
- clearInterval(interval);
- }
- }.bind(this), 1000);
- });
- </script>
- </html>
|