track.ended promise (Re: Bug 26939 "what info does the app get when a track ends")

On 10/10/14, 12:48 PM, Jan-Ivar Bruaroey wrote:
> FWIW it's a prime candidate since we only end once [2]. I cast my vote 
> for adding an 'ended' promise attribute (and keeping onended as-is).

Since this is still new to many, I should probably explain what I mean 
to make it an actual proposal:


    interface MediaStreamTrack : EventTarget {
         ...
         attribute EventHandler onended;
         attribute Promise ended;  // <--- add this
    };

So people can write:

     track.ended.then(() => log("Ended"), reason => log("Dropped: " + 
reason.message));

instead of:

     track.onended = () => log("Ended or dropped");

.: Jan-Ivar :.

> [2] http://www.w3.org/2001/tag/doc/promises-guide#one-time-events

Received on Friday, 10 October 2014 17:07:16 UTC