Andy Turner | 3 Oct 21:07

Re: ECMAScript API docs, and a sound suggestion

On Mon, Oct 03, 2005 at 01:34:42PM -0400, Andrew Plotkin wrote:
> I do not like your audio API. Having methods that are both getters and 
> setters -- bleah. Since Javascript supports object fields which are 
> dynamic (like "nickname", above) we should do it that way:
> 
>   val = audio.url;
>   audio.url = newval;

I agree.

> I don't think we need play(float) to start a sound in the middle. However, 
> we *do* need a way to start a sound playing in "repeat forever" mode. 
> (Background music.)

Make this another attribute?  I don't imagine they'll be any call for sounds
that may be both repeat forever and play once.

> Games frequently need to blast out multiple instances of a sound -- 
> possibly overlapping. Your audio object can't do that. A game *can* create 
> multiple audio objects with the same URL. Is that sufficient, or do we 
> want to avoid the overhead cost of setting the URL and alt on each one?
> 
> (A way to avoid that would be to have just one audio object, and then 
> audio.play() returns an *audio instance* object. The latter would have a 
> stop() method; the former would not. This is not necessarily the right 
> way, just a way. We could also just have a clone() method.)

When I was reading the paragraph before this one, this is exactly
what came to my mind.  I think i prefer the audio instance style. 
I'd also suggest that instances should not have a play method.  
(Continue reading)

Jason McIntosh | 3 Oct 21:40
Picon

Re: ECMAScript API docs, and a sound suggestion

On 10/3/05, Andy Turner <turner <at> mikomi.org> wrote:
> On Mon, Oct 03, 2005 at 01:34:42PM -0400, Andrew Plotkin wrote:
> >
> >   val = audio.url;
> >   audio.url = newval;
>
> I agree.

OK, I can live with this.

> > I don't think we need play(float) to start a sound in the middle.

Fair enough; I just wanted to throw the possibility out there.
Removing this would also obviate the need for a return value of
stop(); the idea was to make pausing and resuming sounds easy.

> Make this another attribute?  I don't imagine they'll be any call for sounds
> that may be both repeat forever and play once.

The one that comes for mind to me is a file that contains a tone
playing for one second; if you want a longer tone you can call the
repeat method (and stop it later) instead of the play method. Of
course, I'm not sure when you'd want to do _that_...

> > (A way to avoid that would be to have just one audio object, and then
> > audio.play() returns an *audio instance* object. The latter would have a
> > stop() method; the former would not. This is not necessarily the right
> > way, just a way. We could also just have a clone() method.)
>
> When I was reading the paragraph before this one, this is exactly
(Continue reading)


Gmane