Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26655 > unrolled thread

Audio autoplay again

Started byAndrew Poulos <ap_prog@hotmail.com>
First post2015-01-23 10:26 +1100
Last post2015-01-26 13:52 -0800
Articles 17 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-23 10:26 +1100
    Re: Audio autoplay again Scott Sauyet <scott.sauyet@gmail.com> - 2015-01-23 05:36 -0800
      Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-24 11:56 +1100
    Re: Audio autoplay again Dr.Kral@nyc.rr.com - 2015-01-23 17:14 -0500
      Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-24 11:36 +1100
    Re: Audio autoplay again "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-23 23:30 +0100
      Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-24 12:02 +1100
        Re: Audio autoplay again "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-24 02:29 +0100
          Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-24 13:08 +1100
    Re: Audio autoplay again Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-24 15:29 +0100
      Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-26 12:30 +1100
    Re: Audio autoplay again "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-26 12:11 -0800
      Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-27 08:22 +1100
        Re: Audio autoplay again "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-26 13:45 -0800
          Re: Audio autoplay again Andrew Poulos <ap_prog@hotmail.com> - 2015-01-27 12:05 +1100
            Re: Audio autoplay again Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-27 13:07 +0100
        Re: Audio autoplay again "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-01-26 13:52 -0800

#26655 — Audio autoplay again

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-23 10:26 +1100
SubjectAudio autoplay again
Message-ID<7qudnc66lNbiFVzJnZ2dnUVZ8iednZ2d@westnet.com.au>
I'm try to test if HTML5 audio can auto play so I'm creating an audio 
element, setting its autoplay property to true and then waiting to see 
if the play event gets triggered.

I have set a 3 second timeout to catch if the audio doesn't trigger play.

The problem is that if the audio takes more than 3 seconds to load/start 
the timeout triggers.

What audio event should I use to "contain" the timeout? I've looked at 
load and canplaythrough but I'm not concerned with whether or not the 
whole audio can play but whether it will start playing or not.

Andrew Poulos

[toc] | [next] | [standalone]


#26666

FromScott Sauyet <scott.sauyet@gmail.com>
Date2015-01-23 05:36 -0800
Message-ID<9a9b6316-5284-4544-a3fe-d53e73689e9b@googlegroups.com>
In reply to#26655
Andrew Poulos wrote:
> The problem is that if the audio takes more than 3 seconds to load/start 
> the timeout triggers.

I'm not actually sure if the following is possible; I've never tried it.

Could you embed an extremely minimal audio sample in a data URI?  That
would skip the wait for an external load and require only the parsing
of that data URI.

Of course this would limit your autoplay detection to those browsers that
support data URIs, but I'm assuming you already have some fallback plan
for those that don't support autoplay, so perhaps it could work for these
older browsers as well?

  -- Scott

[toc] | [prev] | [next] | [standalone]


#26680

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-24 11:56 +1100
Message-ID<6pqdnTyyu8iLcl_JnZ2dnUVZ7q2dnZ2d@westnet.com.au>
In reply to#26666
On 24/01/2015 12:36 AM, Scott Sauyet wrote:
> Andrew Poulos wrote:
>> The problem is that if the audio takes more than 3 seconds to load/start
>> the timeout triggers.
>
> I'm not actually sure if the following is possible; I've never tried it.
>
> Could you embed an extremely minimal audio sample in a data URI?  That
> would skip the wait for an external load and require only the parsing
> of that data URI.

I'm finding that browsers are not consistently playing data URI and 
"normal" MP3 files. I created a 1 second low quality MP3 or silence and 
it wouldn't play (I'm guessing it didn't play because onplay never 
triggered). I've tried files of different bit rates and found the lower 
rates failing.

It needs lots of testing.

> Of course this would limit your autoplay detection to those browsers that
> support data URIs, but I'm assuming you already have some fallback plan
> for those that don't support autoplay, so perhaps it could work for these
> older browsers as well?

On devices that won't autoplay I'm going to display a message to tell 
users to click a play button.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26676

FromDr.Kral@nyc.rr.com
Date2015-01-23 17:14 -0500
Message-ID<irh5cah5pqp25kg8ajnj1t0pga3v392645@4ax.com>
In reply to#26655
On Fri, 23 Jan 2015 10:26:17 +1100, Andrew Poulos <ap_prog@hotmail.com>
wrote in <7qudnc66lNbiFVzJnZ2dnUVZ8iednZ2d@westnet.com.au>:

>I'm try to test if HTML5 audio can auto play so I'm creating an audio 
<snip>

Have you considered that some people who go to your page do NOT want to
disturb other people with a sound blast?  And that others are not ready to
give you that sort of attention (since your previous post mention video)?

Personally, that is one thing that will drive me away from your page
immediately.  And not just me -- the weather.com page reported that the
number one change people wanted was to NOT to turn on a video with sound.

Frankly, auto start audio/video is extremely rude except, perhaps, when
going to a video directly.

JMHO.

[toc] | [prev] | [next] | [standalone]


#26679

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-24 11:36 +1100
Message-ID<4aGdnXENCrcNd1_JnZ2dnUVZ8nGdnZ2d@westnet.com.au>
In reply to#26676
On 24/01/2015 9:14 AM, Dr.Kral@nyc.rr.com wrote:
> On Fri, 23 Jan 2015 10:26:17 +1100, Andrew Poulos <ap_prog@hotmail.com>
> wrote in <7qudnc66lNbiFVzJnZ2dnUVZ8iednZ2d@westnet.com.au>:
>
>> I'm try to test if HTML5 audio can auto play so I'm creating an audio
> <snip>
>
> Have you considered that some people who go to your page do NOT want to
> disturb other people with a sound blast?  And that others are not ready to
> give you that sort of attention (since your previous post mention video)?
>
> Personally, that is one thing that will drive me away from your page
> immediately.  And not just me -- the weather.com page reported that the
> number one change people wanted was to NOT to turn on a video with sound.
>
> Frankly, auto start audio/video is extremely rude except, perhaps, when
> going to a video directly.

I'm working on some elearning courses where its generally expected that 
media autoplays.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26678

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2015-01-23 23:30 +0100
Message-ID<m9ui12$jgh$1@solani.org>
In reply to#26655
Andrew Poulos wrote:

> I'm try to test if HTML5 audio can auto play so I'm creating an audio
> element, setting its autoplay property to true and then waiting to see
> if the play event gets triggered.

I'm wondering whether the `paused` attribute can be utilized instead of
the `play` event.  I don't know, but it might be worth investigating.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26681

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-24 12:02 +1100
Message-ID<qeidneZjpvPgbV_JnZ2dnUVZ8sudnZ2d@westnet.com.au>
In reply to#26678
On 24/01/2015 9:30 AM, Christoph M. Becker wrote:
> Andrew Poulos wrote:
>
>> I'm try to test if HTML5 audio can auto play so I'm creating an audio
>> element, setting its autoplay property to true and then waiting to see
>> if the play event gets triggered.
>
> I'm wondering whether the `paused` attribute can be utilized instead of
> the `play` event.  I don't know, but it might be worth investigating.

I'll  have a look.

Currently I'm testing calling play() without setting autoplay and then 
testing for onplay because it seems to me that devices that let you 
start playback using code also allow autoplay.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26682

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2015-01-24 02:29 +0100
Message-ID<m9usi7$p1c$1@solani.org>
In reply to#26681
Andrew Poulos wrote:

> Currently I'm testing calling play() without setting autoplay and then
> testing for onplay because it seems to me that devices that let you
> start playback using code also allow autoplay.

If I'm not mistaken, "all" browsers accept play(), if it is called on
direct user interaction, e.g.

  button.onclick = function () {
      audio.play();
  };

should work "everywhere" (e.g. on iOS), whereas

  window.onload = function () {
      audio.play();
  };

does not necessarily.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#26683

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-24 13:08 +1100
Message-ID<oPidnUpwxvV1Yl_JnZ2dnUVZ8m6dnZ2d@westnet.com.au>
In reply to#26682
On 24/01/2015 12:29 PM, Christoph M. Becker wrote:
> Andrew Poulos wrote:
>
>> Currently I'm testing calling play() without setting autoplay and then
>> testing for onplay because it seems to me that devices that let you
>> start playback using code also allow autoplay.
>
> If I'm not mistaken, "all" browsers accept play(), if it is called on
> direct user interaction, e.g.
>
>    button.onclick = function () {
>        audio.play();
>    };
>
> should work "everywhere" (e.g. on iOS), whereas
>
>    window.onload = function () {
>        audio.play();
>    };
>
> does not necessarily.
>
Yes, you're right.

Perhaps I should've said "devices that let you start playback using 
code, without any user input, also allow autoplay."

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26688

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2015-01-24 15:29 +0100
Message-ID<5315239.VqnyhsogH5@PointedEars.de>
In reply to#26655
Andrew Poulos wrote:

> I'm try to test if HTML5 audio can auto play […]

Your current approach of creating a new thread for a subject discussed only 
days ago in a thread also started by you is not appreciated.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#26699

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-26 12:30 +1100
Message-ID<ZcGdnaRGWPazB1jJnZ2dnUVZ7sydnZ2d@westnet.com.au>
In reply to#26688
On 25/01/2015 1:29 AM, Thomas 'PointedEars' Lahn wrote:
> Andrew Poulos wrote:
>
>> I'm try to test if HTML5 audio can auto play […]
>
> Your current approach of creating a new thread for a subject discussed only
> days ago in a thread also started by you is not appreciated.

To me it was a different aspect of the problem and so deserved a new thread.

At any rate, when we did the accessibility testing having a screen 
reader reading the screen while a piece of audio autoplays is unacceptable.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26713

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2015-01-26 12:11 -0800
Message-ID<e793a9ba-52e8-4943-ad67-924cb286fd62@googlegroups.com>
In reply to#26655
On Thursday, January 22, 2015 at 5:32:21 PM UTC-6, Andrew Poulos wrote:
> I'm try to test if HTML5 audio can auto play so I'm creating an audio 
> element, setting its autoplay property to true and then waiting to see 
> if the play event gets triggered.
> 
> I have set a 3 second timeout to catch if the audio doesn't trigger play.
> 
> The problem is that if the audio takes more than 3 seconds to load/start 
> the timeout triggers.
>
> What audio event should I use to "contain" the timeout? I've looked at 
> load and canplaythrough but I'm not concerned with whether or not the 
> whole audio can play but whether it will start playing or not.

Is the following not sufficient?

"autoplay" in Audio.prototype === true

[toc] | [prev] | [next] | [standalone]


#26714

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-27 08:22 +1100
Message-ID<B-ydnfHLsNnoLFvJnZ2dnUVZ8madnZ2d@westnet.com.au>
In reply to#26713
On 27/01/2015 7:11 AM, Michael Haufe (TNO) wrote:
> On Thursday, January 22, 2015 at 5:32:21 PM UTC-6, Andrew Poulos wrote:
>> I'm try to test if HTML5 audio can auto play so I'm creating an audio
>> element, setting its autoplay property to true and then waiting to see
>> if the play event gets triggered.
>>
>> I have set a 3 second timeout to catch if the audio doesn't trigger play.
>>
>> The problem is that if the audio takes more than 3 seconds to load/start
>> the timeout triggers.
>>
>> What audio event should I use to "contain" the timeout? I've looked at
>> load and canplaythrough but I'm not concerned with whether or not the
>> whole audio can play but whether it will start playing or not.
>
> Is the following not sufficient?
>
> "autoplay" in Audio.prototype === true
>
I doubt its that simple. The iPad for one will not autoplay audio no 
matter what settings you give it (though I will test it).

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26715

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2015-01-26 13:45 -0800
Message-ID<222a6cfc-f2b5-4b14-b9e5-02cd5c09815e@googlegroups.com>
In reply to#26714
On Monday, January 26, 2015 at 3:28:28 PM UTC-6, Andrew Poulos wrote:
> On 27/01/2015 7:11 AM, Michael Haufe (TNO) wrote:
> > On Thursday, January 22, 2015 at 5:32:21 PM UTC-6, Andrew Poulos wrote:
> >> I'm try to test if HTML5 audio can auto play so I'm creating an audio
> >> element, setting its autoplay property to true and then waiting to see
> >> if the play event gets triggered.
> >>
> >> I have set a 3 second timeout to catch if the audio doesn't trigger play.
> >>
> >> The problem is that if the audio takes more than 3 seconds to load/start
> >> the timeout triggers.
> >>
> >> What audio event should I use to "contain" the timeout? I've looked at
> >> load and canplaythrough but I'm not concerned with whether or not the
> >> whole audio can play but whether it will start playing or not.
> >
> > Is the following not sufficient?
> >
> > "autoplay" in Audio.prototype === true
> >
> I doubt its that simple. The iPad for one will not autoplay audio no 
> matter what settings you give it (though I will test it).

Recently I discovered that in some webkit browsers the order of attributes seem to matter. IME, in order to get a consistent autoplay without scripting, I've had to put the attribute last and leave it without a value:

<...autoplay>...</>

I can find a number of bug complaints related to this, but nothing consistent yet. YMMV at this date.

[toc] | [prev] | [next] | [standalone]


#26722

FromAndrew Poulos <ap_prog@hotmail.com>
Date2015-01-27 12:05 +1100
Message-ID<joydnV4jYqAgeFvJnZ2dnUVZ8h2dnZ2d@westnet.com.au>
In reply to#26715
On 27/01/2015 8:45 AM, Michael Haufe (TNO) wrote:
> "autoplay" in Audio.prototype === true

In Chrome on Windows desktop Audio.prototype does not include: 
autobuffer, autoplay, buffered, controls, ended... whereas IE and FF do.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#26728

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2015-01-27 13:07 +0100
Message-ID<1483492.yQ09jnUT9t@PointedEars.de>
In reply to#26722
Andrew Poulos wrote:

> On 27/01/2015 8:45 AM, Michael Haufe (TNO) wrote:
>> "autoplay" in Audio.prototype === true
> 
> In Chrome on Windows desktop Audio.prototype does not include:
> autobuffer, autoplay, buffered, controls, ended... whereas IE and FF do.

In that case you could use the instance reference as second operand instead.  
The “in” operator traverses the prototype chain:

<http://ecma-international.org/ecma-262/5.1/#sec-11.8.7>

However, “with host objects, all bets are off” (LRN in [1], among others).

______
[1] <news:isi947of.fsf@hotpop.com>
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#26716

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2015-01-26 13:52 -0800
Message-ID<d925653c-1817-4dba-add1-bec9e59be6e8@googlegroups.com>
In reply to#26714
On Monday, January 26, 2015 at 3:28:28 PM UTC-6, Andrew Poulos wrote:
> The iPad for one will not autoplay audio no 
> matter what settings you give it (though I will test it).

I overlooked this part earlier. You are correct. This is generally the case on mobile devices due to billing and data plans I assume.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web