<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>28032</bug_id>
          
          <creation_ts>2015-02-16 04:37:25 +0000</creation_ts>
          <short_desc>Definition of &quot;ended playback&quot; prevents looping when loop attribute is added after playback has ended</short_desc>
          <delta_ts>2019-03-29 21:40:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc>https://html.spec.whatwg.org/#playing-the-media-resource</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>chcunningham</cc>
    
    <cc>d</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>117946</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2015-02-16 04:37:25 +0000</bug_when>
    <thetext>Specification: https://html.spec.whatwg.org/multipage/embedded-content.html
Multipage: https://html.spec.whatwg.org/multipage/#playing-the-media-resource
Complete: https://html.spec.whatwg.org/#playing-the-media-resource
Referrer: https://html.spec.whatwg.org/multipage/

Comment:
Definition of &quot;ended playback&quot; prevents looping when loop attribute is added
after playback has ended

Posted from: 14.162.111.98 by philipj@opera.com
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36 OPR/27.0.1689.69</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117947</commentid>
    <comment_count>1</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-02-16 04:39:51 +0000</bug_when>
    <thetext>This is from a Chromium bug report:
https://code.google.com/p/chromium/issues/detail?id=364442

It was fixed by ignoring the loop attribute part of the definition in the context of play():
https://codereview.chromium.org/898883003/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117948</commentid>
    <comment_count>2</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-02-16 04:45:01 +0000</bug_when>
    <thetext>For a spec fix, it probably makes more sense to separate out &quot;The current playback position is the end of the media resource, and the direction of playback is forwards&quot; into a separate definition and using that in play().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118304</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-03-04 20:35:15 +0000</bug_when>
    <thetext>I&apos;m confused. What behaviour are you expecting if a loop attribute is added when the media element is paused after having ended playback?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118342</commentid>
    <comment_count>4</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-03-05 06:05:26 +0000</bug_when>
    <thetext>The expectation is that if the &quot;ended playback&quot; predicate is true, adding the loop attribute does not cause it to become false, as the actual state of playback did not change. Calling play() should then seek to the earlier possible position just as it would if the loop attribute was not present.

(The expectation is not that playback should continue at the time the loop attribute is added or anything like that.)

Looking at this a second time, I think the most natural fix could be to remove &quot;Either the media element does not have a loop attribute specified, or the media element has a current media controller&quot; from the definition of &quot;ended playback&quot; and add those conditions to the call sites where they are needed. play() already does the right thing here it seems, I haven&apos;t look closely at the other cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119083</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-03-30 20:45:39 +0000</bug_when>
    <thetext>If play() does what you want, I&apos;m not really sure I understand what doesn&apos;t do what you want. Sorry if I&apos;m being dumb here...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119129</commentid>
    <comment_count>6</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-03-31 09:41:51 +0000</bug_when>
    <thetext>Well no, play() doesn&apos;t do what I want, because the addition of the loop attribute causes &lt;https://html.spec.whatwg.org/#ended-playback&gt; to go from true to false, which changes the behavior of &lt;https://html.spec.whatwg.org/#dom-media-play&gt;.

The current spec seems to assume that one cannot be paused at currentTime==duration with the loop attribute present, but all one needs to do is to add the loop attribute after reaching currentTime==duration.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119320</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-04-07 22:15:40 +0000</bug_when>
    <thetext>I see what you&apos;re saying. How about adding this text to just before the note that says &quot;The word &quot;reaches&quot; here does not imply that...&quot;:

When a _loop_ content attribute is added to a _media element_ that does not have a _current media controller_ but whose _current playback position_ has reached the end of the _media resource_ and whose _direction of playback_ is forwards, the user agent must _seek_ to the _earliest possible position_ of the _media resource_.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119491</commentid>
    <comment_count>8</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-04-14 10:57:33 +0000</bug_when>
    <thetext>That would allow the subsequent play() to actually play, but I think it&apos;s a bit odd to seek (but not play) in response to adding the loop attribute. In particular if there&apos;s a &quot;Loop&quot; option in the context menu, it would be surprising if merely toggling that would also cause a seek.

How about the suggestion at the end of comment #4, does that have any drawbacks that you can see?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119588</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-04-16 22:08:55 +0000</bug_when>
    <thetext>It just seems like a brittle fix (e.g. we have to go through all those call sites and understand for each one what the implications are, possibly going to their call sites, etc).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119619</commentid>
    <comment_count>10</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-04-17 08:22:14 +0000</bug_when>
    <thetext>A more local fix would be to change step 2 of play() from

&quot;If the playback has ended and the direction of playback is forwards, and the media element does not have a current media controller, seek to the earliest possible position of the media resource.&quot;

to

&quot;If the current playback position is the end of the media resource and the direction of playback is forwards, and the media element does not have a current media controller, seek to the earliest possible position of the media resource.&quot;

The definition of the ended attribute should probably also change in that case.

(I would slightly prefer to change the definition of ended playback itself and fix up all the call sites, but that amounts to an editorial decision.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129704</commentid>
    <comment_count>11</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2019-03-29 21:40:48 +0000</bug_when>
    <thetext>https://github.com/whatwg/html/issues/4487</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>