程式碼: ``` javascript:(function(){var%20zoomLevel=prompt("請輸入縮放倍率:");if(zoomLevel!==null){var%20cameraId=document.querySelector("select#videoSource")?document.querySelector("select#videoSource").value:null;if(cameraId){navigator.mediaDevices.getUserMedia({audio:!1,video:{deviceId:{exact:cameraId},zoom:parseFloat(zoomLevel)||1}}).then(function(e){var%20t=document.querySelector("video");t&&(t.srcObject=e,t.play())}).catch(function(e){console.error("應用縮放倍率時發生錯誤:",e)})}else%20console.error("未找到鏡頭ID。")}else%20console.error("未輸入縮放倍率。")})(); ``` 還在測試的程式碼(不要用這個) ``` javascript:(function(){var%20select=document.createElement('select');select.id='zoomDropdown';select.innerHTML='<option%20disabled%20selected%20value%20style="display:none;">縮放/Zoom:</option><option%20value="1">1x</option><option%20value="2">2x</option><option%20value="3">3x</option><option%20value="4">4x</option><option%20value="5">5x</option>';document.body.appendChild(select);select.addEventListener('change',function(){var%20zoomLevel=select.value;var%20cameraId=document.querySelector('select#videoSource')?document.querySelector('select#videoSource').value:null;if(cameraId){navigator.mediaDevices.getUserMedia({audio:!1,video:{deviceId:{exact:cameraId},zoom:parseFloat(zoomLevel)||1}}).then(function(e){var%20t=document.querySelector('video');t&&(t.srcObject=e,t.play())}).catch(function(e){console.error('應用縮放倍率時發生錯誤:',e)})}else%20console.error('未找到鏡頭ID。')})})(); ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up