mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Omit "type" attribute from "<source />" tags in "<video>" to trick Chrome into playing them
Summary: Fixes T13135. See PHI633. For at least some video files with legitimate MIME type "video/quicktime", Chrome can play them but refuses to if the `<source />` tag has a `type="video/quicktime"` attribute. To trick Chrome into giving these videos the old college try, omit the "type" attribute. Chrome then tries to play the video, seems to realize it can, and we're back on track. Since the "type" attribute is theoretically only useful to help browsers select among multiple different alternatives and we're only presenting one alternative, this seems likely safe and reasonable. Omitting "type" also validates. It's hard to be certain that this won't cause any collateral damage, but intuitively it seems like it should be safe and I wasn't able to identify any problems. Test Plan: - Watched a "video/quicktime" MP4 cat video in Chrome/Safari/Firefox. - See T13135 for discussion, context, and discussion of the behavior of some smaller reproduction cases. Reviewers: amckinley, asherkin Reviewed By: amckinley Maniphest Tasks: T13135 Differential Revision: https://secure.phabricator.com/D19424
This commit is contained in:
parent
332f4ab66d
commit
5784e3d3c0
1 changed files with 13 additions and 1 deletions
|
@ -260,6 +260,18 @@ final class PhabricatorEmbedFileRemarkupRule
|
|||
$autoplay = null;
|
||||
}
|
||||
|
||||
if ($is_video) {
|
||||
// See T13135. Chrome refuses to play videos with type "video/quicktime",
|
||||
// even though it may actually be able to play them. The least awful fix
|
||||
// based on available information is to simply omit the "type" attribute
|
||||
// from `<source />` tags. This causes Chrome to try to play the video
|
||||
// and realize it can, and does not appear to produce any bad behavior in
|
||||
// any other browser.
|
||||
$mime_type = null;
|
||||
} else {
|
||||
$mime_type = $file->getMimeType();
|
||||
}
|
||||
|
||||
return $this->newTag(
|
||||
$tag,
|
||||
array(
|
||||
|
@ -274,7 +286,7 @@ final class PhabricatorEmbedFileRemarkupRule
|
|||
'source',
|
||||
array(
|
||||
'src' => $file->getBestURI(),
|
||||
'type' => $file->getMimeType(),
|
||||
'type' => $mime_type,
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue