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

muted option makes no difference #529

Closed
felipecrs opened this issue Jul 17, 2023 · 23 comments · Fixed by #740
Closed

muted option makes no difference #529

felipecrs opened this issue Jul 17, 2023 · 23 comments · Fixed by #740
Labels
bug Something isn't working

Comments

@felipecrs
Copy link
Contributor

I'm using the latest (3.2.1), and the muted option simply makes no difference: the audio is always muted no matter what:

chrome_K7XW0OTLgv.mp4
@felipecrs
Copy link
Contributor Author

@AlexxIT if I change the following lines:

if (!this.video.muted) {
this.video.muted = true;
this.video.play().catch(er => {
console.warn(er);
});

To:

            if (!this.video.muted) {
-               this.video.muted = true;
+               this.video.muted = false;
                this.video.play().catch(er => {
                    console.warn(er);
                });

Then the audio starts unmuted, but it also starts paused by default.

@felipecrs
Copy link
Contributor Author

Ok, I think I understood what that piece of code is doing. It's actually falling back to muted audio if Chrome's autoplay block is detected.

I just don't understand why it works in go2rtc's stream page normally, and also why it works with Frigate Card.

@alexcodito
Copy link

alexcodito commented Jul 18, 2023

Facing the same issue on Firefox even with this enabled:
image

@felipecrs
Copy link
Contributor Author

One workaround is to use the WebRTC card within the Frigate Card, with the Frigate Card configured to auto unmute.

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 20, 2023

This is a very complex and confusing issue. Different browsers allow audio+autoplay for completely different reasons.
This may depend on how the page is opened (whether the user clicked somewhere) and how often the user opens the page.
If it worked on the old version and stopped working on the new version - we need to run some tests and understand the difference in JS code.

@AlexxIT AlexxIT added the bug Something isn't working label Jul 20, 2023
@stplatt
Copy link

stplatt commented Jul 24, 2023

I'm seeing it in chrome and android webview. It works ok with version 3.1.1, the issue started with 3.2.1. I downgraded to 3.1.1 and it's working as expected again

@mikedrawback
Copy link

Same here, had to downgrade to 3.1.1

@Mr-HaleYa
Copy link

The Chrome update broke a lot of platforms auto-play. I use Pandora radio on my desktop through Chrome and even they added a thing recently saying autoplay may be broken but as you use the site more then Chrome will "learn" what you want and autoplay should start functioning again as normal.
image

@AlexxIT
Copy link
Owner

AlexxIT commented Aug 26, 2023

@Mr-HaleYa where you get this screenshot?

@Mr-HaleYa
Copy link

@a20691
Copy link

a20691 commented Aug 26, 2023

The Chrome update broke a lot of platforms auto-play. I use Pandora radio on my desktop through Chrome and even they added a thing recently saying autoplay may be broken but as you use the site more then Chrome will "learn" what you want and autoplay should start functioning again as normal. image

This happened to me. At first it was never unmuted, after a few hours trying to get around the situation it started to work perfectly, after two days without using it, it didn't work again. So it makes sense to be some kind of Chrome memory function.

@luzik
Copy link

luzik commented Aug 28, 2023

I have 4 webrtc cards with:

muted: true
mode: webrtc

On every browser refresh mute icon is muted or unmuted (seams random) - independently from other cards

uuuu
umuu
umum
uuuu
uumu
..just random on every browser refresh

unmuted cards do not play any sound, and pressing mute button do not change anything (even icon do not change to muted state)
Firefox here

@Takst3in
Copy link

Hi all!

I'm casting a webrtc_camera card on a dashboard in panel mode, to my Nest Hub, as a baby-cam stream.
The stream always comes up with the "muted ON button", I have to press the mute button to get sound.

Suspect this is related to this bug, however downgrading to other versions (3.2.1/3.2.0/3.1.1) does not resolve the issue,
also editing the line (true/false) "this.video.muted = true;" in /webrtc/www/video-rtc.js file also does not make any difference.

I'm casting the dashboard via DashCast (HA Continuesly Casting Dashboard) integration.

@stplatt
Copy link

stplatt commented Aug 29, 2023

Workaround is to use the Frigate card with the webrtc-card provider. The mute settings work properly with that setup

@Takst3in
Copy link

Workaround is to use the Frigate card with the webrtc-card provider. The mute settings work properly with that setup

Do you have a template configuration for that setup?

@felipecrs
Copy link
Contributor Author

felipecrs commented Aug 29, 2023

This is the one I use:

The dashboard:

views:
  - title: Home
    type: panel
    badges: []
    cards:
      - type: custom:frigate-card
        cameras:
          - live_provider: webrtc-card
            webrtc_card:
              url: camera_03
              style: |
                video {aspect-ratio: 16/9; object-fit: fill;}
                .mode {display: none}
            camera_entity: camera.video_porteiro
        view:
          default: live
        live:
          auto_play: all
          auto_unmute: all
          controls:
            builtin: false
            title:
              mode: none
          zoomable: true
          layout:
            fit: cover
            position:
              x: 0
              'y': 0
          lazy_unload: all
        menu:
          buttons:
            cameras:
              enabled: false
            frigate:
              enabled: false
            fullscreen:
              enabled: false
            media_player:
              enabled: false
            play:
              enabled: true
            microphone:
              enabled: false
            live:
              enabled: false
            mute:
              enabled: true
          style: overlay
          position: top
          alignment: right
          button_size: 80
        dimensions:
          aspect_ratio_mode: static
          aspect_ratio: '16:9'
        elements:
          - type: custom:frigate-card-menu-state-icon
            entity: cover.porta
            tap_action:
              action: toggle
            priority: 51
        performance:
          profile: low

How I call the service:

service: cast.show_lovelace_view
data:
  entity_id: media_player.sala_home
  view_path: "0"
  dashboard_path: video-porteiro

The result:

1_5116194257362748298.mp4

Refs dermotduffy/frigate-hass-card#1231

@stplatt
Copy link

stplatt commented Aug 30, 2023

Workaround is to use the Frigate card with the webrtc-card provider. The mute settings work properly with that setup

Do you have a template configuration for that setup?

type: custom:frigate-card
cameras:
  - live_provider: webrtc-card
    engine: generic
    id: Nursery
    webrtc_card:
      url: camera.nursery_go2rtc
      ui: false
      background: false
      digital_ptz:
        mouse_drag_pan: true
        mouse_wheel_zoom: false
        mouse_double_click_zoom: true
        touch_pinch_zoom: true
        touch_drag_pan: true
        touch_tap_drag_zoom: true
      ptz:
        opacity: 0.5
        service: amcrest.ptz_control
        data_left:
          entity_id: camera.nursery
          movement: left
        data_right:
          entity_id: camera.nursery
          movement: right
        data_up:
          entity_id: camera.nursery
          movement: up
        data_down:
          entity_id: camera.nursery
          movement: down
        data_zoom_in:
          entity_id: camera.nursery
          movement: zoom_in
        data_zoom_out:
          entity_id: camera.nursery
          movement: zoom_out
      style: >-
        .header {top: 6px; right: 5px} .mode {position: absolute; top: 0px;
        right: 5px} .shortcuts {left: 6px: top: 6px; right: unset; display:
        flex; flex-direction: row; gap: 10px; opacity: 0.7; background: rgba(0,
        0, 0, 0.25); border-radius: 5px}
live:
  controls:
    builtin: false
  draggable: false
  zoomable: false
  auto_unmute: all
menu:
  buttons:
    frigate:
      enabled: false
    cameras:
      enabled: false
    live:
      enabled: false
    mute:
      enabled: true
      alignment: opposing
    expand:
      enabled: true
    media_player:
      alignment: opposing
  alignment: left
  style: overlay
  position: bottom
dimensions:
  aspect_ratio_mode: static
elements:
  - type: icon
    title: Full room
    icon: mdi:application-brackets-outline
    tap_action:
      action: call-service
      service: amcrest.goto_preset
      service_data:
        entity_id: camera.nursery
        preset: 1
    style:
      top: 15px
      left: 15px
      color: rgba(255,255,255,0.7)
      background: rgba(0,0,0,0.25)
      border-radius: 20px
  - type: icon
    title: Windows
    icon: mdi:curtains
    tap_action:
      action: call-service
      service: amcrest.goto_preset
      service_data:
        entity_id: camera.nursery
        preset: 3
    style:
      top: 15px
      left: 50px
      color: rgba(255,255,255,0.7)
      background: rgba(0,0,0,0.25)
      border-radius: 20px
  - type: icon
    title: Bed
    icon: mdi:cradle
    tap_action:
      action: call-service
      service: amcrest.goto_preset
      service_data:
        entity_id: camera.nursery
        preset: 2
    style:
      top: 15px
      left: 85px
      color: rgba(255,255,255,0.7)
      background: rgba(0,0,0,0.25)
      border-radius: 20px
  - type: custom:frigate-card-menu-submenu
    icon: mdi:menu
    items:
      - title: Wake with sound
        entity: automation.wake_baby_monitor_if_noise_detected
        icon: mdi:robot
        tap_action:
          action: toggle
      - title: Show Evelyn's camera
        entity: input_boolean.show_evelyn_s_camera
        tap_action:
          action: toggle
      - title: Show nursery camera
        entity: input_boolean.show_nursery_camera
        tap_action:
          action: toggle

@mikedrawback
Copy link

I'm using Fully Kiosk browser and having this issue when I enable autoplay video and audio. It worked on version 3.1.1 and I have not updated the browser.

@mikedrawback
Copy link

I was able to fix my issue by commenting out this section at line 158 in video-rtc.js.

I then added a console.warn to the first catch to see what was happening.

    play() {
        this.video.play().catch((er) => {
              console.warn(er)
          /*  if (!this.video.muted) { 
                this.video.muted = true; 
                this.video.play().catch(er => {
                    console.warn(er);
                });
            }*/
        });
    }

The error was:

DOMException: The play() request was interrupted by a new load request.

This code is trying to catch an error caused by autoplay being blocked. In my case the error is caused by something else, but it still proceeds to mute the video even though I have muted: false in my config.

This code block should be more specific about the error we are trying to catch on that first call to this.video.play(), and also should check that it is obeying the configuration for the muted attribute.

@nortuzar
Copy link

nortuzar commented Jan 6, 2024

I'm using Fully Kiosk browser and having this issue when I enable autoplay video and audio. It worked on version 3.1.1 and I have not updated the browser.

same thing here and now o cant downgrade to 3.1.1 from HA menu

@mikedrawback
Copy link

mikedrawback commented Jan 7, 2024

@nortuzar I am also using fully kiosk. The solution for now is to comment out the section below in the VideoRTC.play() function in video-rtc.js:

play() {
        this.video.play().catch(() => {
            /*
            if (!this.video.muted) {
                this.video.muted = true;
                this.video.play().catch(er => {
                    console.warn(er);
                });
            } */
        }); 
    }

You will have to go back and do this every time the integration is upgraded.

@codemunkie15
Copy link

codemunkie15 commented Jan 7, 2024

@nortuzar I am also using fully kiosk. The solution for now is to comment out the section below in the VideoRTC.play() function in video-rtc.js:

play() {
        this.video.play().catch(() => {
            /*
            if (!this.video.muted) {
                this.video.muted = true;
                this.video.play().catch(er => {
                    console.warn(er);
                });
            } */
        }); 
    }

You will have to go back and do this every time the integration is upgraded.

This isn't working for me. The video still autoplays muted. What browser is this working in for you please?

EDIT:

It turns out my changes aren't being reflected. I've edit video-rtc.js in my custom_components/webrtc/www folder and restarted HA, but when I view the hosted file (http://xxxxxxxxx:xxxx/webrtc/video-rtc.js?v=1.8.0), the lines are not commented. I've tried an "Empty Cache and Hard Refresh" but nothing changes. Any ideas?

EDIT 2:

My browser was loading the compressed version of the library, video-rtc.js.gz. I deleted this file and then it loaded the uncompressed version with my changes and now it's working. Cheers!

@nortuzar
Copy link

nortuzar commented Jan 8, 2024

@nortuzar I am also using fully kiosk. The solution for now is to comment out the section below in the VideoRTC.play() function in video-rtc.js:

play() {
        this.video.play().catch(() => {
            /*
            if (!this.video.muted) {
                this.video.muted = true;
                this.video.play().catch(er => {
                    console.warn(er);
                });
            } */
        }); 
    }

You will have to go back and do this every time the integration is upgraded.

This isn't working for me. The video still autoplays muted. What browser is this working in for you please?

EDIT:

It turns out my changes aren't being reflected. I've edit video-rtc.js in my custom_components/webrtc/www folder and restarted HA, but when I view the hosted file (http://xxxxxxxxx:xxxx/webrtc/video-rtc.js?v=1.8.0), the lines are not commented. I've tried an "Empty Cache and Hard Refresh" but nothing changes. Any ideas?

EDIT 2:

My browser was loading the compressed version of the library, video-rtc.js.gz. I deleted this file and then it loaded the uncompressed version with my changes and now it's working. Cheers!

@codemunkie15 thanks for the fix. I was using the frigate card to fix the issue, but on mi fire HD 7 i take several seconds to start showing the stream, with this card with mode: mse work great. Hope this can be fixed in the next release , thanks for the awesome card

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.