vendredi 15 septembre 2017

How to get event Handler for stop sharing button in chrome in emberjs

I am using twilio API to implementing screen sharing in emberjs app, I successfully able to share the screen and also able to toggle on stopping it, code mentioned as below

this.get('detectRtc').isChromeExtensionAvailable(available => {
    if (available) {
      const { twilioParticipant } = this.get('participant')

      if (this.get('stream') && this.get('stream').active) {
        this.get('streamTrack').stop()
        this.get('userMedia.mediaStream')
        .removeTrack(this.get('streamTrack'))
        this.set('isEnabled', false)
        twilioParticipant.removeTrack(this.get('streamTrack'))
      } else {
        this.get('detectRtc').getSourceId(sourceId => {
          // "cancel" button is clicked
          if (sourceId !== 'PermissionDeniedError') {
            // "share" button is clicked extension returns sourceId
            this.get('userMedia')
            .getScreen(sourceId)
            .then(mediaStream => {
              this.set('isEnabled', true)
              this.set('stream', mediaStream)
              this.set('streamTrack', mediaStream.getVideoTracks()[0])
              twilioParticipant.addTrack(mediaStream.getVideoTracks()[0])
            })
            .catch(() => { /* do nothing, but return something */ })
          }
        })
      }
    } else {
      this.get('flash').status(
        'base',
        this.get('intl').t('chromeExtension.install'),
        {
          icon: 'alert-circle',
          push: true
        }
      )
      // TODO Show the system popup to install chrome extension from web store
      // !!chrome.webstore &&
      // !!chrome.webstore.install &&
      // chrome.webstore.install(this.webStoreUrl)
    }
  })

So the issue I'm facing is with the stop sharing button which is at the bottom of the app as mentioned in screenshot below enter image description here

I need a way to listen to an event handler and execute the some code while clicking on the stop sharing screen, I know there is one onended event Handler is there as mentioned in MediaStreamTrack docs, but don't know how to use, any help will be highly appreciated.

http://ift.tt/1q4huVd




Aucun commentaire:

Enregistrer un commentaire