New issue
Advanced search Search tips

Issue 872067 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 15
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

MediaStreamTrack.stop() should trigger MediaStreamTrack.onended event

Reported by wanggen...@gmail.com, Aug 7

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36

Steps to reproduce the problem:
https://codepen.io/anon/pen/MBPvbe

window.navigator.mediaDevices.getUserMedia({video: true}).then(stream => {
  const vtrack = stream.getVideoTracks()[0];
  vtrack.onended = (event) => {
    console.log('video track on ended');
    const span = document.createElement('span');
    span.innerHTML = "stopped";
    document.body.appendChild(span);
  };
  const videoEl = document.getElementById('video');
  videoEl.srcObject = stream;
  videoEl.play().then(() => {
  	const button = document.createElement('button');
    button.innerHTML = "stop";
    button.onclick = (ev) => {
      console.log('stopped clicked');
    	vtrack.stop();
    };
    document.body.appendChild(button);
  });
});

What is the expected behavior?
https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack  

1. stop will detach the track from the media source,
2. onended will fire when the source is detached from the track.

So we expect onended is called when stop is called()

What went wrong?
onended is not called
addEventListener('ended',  (ev) => {...}); is not called.

Did this work before? No 

Does this work in other browsers? N/A

Chrome version: 68.0.3440.84  Channel: stable
OS Version: OS X 10.13.5
Flash Version: 

however,  this works when the media track is stopped from the media source.  e.g. screen sharing persistent banner.
 
Labels: Needs-Triage-M68
Cc: susan.boorgula@chromium.org
Labels: Needs-Feedback Triaged-ET
wanggen917@g Thanks for the issue.

Tested this issue on Mac OS 10.13.3 on the reported version 68.0.3440.84 and the latest Canary 70.0.3516.0 by following the below steps.

1. Launched Chrome and navigated to https://codepen.io/anon/pen/MBPvbe.
2. Could see the media source. 
3. navigated to devtools -> Console, clicked on the Stop button and could observe that the media is stopped.
Attached is screen cast for reference.

Request you to check and confirm if anything is missed from our end in triaging the issue.

Thanks..
872067.mp4
1.6 MB View Download
Yes, the media is stopped. 
But this issue is the 'onended' event is not dispatched somehow. I don't think this ever works, but wonder know if it is by design and why?  If not, then please fix. 

Project Member

Comment 4 by sheriffbot@chromium.org, Aug 14

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: WontFix (was: Unconfirmed)
According to spec, stop() should not fire the ended event.
More details:
https://w3c.github.io/mediacapture-main/#life-cycle-and-media-flow
https://w3c.github.io/mediacapture-main/#event-summary

Sign in to add a comment