Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to sniff for a FLAC file #150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

padenot
Copy link
Collaborator

@padenot padenot commented Aug 25, 2021

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

@padenot padenot requested a review from annevk August 25, 2021 17:33
@GPHemsley
Copy link
Member

GPHemsley commented Aug 28, 2021

@padenot Note that supporting the audio/flac MIME type is not the same as supporting sniffing for content of that MIME type.

Browsers having implemented FLAC support does not inherently indicate support for sniffing it, and the linked bugs are for such general FLAC support, not explicitly for sniffing.

While I do see that sniffing was added alongside the Firefox implementation (1ce419e3955f, e42414eeeabe), I am not seeing that in the Chrome/Chromium implementation. Are you able to point more directly to where Chrome/Chromium is doing the sniffing?

Separately, your own recent Firefox bugs/commits on this topic may also be of relevance:
https://bugzilla.mozilla.org/show_bug.cgi?id=1704115
https://bugzilla.mozilla.org/show_bug.cgi?id=1727361

@GPHemsley
Copy link
Member

I think I found where Chromium is sniffing for FLAC, which seems to predate its adding support for FLAC and also uses the MIME type audio/x-flac:
https://chromium.googlesource.com/chromium/src.git/+/785d871db8a39205b3c138d018b835a6b6a2ba41%5E%21/

It doesn't appear to have changed since 2013:
https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/mime_sniffer.cc
https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/mime_sniffer_unittest.cc

I don't know the ramifications of this.

@annevk Does seem like enough information to merge this?

@annevk
Copy link
Member

annevk commented Sep 3, 2021

If you navigate to a FLAC file directly (or in an iframe) and it doesn't have Content-Type set or to a bogus value, does doc.contentType reveal it? Or is it only sniffed by media elements and not navigation?

@annevk annevk closed this Sep 3, 2021
@annevk annevk reopened this Sep 3, 2021
@GPHemsley
Copy link
Member

In a browsing context, Chrome identifies this as text/plain and Firefox identifies this as audio/flac.

@annevk
Copy link
Member

annevk commented Sep 3, 2021

And Chrome also tries to render it as text and not offer playback?

@GPHemsley
Copy link
Member

Yeah, Chrome just displays the fLaC text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants