cancellation - 如何获取 Agora io 屏幕共享取消事件?
问题描述
我正在使用 agora io 进行视频通话和屏幕共享。屏幕共享工作正常。但问题是当我取消屏幕共享时,流不显示。但加入仍然有效。我需要捕捉屏幕共享的取消事件。我已阅读文档,但没有关于取消事件的线索。您能帮忙取消活动吗?提前谢谢。
解决方案
If you are using agora web sdk ng library then you can detect this by using track-ended event.
We can create screen track using createScreenVideoTrack in this sdk.
step-1 call this method to create track
async shareScreen() {
const localScreenTrack = await AgoraRTC.createScreenVideoTrack();
return localScreenTrack;
}
step2- call event method after creating track.
To add event on this track create different method to handle event
shareScreenEvent(){
const track = this.shareScreen()
if (track) {
track.on('track-ended', () => {
console.log('track-ended');
console.log('you can run your code here to stop screen')
})
}
}
推荐阅读
- ruby-on-rails - 带有Webpacker触发器的rails中的传单找不到地图容器
- python - 如何根据阈值划分列表?
- css - 预加载会阻塞整个渲染阶段
- android - java.lang.IllegalArgumentException:无法在形状为 [2] 的 TensorFlowLite 张量和形状为 [1、2] 的 Java 对象之间复制
- react-native-ui-kitten - 如何更改底部导航中选定的 BottomNavigationTab 的颜色( ui-kitten )
- xamarin - 我正在尝试在 Xamarin Android 中使用 Google ARCore sceneform SDK。但我在“ModelRenderable.InvokeBuilder().SetSource()”方法中遇到错误
- data-structures - 如何计算结果森林中一棵树的最大高度?
- javascript - 排序哈希键。获取顺序是固定的吗?
- material-ui - 如何在矩阵 UI 排版中添加更多变体
- c# - 递归继承如何工作?类 PersonInfoBuilder
: PersonBuilder where SELF : PersonInfoBuilder