<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # [camera]() Camera模塊管理設備的攝像頭,可用于拍照、攝像操作,通過plus.camera獲取攝像頭管理對象。 ### 方法: - [getCamera](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.getCamera): 獲取攝像頭管理對象 ### 對象: - [Camera](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera): 攝像頭對象 - [CameraOption](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraOption): JSON對象,調用攝像頭的參數 - [PopPosition](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.PopPosition): JSON對象,彈出拍照或攝像界面指示位置 ### 回調方法: - [CameraSuccessCallback](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraSuccessCallback): 調用攝像頭操作成功回調 - [CameraErrorCallback](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraErrorCallback): 攝像頭操作失敗回調 ### 權限: permissions ~~~ "Camera": { "description": "訪問攝像頭設備" } ~~~ # [getCamera]() 獲取攝像頭管理對象 ~~~ Camera plus.camera.getCamera( index ); ~~~ ### 說明: 獲取需要操作的攝像頭對象,如果要進行拍照或攝像操作,需先通過此方法獲取攝像頭對象。 ### 參數: - index: *( Number ) 可選 *要獲取攝像頭的索引值 指定要獲取攝像頭的索引值,1表示主攝像頭,2表示輔攝像頭。如果沒有設置則使用系統默認主攝像頭。 ### 返回值: [Camera](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera) : 攝像頭對象 ### 平臺支持: - Android - 2.2+ (支持) - iOS - 4.3+ (支持) ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); var r = null; // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { // 獲取設備默認的攝像頭對象 var cmr = plus.camera.getCamera(); // ...... } </script> </head> <body> </body> </html> ~~~ # [Camera]() 攝像頭對象 ~~~ interface Camera { readonly attribute DOMString[] supportedImageResolutions; readonly attribute DOMString[] supportedVideoResolutions; readonly attribute DOMString[] supportedImageFormats; readonly attribute DOMString[] supportedVideoFormats; function void captureImage( successCB, errorCB, option ); function void startVideoCapture( successCB, errorCB, option ); function void stopVideoCapture(); } ~~~ ### 屬性: - [supportedImageResolutions](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.supportedImageResolutions): 字符串數組,攝像頭支持的拍照分辨率 - [supportedVideoResolutions](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.supportedVideoResolutions): 字符串數組,攝像頭支持的攝像分辨率 - [supportedImageFormats](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.supportedImageFormats): 字符串數組,攝像頭支持的拍照文件格式 - [supportedVideoFormats](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.supportedVideoFormats): 字符串數組,攝像頭支持的攝像文件格式 ### 方法: - [captureImage](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.captureImage): 進行拍照操作 - [startVideoCapture](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.startVideoCapture): 調用攝像頭進行攝像操作 - [stopVideoCapture](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.Camera.stopVideoCapture): 結束攝像操作 # [supportedImageResolutions]() 字符串數組,攝像頭支持的拍照分辨率 ### 說明: Array 類型 只讀屬性 屬性類型為DOMString[],若不支持此屬性則返回空數組對象。攝像頭支持的拍照圖片分辨率字符串形式“WIDTH*Height”,如“400*800”;如果支持任意自定義分辨率則“*”。 ### 平臺支持: - Android (支持) - iOS (不支持): 返回空數組對象 ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); alert( "Camera supperted image resolutions: " + cmr.supportedImageResolutions ); } </script> </head> <body> </body> </html> ~~~ # [supportedVideoResolutions]() 字符串數組,攝像頭支持的攝像分辨率 ### 說明: Array 類型 只讀屬性 屬性類型為String[],若不支持此屬性則返回空數組對象。攝像頭支持的視頻分辨率字符串形式為“WIDTH*Height”,如“400*800”;如果支持任意自定義分辨率則“*”。 ### 平臺支持: - Android (支持) - iOS (不支持): 返回空數組對象 ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); alert( "Camera supperted image resolutions: " + cmr.supportedImageResolutions ); } </script> </head> <body> </body> </html> ~~~ # [supportedImageFormats]() 字符串數組,攝像頭支持的拍照文件格式 ### 說明: Array 類型 只讀屬性 屬性類型為String[],若不支持此屬性則返回空數組對象。攝像頭支持的圖片文件格式字符串形式為文件格式后綴名,如“jpg”、“png”、“bmp”。 ### 平臺支持: - Android (支持) - iOS (不支持): 返回空數組對象 ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); alert( "Camera supperted image formats: " + cmr.supportedImageFormats ); } </script> </head> <body> </body> </html> ~~~ # [supportedVideoFormats]() 字符串數組,攝像頭支持的攝像文件格式 ### 說明: Array 類型 只讀屬性 屬性類型為String[],若不支持此屬性則返回空數組對象。攝像頭支持的視頻文件格式字符串形式為文件格式后綴名,如“3gp”、“mp4”、“avi”。 ### 平臺支持: - Android (支持) - iOS (不支持): 返回空數組對象 ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); alert( "Camera supperted video formats: " + cmr.supportedVideoFormats ); } </script> </head> <body> </body> </html> ~~~ # [captureImage]() 進行拍照操作 ~~~ cmr.captureImage( successCB, errorCB, option ); ~~~ ### 說明: 攝像頭資源為獨占資源,如果其它程序或頁面已經占用攝像頭,再次操作則失敗。 拍照操作成功將通過successCB返回拍照獲取的圖片路徑。 可通過option設置攝像頭的各種屬性參數。 ### 參數: - successCB: *( [CameraSuccessCallback](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraSuccessCallback) ) 必選 *拍照操作成功的回調函數 - errorCB: *( [CameraErrorCallback](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraErrorCallback) ) 可選 *拍照操作失敗的回調函數 - option: *( [CameraOption](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraOption) ) 必選 *攝像頭拍照參數 ### 返回值: void : 無 ### 平臺支持: - Android - 2.2+ (支持) - iOS - 4.3+ (支持) ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); var r = null; // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); var res = cmr.supportedImageResolutions[0]; var fmt = cmr.supportedImageFormats[0]; cmr.captureImage( function( path ){ alert( "Capture image success: " + path ); }, function( error ) { alert( "Capture image failed: " + error.message ); }, {resolution:res, format:fmt } ); } </script> </head> <body> </body> </html> ~~~ # [startVideoCapture]() 調用攝像頭進行攝像操作 ~~~ cmr.startVideoCapture( successCB, errorCB, option ); ~~~ ### 說明: 攝像頭資源為獨占資源,如果其它程序或頁面已經占用攝像頭,再次操作則失敗。 拍照操作成功將通過successCB返回攝像獲取的視頻文件路徑。 可通過option設置攝像頭的各種屬性參數。 ### 參數: - successCB: *( [CameraSuccessCallback](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraSuccessCallback) ) 必選 *攝像操作成功的回調函數 - errorCB: *( [CameraErrorCallback](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraErrorCallback) ) 可選 *拍攝像操作失敗的回調函數 - option: *( [CameraOption](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.CameraOption) ) 必選 *攝像頭拍照參數 ### 返回值: void : 無 ### 平臺支持: - Android - 2.2+ (支持) - iOS - 4.3+ (支持) ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); var r = null; // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); var res = cmr.supportedVideoResolutions[0]; var fmt = cmr.supportedVideoFormats[0]; cmr.startVideoCapture( function( path ){ alert( "Capture video success: " + path ); }, function( error ) { alert( "Capture video failed: " + error.message ); }, {resolution:res, format:fmt } ); } </script> </head> <body> </body> </html> ~~~ # [stopVideoCapture]() 結束攝像操作 ~~~ cmr.stopVideoCapture(); ~~~ ### 說明: 開始調用攝像頭進行攝像操作后,可在后臺結束攝像操作,與用戶在界面結束操作效果一致。 攝像操作成功將通過startVideoCapture函數中的successCB返回拍照獲取的圖片路徑。 用戶如果沒有進行攝像操作關閉攝像頭頁面則調用失敗回調函數。 ### 參數: ### 返回值: void : 無 ### 平臺支持: - Android - 2.2+ (支持) - iOS - 4.3+ (支持) ### 示例: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Camera Example</title> <script type="text/javascript"> // 擴展API加載完畢后調用onPlusReady回調函數 document.addEventListener( "plusready", onPlusReady, false ); var r = null; // 擴展API加載完畢,現在可以正常調用擴展API function onPlusReady() { var cmr = plus.camera.getCamera(); var res = cmr.supportedVideoResolutions[0]; var fmt = cmr.supportedVideoFormats[0]; cmr.startVideoCapture( function( path ){ alert( "Capture video success: " + path ); }, function( error ) { alert( "Capture video failed: " + error.message ); }, {resolution:res, format:fmt } ); // 拍攝10s后自動完成 setTimeout( function () { cmr.stopVideoCapture(); }, 10000 ); } </script> </head> <body> </body> </html> ~~~ # [CameraOption]() JSON對象,調用攝像頭的參數 ~~~ interface CameraOption { attribute DOMString filename; attribute DOMString format; attribute DOMString index; attribute PopPosition popover; } ~~~ ### 屬性: - filename: *(DOMString 類型)*拍照或攝像文件保存的路徑 可設置具體文件名,也可只設置路徑,如果以“/”結尾則表明是路徑,如未設置文件名稱或設置的文件名沖突則文件名由程序程序自動生成。 - format: *(DOMString 類型)*拍照或攝像的文件格式 可通過Camera對象的supportedImageFormats或supportedVideoFormats獲取,如果設置的參數無效則使用系統默認值。 - index: *(DOMString 類型)*拍照或攝像默認使用的攝像頭 拍照或攝像界面默認使用的攝像頭編號,1表示主攝像頭,2表示輔攝像頭。 - popover: *([PopPosition](http://www.dcloud.io/docs/api/zh_cn/camera.shtml#plus.camera.PopPosition) 類型)*拍照或攝像界面彈出指示區域 對于大屏幕設備如iPad,拍照或攝像界面為彈出窗口,此時可通過此參數設置彈出窗口位置,其為JSON對象,格式如{top:10,left:10,width:200,height:200},默認彈出位置為屏幕居中。 # [PopPosition]() JSON對象,彈出拍照或攝像界面指示位置 ### 屬性: - top: *(DOMString 類型)*指示區域距離容器頂部的距離 彈出拍照或攝像窗口指示區域距離容器頂部的距離,支持像素值(如100px)和百分比(如50%)。 - left: *(DOMString 類型)*指示區域距離容器左側的距離 彈出拍照或攝像窗口指示區域距離容器左側的距離,支持像素值(如100px)和百分比(如50%)。 - width: *(DOMString 類型)*指示區域的寬度 彈出拍照或攝像窗口指示區域的寬度,支持像素值(如100px)和百分比(如50%)。 - height: *(DOMString 類型)*指示區域的高度 彈出拍照或攝像窗口指示區域的高度,支持像素值(如100px)和百分比(如50%)。 # [CameraSuccessCallback]() 調用攝像頭操作成功回調 ~~~ void onSuccess( capturedFile ) { // Caputre image/video file code. } ~~~ ### 說明: 調用攝像頭操作成功的回調函數,在拍照或攝像操作成功時調用,用于返回圖片或視頻文件的路徑。 ### 參數: - capturedFile: *( DOMString ) 必選 *拍照或攝像操作保存的文件路徑 ### 返回值: void : 無 ### 平臺支持: - Android - 2.2+ (支持) - iOS - 4.3+ (支持) # [CameraErrorCallback]() 攝像頭操作失敗回調 ~~~ void onError( error ) { // Handle camera error } ~~~ ### 參數: - error: *( DOMException ) 必選 *攝像頭操作的錯誤信息 ### 返回值: void : 無 ### 平臺支持: - Android - 2.2+ (支持) - iOS - 4.3+ (支持)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看