gpt4 book ai didi

javascript - 如何判断 pc.onnegotiationneeded 是否因为流已被删除而被解雇?

转载 作者:太空狗 更新时间:2023-10-29 13:53:30 24 4
gpt4 key购买 nike

我正在处理一个 RTCPeerConnection (pc) 有一个名为 onnegotiationneeded 的事件处理程序.

当使用 pc.addStreampc.removeStream 添加或删除完整的媒体流时,将触发“onnegotiationneeded”。

是否可以在 onnegotiationneeded 函数内部判断它是否因为流被添加或删除而被执行?因为通过阅读文档我找不到那个状态。

目前,当我执行 pc.addStreampc.removeStream 时,我正在切换一个标志。此标志帮助我在 onnegotiationneeded 中判断它是否已被流删除触发。

但我想知道浏览器(Chrome 40 或 Firefox 36)的 API 是否已经提供了这样的属性?

最佳答案

MDN documentation for the onnegotiationneeded handler状态:

This should be set to a function you provide which is passed a single parameter: an Event object containing the negotiationneeded event. There's no additional information provided in the event; anything you need, you can get by examining the properties of the RTCPeerConnection.

所以基本上,您不能仅通过回调来完成。但是您可以将它与 onstreamaddedonstreamremoved 处理程序一起使用

您可能会找到一个舒适的解决方案来跟踪添加的轨道和流 here .

关于javascript - 如何判断 pc.onnegotiationneeded 是否因为流已被删除而被解雇?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28801507/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com