-1

Chrome 25を使用してgetUserMediaとRTCPeerConnectionを使用して、ウェブページから別のパーティにオーディオを接続していますが、そのページでメディアが使用されていることを示すChromeタブの赤い点滅表示アイコンをAPIで停止できません。 。私の質問は、解決策が機能していないことを除いて、navigator.getUserMediaによって開かれるStop /CloseWebカメラの複製です。リモートメディアなし(ピアなし)でgetUserMediaのみを使用するページがある場合、カメラを停止すると、タブインジケーターの点滅がオフになります。リモートストリームの追加が問題のようです。これが私の「近い」コードのために現在持っているものです:

if (localStream) {
    if (peerConnection && peerConnection.removeStream) {
        peerConnection.removeStream(localStream);
    }
    if (localStream.stop) {
        localStream.stop();
    }
    localStream.onended = null;
    localStream = null;
}
if (localElement) {
    localElement.onerror = null;
    localElement.pause();
    localElement.src = undefined;
    localElement = null;
}
if (remoteStream) {
    if (peerConnection && peerConnection.removeStream) {
        peerConnection.removeStream(remoteStream);
    }
    if(remoteStream.stop) {
        remoteStream.stop();
    }
    remoteStream.onended = null;
    remoteStream = null;
}
if (remoteElement) {
    remoteElement.onerror = null;
    remoteElement.pause();
    remoteElement.src = undefined;
    remoteElement = null;
}
if (peerConnection) {
    peerConnection.close();
    peerConnection = null;
}

私は電話の有無にかかわらずremoveStream()試しました、私は電話の有無にかかわらず試しました、私はそしてstop()を試しました、私はアイデアを使い果たしています。これがAPIの使用におけるバグなのかユーザー/私のエラーなのか誰か知っていますか?element.src=""element.src=null

編集:デフォルトのデバイス(Windowsを使用)を、使用時にライトが付いているカメラに設定しました。停止すると、カメラのライトが消えます。これはChromeのバグである可能性があります。またchrome://settings/content、マイクデバイスを「デフォルト」以外に変更すると、Chromeオーディオが完全に失敗することもわかりました。そして最後に、使用するelement.src=undefinedとChromeがリソースを読み込もうとし、404をスローすることになり、明らかに正しくないことに気づきelement.src=''ました。

4

2 に答える 2

2

結局私のせいになりました(はい、衝撃的です)。...のコールバックでlocalStream正しく保存されていなかったことが判明しました。一度設定されると、Chromeは点滅している録音アイコンをオフにします。それは他の異常を説明しませんでした、しかしそれは質問の要点を閉じます。onUserMediaSuccessgetUserMedia

于 2013-03-01T14:12:37.500 に答える
0

昨日、WebRTC仕様を調べた後、これが機能するようになりましたこれが「正しい」方法かどうかはわかりませんが、ストリームを削除した後、新しいオファーでPeerConnectionを再ネゴシエートすることでうまくいくことがわかりました。

var pc = peerConnections[socketId];
pc.removeStream(stream);
pc.createOffer( function(session_description) {
  pc.setLocalDescription(session_description);
  _socket.send(JSON.stringify({
    "eventName": "send_offer",
    "data":{
      "socketId": socketId,
      "sdp": session_description
      }
    }));
},
function(error) {},
defaultConstraints);
于 2013-03-01T00:07:44.653 に答える