Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#9174 closed bug (invalid)

creating video element causes video to play in background, even before adding it to the page

Reported by: bugs.jquery.com@… Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6
Keywords: Cc:
Blocked by: Blocking:

Description

This happens sometimes, but not all of the time, in Firefox, Safari, and Chrome.

http://jsfiddle.net/cDpV9/8/

var v = $("<video id='v' src='http://ia600401.us.archive.org/18/items/ForrestPlaysTaik/forresto-plays-taik-banjo-360.webm' autobuffer='auto' preload autoplay controls></video>");
  1. Create the video element
  2. Hear it playing in background, even though it isn't in the DOM tree
  3. Then if you add the element to the page with .append(v) the audio will be doubled

More: http://stackoverflow.com/questions/5927573/html5-video-playing-twice-audio-doubled-with-jquery-append

Change History (5)

comment:1 Changed 9 years ago by Rick Waldron

Component: unfiledmanipulation
Priority: undecidedlow
Resolution: invalid
Status: newclosed

Try removing the "autoplay" attribute.

comment:2 Changed 9 years ago by bugs.jquery.com@…

Isn't this a valid bug? I need it to autoplay. A workaround is to use

$("#player").html("<video id='v' src='http://ia600401.us.archive.org/18/items/ForrestPlaysTaik/forresto-plays-taik-banjo-360.webm' autobuffer='auto' preload autoplay controls></video>");

instead of

$("#player").append($("<video id='v' src='http://ia600401.us.archive.org/18/items/ForrestPlaysTaik/forresto-plays-taik-banjo-360.webm' autobuffer='auto' preload autoplay controls></video>"));

comment:3 Changed 9 years ago by timmywil

This sounds like a browser bug. However, I've tried this before and I believe it will autoplay (whether the attribute is present or not) as soon as you append it so the autoplay attribute may be unnecessary in this case.

comment:4 Changed 9 years ago by Rick Waldron

Again, removing the "autoplay" attribute corrects the issue: http://jsfiddle.net/rwaldron/cDpV9/9/

comment:5 Changed 7 years ago by anonymous

Seems fixed in jquery 1.9

Note: See TracTickets for help on using tickets.