Skip to content

Use the extra's mime type for video sources - #1081

Open
NopeCharon wants to merge 1 commit into
pytest-dev:masterfrom
NopeCharon:fix-video-mime-type
Open

NopeCharon wants to merge 1 commit into
pytest-dev:masterfrom
NopeCharon:fix-video-mime-type

Conversation

@NopeCharon

Copy link
Copy Markdown

The <source> element of the media viewer had its type hardcoded to video/mp4 in index.jinja2, so the mime_type passed to extras.video() was never used. Browsers that honour the type attribute strictly (e.g. Safari) then refuse to play non-MP4 videos such as WebM.

Changes

  • Pass each media extra's mime_type through to the media viewer (dom.js) and set it on the <source> element whenever a video is shown (mediaviewer.js).
  • If an extra has no mime type (e.g. built with extras.extra(..., FORMAT_VIDEO)), remove the type attribute so the browser detects the format itself. This also stops a type from a previous video sticking around when navigating between videos.
  • Drop the hardcoded type="video/mp4" from the template.
  • Add extras.video(video, mime_type='video/webm', extension='webm') to the extras table in the user guide.

Testing

  • test_extra_video in testing/test_integration.py now builds the extra with extras.video(...) and also covers video/webm. The WebM case fails on master and passes with this change.
  • Checked by hand in Chromium: a report with a WebM video, an MP4 video and a video URL with no mime type. While navigating between them, the <source> gets type="video/webm", then type="video/mp4", then no type.
  • npm run lint passes.

Fixes #819

The <source> element of the media viewer had its type hardcoded to
"video/mp4" in the report template, so the mime_type passed to
extras.video() was never used. Browsers that honour the type attribute
strictly (e.g. Safari) then refuse to play non-MP4 videos such as WebM.

Pass the extra's mime_type through to the media viewer and set it on
the <source> element whenever a video is shown. If an extra has no
mime type, the type attribute is removed so the browser can detect the
format itself instead of keeping a stale value from a previous video.

Also document extras.video() in the user guide and extend the video
integration test to cover a WebM extra.

Fixes pytest-dev#819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML source type for video is hardcoded as video/mp4

1 participant