Last Comment Bug 449157 - Implement the looping attributes in media elements
: Implement the looping attributes in media elements
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: Audio/Video (show other bugs)
: Trunk
: All All
: -- normal with 23 votes (vote)
: mozilla11
Assigned To: Matthew Gregan [:kinetik]
:
Mentors:
http://www.whatwg.org/specs/web-apps/...
: 589562 (view as bug list)
Depends on: 449159
Blocks: 654787 457604 ietestcenter
  Show dependency treegraph
 
Reported: 2008-08-04 19:51 PDT by cajbir (:cajbir)
Modified: 2015-10-10 07:29 PDT (History)
44 users (show)
roc: wanted1.9.2+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch v0 (5.45 KB, patch)
2009-05-23 21:14 PDT, Matthew Gregan [:kinetik]
no flags Details | Diff | Splinter Review
patch v1 (6.06 KB, patch)
2011-11-20 18:06 PST, Matthew Gregan [:kinetik]
roc: review+
Details | Diff | Splinter Review

Description cajbir (:cajbir) 2008-08-04 19:51:33 PDT
start, loopstart, loopend, end, and playcount all control when the video is started, stopped and looped. These are currently unimplemented. See the spec in the URL.
Comment 1 cajbir (:cajbir) 2008-10-27 15:31:15 PDT
The attributes are currently being discussed in the WHATWG mailing list and may be removed. See the following thread:

http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-October/016605.html
Comment 2 :Ms2ger (⌚ UTC+1/+2) 2008-11-15 05:38:21 PST
The attributes have been removed from the spec (r2401) and replaced by a single boolean |loop| attribute for infinite loops.[1]

[1] http://html5.org/tools/web-apps-tracker?from=2400&to=2401
Comment 3 Matthew Gregan [:kinetik] 2009-05-23 21:14:23 PDT
Created attachment 379389 [details] [diff] [review]
patch v0

Add support for loop attribute, remove obsolete attributes from old spec.

All that's left to do is verify that the correct events fire when playback loops, and write a test.
Comment 4 Toni Ruottu 2009-06-05 03:27:40 PDT
Is this going to be ready in time for Firefox 3.5?
Comment 5 Matthew Gregan [:kinetik] 2009-06-05 04:01:50 PDT
No, 3.5 is frozen for the release candidate now, so new features are not being added.  Looping (and a few other video features) has been scheduled for the next release, which is why I've recently started working on it.
Comment 6 Antoine Turmel [:GeekShadow] 2009-07-13 14:22:52 PDT
Can we see this feature for 3.5.1 or 3.5.2 ?
Comment 7 Matthew Gregan [:kinetik] 2009-07-13 14:54:14 PDT
This feature will be in 3.6 (or whatever the next major release is called).

3.5.x will only receive security and critical fixes.  Looping can be achieved using scripting, so it would be very difficult to argue that native support counts as a critical fix for the 3.5.x release branch.
Comment 8 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2009-07-30 22:00:47 PDT
This seems like low-hanging fruit that we should get in.

It would be nice to have skip-free looping but doing it perfectly would be extremely hard --- requires decoding from the beginning of the stream before we actually seek back there. This patch alone is probably worth taking because it's at least as good as what you can do with script. We could improve it by doing the seek from the decoder thread so that if the data is in the media cache, we can loop without having to go back to the main thread.
Comment 9 Jeff Walden [:Waldo] (remove +bmo to email) 2009-07-30 22:30:53 PDT
Extremely hard, perhaps -- but essential, in my opinion, regardless whether or not the spec ever requires it.  I'm not even sure I'd advertise looping support in its absence, at least not without very prominent caveats about loop behavior not being skip-free.
Comment 10 Sonny Piers [:sonny] 2009-10-26 09:22:36 PDT
I implemented it through an add-on:
https://addons.mozilla.org/en-US/firefox/addon/45730/
Comment 11 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2009-11-06 01:41:21 PST
I've had an idea about how to implement this skip-free without adding too much complexity. We could allow an HTMLMediaElement to have two nsMediaDecoders: the "current" decoder (today's mDecoder) and a "next" decoder. We now support cloning decoders and sharing the underlying cached data, so we could use that here. When the "current" decoder is near the end and "loop" is specified, we clone it to create the "next" decoder". The "next" decoder starts off paused, at position 0, but will automatically decode some frames into the frame queue (if it needs one). When the "current" decoder ends, we simply replace it with the "next" decoder and start playing.

Hmm, except that doesn't quite work. For total fidelity we need to actually wire together the audio queues and the video frame queues. Hmm.
Comment 12 sergeymk 2009-12-05 10:57:07 PST
Hopefully the internal looping routine will be gapless, at least for audio. As I understand, it is substantially easier to do this for ogg/vorbis than mp3.

The following wikipedia page lists players that support gapless playback. There are some open-source players on there. Maybe looking at their source code will be helpful?

http://en.wikipedia.org/wiki/Gapless_playback
Comment 13 Volomike 2010-02-17 22:49:29 PST
I found a workaround for now with Firefox 3.6 and tested on Ubuntu Linux 8.04 at least. I used jQuery and had a routine like this in my HTML5 page:

<script type="text/javascript">
$().ready(function(){

$('#snd').bind('ended',{},function() {
  $(this).trigger('play');
});

});
</script>
<audio id="snd" src="fire.wav" autoplay="autoplay" playcount="9999" loop="true" />

In other words, I trapped the "ended" event, and made it trigger the play() method to start over again. This was similar to how sonny.piers' plugin worked when I cracked open his XPI file and poked around.
Comment 14 Matthew Gregan [:kinetik] 2010-06-24 17:38:00 PDT
When this bug is fixed, the following test should pass:
(Note that the tests current sniff the user agent for Firefox--hopefully that'll be fixed soon.)

http://test.w3.org/html/tests/submission/Microsoft/video/video_005.htm
Comment 15 Michael Kraft [:morac] 2010-07-27 08:56:44 PDT
Still MIA in the Firefox 4 beta trunk loads.  The loop tag is in the HTML5 spec over at W3 - http://www.w3.org/TR/html5/video.html#attr-media-loop

There's an audio example over at http://forestmist.org/2010/04/html5-audio-loops/ as well as some work arounds.

The missing loop tag functionality is actually affecting developers trying to build HTML5 applications. See the "Issues" section on http://arandomurl.com/2010/07/25/html5-pacman.html
Comment 16 :Ms2ger (⌚ UTC+1/+2) 2010-08-22 10:05:15 PDT
*** Bug 589562 has been marked as a duplicate of this bug. ***
Comment 17 Darxus 2010-08-22 10:20:14 PDT
Also blocks ietestcenter.  Why can't I edit that?
Relevant url is:  http://samples.msdn.microsoft.com/ietestcenter/html5/MediaElements/media-rules-loop.htm
Comment 18 SteveBaker 2010-10-23 14:17:16 PDT
Two years and two months after the original bug was filed...and all the promotion that the Firefox folks are doing over HTML5 - it's REALLY bad that these video (and audio) tags and all of the associated JavaScript events are not working by now.

I had hoped to use both audio and video features in my entry for GameOn-2010 - but right now, the whole thing is just a mess.

This absolutely needs to be there for Firefox 4.0.
Comment 19 :Ms2ger (⌚ UTC+1/+2) 2010-10-23 14:57:29 PDT
SteveBaker: Please read <https://bugzilla.mozilla.org/page.cgi?id=etiquette.html>, in particular "No pointless comments" and "No obligation". Thanks.
Comment 20 Frank Yan (:fryn) 2010-12-21 17:53:18 PST
Resetting to NEW. Set back to ASSIGNED with an assignee, if you're working on
this.
Comment 21 Matthew Gregan [:kinetik] 2011-05-10 15:54:46 PDT
*** Bug 654787 has been marked as a duplicate of this bug. ***
Comment 22 Jeff Muizelaar [:jrmuizel] 2011-06-15 22:36:39 PDT
The FishBowl (fhttp://people.mozilla.com/~jmuizelaar/fishbowl/fishbowl-gl.html) benchmark uses the 'loop' attribute. IE 9 and Chrome both implement it, we probably should too.
Comment 23 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2011-06-16 20:59:44 PDT
The new media infrastructure will make seamless looping much easier to implement.
Comment 24 Matthew Gregan [:kinetik] 2011-11-20 18:06:11 PST
Created attachment 575791 [details] [diff] [review]
patch v1

I think it is a mistake not to support this until seamless looping is possible.  None of Chrome 17, Opera 11.52, Safari 5.1, or Internet Explorer 9 loop seamlessly.
Comment 25 Matthew Gregan [:kinetik] 2011-11-20 18:07:39 PST
Bug 654787 will track looping seamlessly.
Comment 26 Matthew Gregan [:kinetik] 2011-11-20 19:49:15 PST
http://hg.mozilla.org/integration/mozilla-inbound/rev/40b854ef9e16
Comment 27 Matt Brubeck (:mbrubeck) 2011-11-21 09:05:24 PST
https://hg.mozilla.org/mozilla-central/rev/40b854ef9e16
Comment 28 Mihaela Velimiroviciu (:mihaelav) 2011-11-28 08:35:28 PST
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0a1) Gecko/20111127 Firefox/11.0a1
Mozilla/5.0 (Windows NT 6.1; rv:11.0a1) Gecko/20111127 Firefox/11.0a1
Mozilla/5.0 (Windows NT 5.1; rv:11.0a1) Gecko/20111127 Firefox/11.0a1
Mozilla/5.0 (X11; Linux x86_64; rv:11.0a1) Gecko/20111128 Firefox/11.0a1

Verified using the sites from comment #14 (http://test.w3.org/html/tests/submission/Microsoft/video/video_005.htm), comment #15 (http://forestmist.org/2010/04/html5-audio-loops/) and comment #22 (http://people.mozilla.com/~jmuizelaar/fishbowl/fishbowl-gl.html) and the test passed/audio looping seems to work fine. Still, on Linux there is a delay between loops.

Are there any other tests needed to verify the fix?
Comment 29 Matthew Gregan [:kinetik] 2011-11-28 12:54:05 PST
Thanks, there's a simple mochitest in the tree as well, so that should cover it.

The extended delay on Linux is bug 582513.  That'll be worked around when bug 623444 finally lands.
Comment 30 George Chriss 2012-01-04 21:07:24 PST
There's a prospective use case in Tumblr.  There are now two ways to inject the video tag into posts, and looped videos might compliment the love of animated gifs.  Demo: http://gchriss.tumblr.com/post/14899370892/demo-html5-video-tumblr

Also, Loop Method 1 from comment #15 fails on FF 9.0 / Linux.  The rest work as expected.

Note You need to log in before you can comment on or make changes to this bug.