- From: Melvin Carvalho <melvincarvalho@gmail.com>
- Date: Sun, 18 Sep 2016 18:45:51 +0200
- To: Simon Pieters <simonp@opera.com>
- Cc: whatwg@lists.whatwg.org
On 18 September 2016 at 14:44, Simon Pieters <simonp@opera.com> wrote: > On Sun, 18 Sep 2016 01:21:27 +0200, Melvin Carvalho < > melvincarvalho@gmail.com> wrote: > > Apologies if this has come up before, but I was wondering if it would be >> possible to add simple parameters to the play() function. >> >> They would be >> >> play(start, end) >> >> Where start and end are the times in seconds. >> >> I know you can do >> >> video.currentTime = start ; video.play() >> >> But there's no real easy way to stop it to play a clip >> >> The media fragments URIs spec [1] handles this quite nicely by adding to >> the URI >> >> #t=start,end >> >> But yet there seems to be no way to do this in JS, resorting to changing >> location.hash and then doing a reload, which seems a bit of a kludge >> >> I may be missing something extremely obvious, if so, I'd love to know! >> >> [1] https://www.w3.org/TR/media-frags/ >> > > The pauseOnExit attribute on VTTCue can be used for this purpose. See > https://html.spec.whatwg.org/multipage/embedded-content.html > #text-track-api:the-audio-element for an example. Thank you for both answers! I found pauseOnExit to work very well for my use case. I ended up with. v.addTextTrack('metadata') cue = new VTTCue(start, end, '') cue.pauseOnExit = true cues.addCue(cue) v.currentTime = start v.play() Regarding var cue = new VTTCue(start, end, ''); As best I could tell that last parameter is a 'message', tho Im not sure I got any message when the video stopped, even when I populated it. Maybe I wasnt supposed to. I'm quite happy to use this solution. My slight concert is whether there are any side effects from adding a TextTrack to a video. Should this be considered best practice, or would there perhaps still be room in future for (start, end) parameters? > > -- > Simon Pieters > Opera Software >
Received on Sunday, 18 September 2016 16:46:20 UTC