(D8 Core) MPEG-4 Audio Files (M4A) with "Audio" Display Don't Play in Safari 13.1

Created on 4 May 2020, over 4 years ago
Updated 1 February 2023, over 1 year ago

This issue mirrors #3133613: MPEG-4 Audio Files (M4A) with "Audio" Display Don't Play in Safari 13.1 β†’ in the File Entity queue for Drupal 7.

We recently started working a lot with audio files on our Drupal-based platform, and the format that we receive the audio from our media asset management system is MPEG-4. We have our file fields configuring to use the "Audio" display format. When M4A files are uploaded to the platform and displayed, the audio player appears and works properly in all major browsers (Chrome 81, Firefox 75, Edge 44, and Edge 81) except for Safari (tested in 13.1).

<!-- break -->

Steps to Reproduce

  1. Install a clean copy of Drupal 8.8.5.
  2. Create a new Content Type called "Test M4A".
  3. Add a new field called "Audio File" in the new content type. Make it of type "File".
  4. Configure the new "Audio File" field to accept an extension of type "m4a" only.
  5. Go to the "Manage display" tab of the "Test M4A" content type, change the "Format" of the "Audio File" field to "Audio", and click the "Save" button.
  6. Create a new "Test M4A" node, uploading an M4A file for the "Audio File" field when creating the new node. (In addition to our own internal M4A files, I was able to reproduce this with "sample1.m4a" from https://filesamples.com/formats/m4a as well).
  7. Open the new node in the browser.

Expected Results

  • In all major browsers (Chrome 81, Firefox 75, Edge 44, Edge 81, and Safari 13.1), an audio player should render on the page
  • The audio player should have a "Play" button.
  • When the play button on the player is clicked, the audio should start to play.

Actual Results

  • In Safari 13.1, the audio player renders with a time of "-00:00".
  • The audio player has a "Play" button.
  • Safari does not play anything when the play button is clicked.

Additional Context

For clarity -- since I know that an M4A file is actually a container file type -- the Linux file command reports our M4A files as:

ISO Media, MPEG v4 system, iTunes AAC-LC

And VLC reports:

It appears that Safari takes issue with the MIME Type reported in the HTML markup for the audio file -- the <audio> tag advertises a MIME type of audio/mpeg. If I open the M4A source path in a new Safari tab (e.g. https://mysite.com/sites/default/files/audio/sample1.m4a), it opens and plays fine in the browser. Developer tools indicates that the MIME type that the Pantheon servers report to Safari is audio/x-m4a.

From various searches I've done, audio/x-m4a is less standard/older than audio/mpeg, and Safari (incorrectly) assumes that audio/mpeg means "MPEG-1, Layer 3". Then again, the IANA spec does not mention M4A in the registration for audio/mpeg. And, according to the /etc/mime.types that ships with Fedora 22, the mapping for M4A is supposedly audio/mp4. So, perhaps core's default mapping for M4A is just plain incorrect.

I have observed that if I manually edit the database and change the MIME type of an M4A file to audio/x-m4a instead of audio/mpeg, the audio will play in the page in all browser I test it with. So, it would appear either that Safari does not recognize audio/mpeg for this type of file (confirmed that it's the former by using the File MIME module).

As an aside, we did not see this behavior when we were using MP3 audio files on our platform. This issue appears to only affect MPEG-4 audio files.

Three approaches that might work to fix this:

  1. Patch core so that ExtensionMimeTypeGuesser::$defaultMapping uses audio/x-m4a for m4a files instead of audio/mpeg, then write a migration to touch/update all existing file entities that have a mime type of "audio/mpeg" so that the database reflects the new MIME type; OR
  2. Render two <audio> tags for the same source URL -- one with a MIME type of audio/mpeg and another with the Safari-desired audio/x-m4a MIME type; OR
  3. Use the File MIME β†’ project to workaround this bug in the interim.
πŸ› Bug report
Status

Closed: cannot reproduce

Version

9.5

Component
File systemΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024