exception on audio.play()

Issue #191 wontfix
dd1 created an issue

Call to audio.play() from mhttpd_alarm_play() bombs with an exception (google-chrome):

message: "play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD"
name: "NotAllowedError"

The explanation URL resolves to this: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

Looks like we are a victim of the war on evil autoplaying video and audio. From reading the stuff I am not sure on what to do to ensure the midas alarm sound always plays.

K.O.

Comments (12)

  1. Stefan Ritt

    The mentioned solution proposes to change the flag chrome://flags/#autoplay-policy, but in my chrome (77.0) I don’t see that flag. Midas alarms sound without problem. Has this flag been dropped recently? Can you try to update to 77.0 and try again?

    Stefan

  2. dd1 reporter

    for the record, current midas prints this to the javascript console. Macos google-chrome “Version 77.0.3865.120”. I do not know if any sounds actually come out as I have the midas tabs muted.

    '''

    Sun Oct 13 2019 08:58:40 GMT-0700 (Pacific Daylight Time): mhttpd_alarm_play: Cannot play alarm sound: audio.play() exception: NotAllowedError: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD

    ‘''

  3. dd1 reporter

    Stefan - the “tenforums” instructions explain how to use the “mute” function. That is not what I am looking at. What I am looking at is the auto.play() promise rejection due to “user did not interact with site”, (and the alarm sound is not played, the best I can tell).

    To give you a taste of the problem, google docs say that muted tabs should “play” all audio, but that is not what I see with my eyes: in a muted tab, I see auto.play() rejected promise, too.

    I have no idea if audio.play() promises are rejected or not or if audio plays or not in unmuted tabs. To test this, I have to unmute my “midas site” (using the instructions from “tenforums”), then turn off my laptop speakers (I do not want midas alarm sounds at 2am) and then wait like this for 2 weeks for the google-chrome to decide that “user did not interact with the site”. I use the laptop every day, I cannot turn off all audio for 2 weeks.

    K.O.

  4. dd1 reporter

    It looks like one can force the missing flag #autoplay-policy from the command line: https://stackoverflow.com/questions/57455849/chrome-autoplay-policy-chrome-76

    They suggest this: google-chrome-stable --kiosk http://google.com/ --new-window --start-maximized --incognito --autoplay-policy=no-user-gesture-required --disable-features=PreloadMediaEngagementData,AutoplayIgnoreWebAudio,MediaEngagementBypassAutoplayPolicies &

    But it is not clear how to enable this just for the midas web pages, not globally (for all and every web page).

    K.O.

  5. dd1 reporter

    There is this: "Consumption of the media (audio/video) must be greater than 7 seconds". The midas alarm sound is 3 sec long. Maybe this is why MEI is always zero. Should we try to make it longer? 3 sec of alarm, 4 sec of silence?

  6. dd1 reporter

    set the alarm sound to “watch.mp3”, it is 15 sec long. Still see the MEI always zero. Maybe they only measure MEI for video objects. After all ,they are fighting auto playing video ads with obnoxious autoplaying sound. I give up on this problem for now. K.O.

  7. Log in to comment