首页 > 解决方案 > 如何获取 Agora io 屏幕共享取消事件?

问题描述

我正在使用 agora io 进行视频通话和屏幕共享。屏幕共享工作正常。但问题是当我取消屏幕共享时,流不显示。但加入仍然有效。我需要捕捉屏幕共享的取消事件。我已阅读文档,但没有关于取消事件的线索。您能帮忙取消活动吗?提前谢谢。

标签: cancellationscreensharingagora.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')
          })
        }
    } 

推荐阅读