-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Current state
- Supports YouTube, Vimeo and WikimediaCommons media sources
Goal
- Allow native html5 video media types
- video/mp4
- video/webm
- video/ogg
Draft
- POC commit: ee5d5ea..., not ready for a PR
Discussion (UX)
- Currently, media sources from youtube, vimeo and wikimedia commons are validated by regex;
- There are several challenges with validating arbitrary remote urls
How can remote media types be validated?
-
Extension validation (soft validation)
Url indicates a typical media extension type (e.g. .mp4, .webm, .ogg for html5 video elements).
Disadvantages:- No real validation of media type
- Other URLs serving media would be invalid (if this is the only type of validation);
workarounds by suffixing with a valid media type, e.g. in the query parameter (bad ux)
-
Header validation
Retrieve the content-type response header from the URL.
A (cors) request to get the headers of the URL could be initiated.
Disadvantages:- A frontend request will only work based on regular CORS restrictions (appropriate Access-Control-Allow-Origin headers), there's a good chance this won't work in most cases.
- Alternative: Headers could be validated with a backend proxy route, e.g. compared to mathpix proxy, but this would introduce cross-origin dependencies
- A frontend request will only work based on regular CORS restrictions (appropriate Access-Control-Allow-Origin headers), there's a good chance this won't work in most cases.
How do others deal with this situation?
H5P
- h5p tries to [determine the mime type based on the url (basically validating the "extension")
- by regex
\.(\w+)$within the html5 video - by
url.match(/\.(webm|mp4|ogv|m4a|mp3|ogg|oga|wav)/i);within the h5p editor
- by regex
- h5p has a fallback mime type for html5 players: video/unknown that is set by the h5p editor; in this case it simply tries to load the video anyway and listens for media errors on the video player (MEDIA_ERR_SRC_NOT_SUPPORTED)
Conclusion
- Since the above validations (1+2) are pretty much limited (except for the backend proxy route), no URL validation might be "sufficient" at this point. Compared to the h5p solution the video player could simply run into the Media error
MEDIA_ERR_SRC_NOT_SUPPORTEDif source is not supported
Follow up question
What are the opinions of the Serlo maintainers on that matter? I could prepare a PR based on the decision.
elbotho
Metadata
Metadata
Assignees
Labels
No labels