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

Re: [whatwg] possible new parameters to video.play() ?

From: Nigel Megitt <nigel.megitt@bbc.co.uk>
Date: Sun, 18 Sep 2016 17:02:17 +0000
To: Melvin Carvalho <melvincarvalho@gmail.com>
Message-ID: <801A82CE-0E6B-4D8D-8F2A-5A8A8DE01F64@bbc.co.uk>
Cc: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>, Simon Pieters <simonp@opera.com>
IMO this should be a feature of TextTrackCue and has no relevance to VTTCue specifically. There's implementation overloading here that is mixing concerns unhelpfully.



On 18 Sep 2016, at 17:46, Melvin Carvalho <melvincarvalho@gmail.com<mailto:melvincarvalho@gmail.com>> wrote:

On 18 September 2016 at 14:44, Simon Pieters <simonp@opera.com<mailto:simonp@opera.com>> wrote:

On Sun, 18 Sep 2016 01:21:27 +0200, Melvin Carvalho <
melvincarvalho@gmail.com<mailto: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


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
#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.

cue = new VTTCue(start, end, '')
cue.pauseOnExit = true
v.currentTime = start


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 17:02:49 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:39 UTC