Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't hear if somebody joins while you're on a different tab #6

Open
karth295 opened this issue Jul 26, 2016 · 5 comments
Open

Can't hear if somebody joins while you're on a different tab #6

karth295 opened this issue Jul 26, 2016 · 5 comments
Assignees

Comments

@karth295
Copy link
Contributor

Browsers do not autoplay videos while you are in a different tab. This is mainly so that websites don't play ads in other tabs, you can open multiple youtube videos, etc.

For tawk, this means that if somebody joins your group, their <video> tag can't automatically play. You can't tell that they joined, and they can't get your attention.

Tawk should send a user desktop notifications (similar to Slack) to inform them that a user joined. These notifications should only fire if you are not actively looking at tawk.

@toomim
Copy link
Member

toomim commented Aug 13, 2016

If users don't have desktop notifications enabled, then perhaps we can still make a sound using the stream on an existing <video> or <audio> tag. Because this limitation is only on new tags (as far as I can tell from your description).

I don't think this is high priority to do, but it is an interesting workaround if we ever want to solve the problem better.

@karth295
Copy link
Contributor Author

That's an interesting thought. I do create a new Audio element for the notification and play it, so I think the restriction applies only to video. Maybe if you switch tabs we change everybody to audio tags.

On the other hand I do like an indication that somebody joins rather than suddenly hearing their voice.

@karth295
Copy link
Contributor Author

karth295 commented Feb 4, 2017

People don't like desktop notifications, and often turn them off. I think we should investigate this audio tag concept.

Actually, users shouldn't subscribe to video streams at all when their focus is in a different tab.

@karth295 karth295 reopened this Feb 4, 2017
@toomim
Copy link
Member

toomim commented Feb 4, 2017

We can actually play audio directly from the audiostream that comes in over webrtc, even before it hits the video tag. I've been writing code to do this, and we can even filter the audio:

    onremotestream: (stream) ->
      # TODO: forget this key when they leave                                               
      save
        key: 'stream/' + id,
        url: URL.createObjectURL(stream)
	volume: 0

      # Get an audio node out of the incoming audio stream
      window.audio or= new AudioContext()
      s = audio.createMediaStreamSource(stream)

      # Make a filter that sits in between the audio node and the sound card
      filter = audio.createBiquadFilter()
      filter.type = 'lowpass'
      filter.frequency.value = 500

      # Connect the incoming audio stream to the filter
      s.connect(filter)
      # Connect the filter to the sound card
      filter.connect(audio.destination)

I've been playing with this but right now it seems like it creates an echo.

@karth295
Copy link
Contributor Author

This is still happening, but harder to reproduce. If Travis starts in tawk by himself, then anybody else joins after some time, he can't hear them. However, if both of us start in tawk, he navigates to a different tab, and I refresh the page, he can hear me.

Two theories (neither confirmed):

  1. Audio cannot be played in a background tab if it didn't start playing any audio when the user was interacting with the page. When Travis joins tawk by himself, no audio is played because there is nobody else. However, if we both start on the page, the tab has played audio (from me). We'd fix this by playing a small (blank) sound when you open the page.

  2. Audio tags cannot be added after certain period of time when the tab is idle. We'd fix this by routing all audio through one audio tag (using https://developer.mozilla.org/en-US/docs/Web/API/ChannelMergerNode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants