2017-08-09 51 views
0

我已經嘗試了本教程的大小,但是當我拿起QVGA或其他,沒有任何反應....分辨率保持不變#ApiRTC我不能改變攝像頭的視頻

爲什麼我不能修復它???

這是源代碼

所以我可以看到這個功能:

//RESOLUTION 
      $("#QVGA").click(function() { 
       console.log("QVGA"); 
       $("#resolution").html('QVGA'); 
       var constraint = { 
        'audio':{'mandatory': {}, 'optional': []}, 
        'video': {'mandatory': {maxWidth: 320, maxHeight: 240}, 'optional': []}}; 
       webRTCClient.setGetUserMediaConfig(constraint); 
      }); 
      $("#VGA").click(function() { 
       console.log("VGA"); 
       $("#resolution").html('VGA'); 
       var constraint = { 
        'audio':{'mandatory': {}, 'optional': []}, 
        'video': {'mandatory': {maxWidth: 640, maxHeight: 480}, 'optional': []}}; 
       webRTCClient.setGetUserMediaConfig(constraint); 
      }); 
      $("#XGA").click(function() { 
       console.log("XGA"); 
       $("#resolution").html('XGA'); 
       var constraint = { 
        'audio':{'mandatory': {}, 'optional': []}, 
        'video': {'mandatory': {maxWidth: 1024, maxHeight: 768}, 'optional': []}}; 
       webRTCClient.setGetUserMediaConfig(constraint); 
      }); 
      $("#SXGA").click(function() { 
       console.log("SXGA"); 
       $("#resolution").html('SXGA'); 
       var constraint = { 
        'audio':{'mandatory': {}, 'optional': []}, 
        'video': {'mandatory': {maxWidth: 1280, maxHeight: 720}, 'optional': []}}; 
       webRTCClient.setGetUserMediaConfig(constraint); 
      }); 
//RESOLUTION 

什麼問題?

回答

0

看來你的約束是不正確的。我找不到任何支持您的約束對象的文檔。比如這裏的記錄上MDN結構:

{ 
    audio: true, 
    video: { 
    width: { min: 1024, ideal: 1280, max: 1920 }, 
    height: { min: 776, ideal: 720, max: 1080 } 
    } 
} 

我嘗試以下,他們似乎工作的罰款(適用於Chrome和Firefox):

{ 
    "audio": true, 
    "video": { 
     "width": { 
      "min": "300", 
      "max": "640" 
     }, 
     "height": { 
      "min": "200", 
      "max": "480" 
     } 
    } 
} 

你可以看到的真人版代碼在這裏:https://webrtc.github.io/samples/src/content/peerconnection/constraints/

另一方面,如果您使用任何第三方庫,您應該檢查其文檔的約束規範。

相關問題