Skip to content

Conversation

@Pintorado
Copy link

@Pintorado Pintorado commented Nov 21, 2025

Description

This PR improves audio file handling in the Mux plugin and adds configurable MIME type validation. It builds upon the work from PR #398 by @isaac-martin.

Closes issue #382, which calls for better audio file handling and support in the plugin, and it also closes #407 by fixing the state of the input on dragEnter for audios.

What to review

  • Added acceptedMimeTypes configuration option that allows configuring which file types are accepted by the input ('video/*' and/or 'audio/*'). Default value is ['video/*', 'audio/*']
  • Fixed audio preview after upload: audio files now display correctly in the player component after being uploaded. Also added an image that reflects the audio type of the file.
  • Updated terminology from "video" to "asset" across multiple components to reflect support for both video and audio files.
  • Updated README.md with comprehensive documentation for the acceptedMimeTypes configuration option.

Testing

There are 2 options to configure the acceptedMimeTypes:

1) Plugin-level configuration

Configure accepted file types for all mux.video fields globally:

import {muxInput} from 'sanity-plugin-mux-input'

export default defineConfig({
  plugins: [
    muxInput({
      acceptedMimeTypes: ['video/*'], // Only accept video files
      // or
      acceptedMimeTypes: ['audio/*'], // Only accept audio files
      // or
      acceptedMimeTypes: ['video/*', 'audio/*'], // Accept both (default)
    }),
  ],
})

2) Schema-level configuration

Configure accepted file types for individual fields in your schema, which will override the plugin-level configuration:

import { defineField, defineType } from "sanity";

export default defineType({
  name: "muxTest",
  title: "Mux Files",
  type: "document",
  fields: [
    defineField({
      name: "audioFile",
      title: "Audio File",
      type: "mux.video",
      options: {
        acceptedMimeTypes: ["audio/*"],
      },
    }),
    defineField({
      name: "videoFile",
      title: "Video File",
      type: "mux.video",
      options: {
        acceptedMimeTypes: ["video/*"],
      },
    }),
    defineField({
      name: "either",
      title: "Either File",
      type: "mux.video",
    }),
  ],
});

Try uploading audios, videos and other unsupported file types in the different uploaders. Verify that each uploader accepts only the file types specified in its acceptedMimeTypes configuration (by default, accepts both audio and video files). After uploading an audio, check that the preview displays correctly.

@vercel
Copy link

vercel bot commented Nov 21, 2025

@Pintorado is attempting to deploy a commit to the Sanity Sandbox Team on Vercel.

A member of the Team first needs to authorize it.

@R-Delfino95 R-Delfino95 self-requested a review November 21, 2025 18:55
@R-Delfino95 R-Delfino95 requested a review from stipsan December 3, 2025 16:42
@R-Delfino95
Copy link
Collaborator

LGTM!
@stipsan, this should be ready for review and merge 😄

Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 💖

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.

Input state not resetting after invalid file upload Better support for audio only files

3 participants