W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2012

Re: [whatwg] TextTrack and addCue

From: Philip Jägenstedt <philipj@opera.com>
Date: Thu, 27 Sep 2012 10:47:29 +0200
To: whatwg@lists.whatwg.org
Message-ID: <op.wladdffwsr6mfa@kirk>
On Thu, 27 Sep 2012 10:35:26 +0200, Cyril Concolato  
<cyril.concolato@telecom-paristech.fr> wrote:

> Hi Philip,
>
> Le 9/27/2012 10:30 AM, Philip Jägenstedt a écrit :
>> On Wed, 26 Sep 2012 21:41:34 +0200, Cyril Concolato  
>> <cyril.concolato@telecom-paristech.fr> wrote:
>>
>>> Hi all,
>>>
>>> Has it been considered adding another method to add cues to a track?  
>>> Something like addCues(DOMString text) where the text is not only one  
>>> cue (like in the TextTrackCue ctor) but where the text would be  
>>> multiple cues as written in a WebVTT file? My use case is that I'm  
>>> getting WebVTT content from a server using XHR and I'd like to add  
>>> that easily to the track, without having to parse them myself.  
>>> Ideally, I would like to push the WebVTT content to the track a bit  
>>> like the Media Source Extension API. Another option (less ideal) would  
>>> be to have a WebVTTParser object with a parseFromString method  
>>> returning a TextTrackList (a bit like the DOMParser object). Each cue  
>>> could be added one by one.
>>>
>>> Comments?
>>>
>>> Cyril
>>
>> You can parse WebVTT using a dummy video+track element and then move  
>> the cues to the actual track, why is this less than ideal?
> I did not think about that option. It could do the trick. Thank you. By  
> less than ideal, I meant that if I can push content to a buffer and let  
> the browser parse the text and add the cues to the track, it seems  
> easier/more elegant than having either to parse in JS or to create dummy  
> elements and move cues around.

Yeah, creating that temporary document is one step more than is needed to  
parse HTML by setting innerHTML. If constructing text tracks  
piece-by-piece in this fashion is something that a lot of people will need  
to do, I think a utility method could be considered. It certainly wouldn't  
be hard to implement, it's just a bigger API that the Web will have to  
support forever :)

-- 
Philip Jägenstedt
Core Developer
Opera Software
Received on Thursday, 27 September 2012 08:47:55 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:45 UTC