GithubHelp home page GithubHelp logo

stipsan / sanity-plugin-mux-input Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sanity-io/sanity-plugin-mux-input

1.0 1.0 0.0 2.15 MB

An input component that integrates Sanity Studio with MUX.com video encoding/hosting service.

Home Page: https://mux.com

License: MIT License

Shell 0.16% JavaScript 1.29% TypeScript 98.55%

sanity-plugin-mux-input's Introduction

Mux Video Input Sanity Plugin

NOTE

This is the Sanity Studio v3 version of sanity-plugin-mux-input.

For the v2 version, please refer to the studio-v2 branch.

This is a plugin that let you use Mux video assets in your Sanity studio.

The Mux plugin for Sanity gives you a way to upload and preview videos easily.

Read our blog post about this plugin.

Not familiar with Sanity? Visit www.sanity.io

Quick start

  • Make a schema type that uses the plugin's type mux.video, for example:

    {
      title: "Video blog post",
      name: "videoBlogPost",
      type: "document",
      fields: [
        { title: "Title", name: "title", type: "string" },
        {
          title: "Video file",
          name: "video",
          type: "mux.video"
        }
      ]
    }
    • Add the muxInput import to your plugins:
    import {createConfig} from 'sanity'
    import {muxInput} from 'sanity-plugin-mux-input'
    
    export default createConfig({
      plugins: [muxInput()],
    })

Read more about schemas in Sanity here.

  • Get an API Access Token and enter it into the setup screen First time you use the plugin you will be asked to enter your Mux credentials.

The Mux Video API uses an Access Token and Secret Key for authentication.

If you haven't already, generate a new Access Token in the Access Token settings of your Mux account dashboard, and make sure it got permission to both read and write video and read data.

The token is stored in the dataset as a document of the type mux.apiKey with the id secrets.mux. Having the ID be non-root ensures that only editors are able to see it.

The Mux plugin will find its access tokens by fetching this document.

Playing videos in the frontend

We have made our own player which supports poster images for the videos as set with this plugin, see sanity-mux-player

You could use any player which supports HLS, just point the video source to:

https://stream.mux.com/${assetDocument.playbackId}.m3u8

Enabling Signed Urls

To enable signed urls with content uploaded to Mux, you will need to check the "Enable Signed Urls" option in the Mux Plugin configuration. Assuming that the API Access Token and Secret Key are set (as per the Quick start section).

More information for this feature of the plugin can be found on Mux's documentation

Enabling MP4 support

To enable static MP4 renditions, add mp4_support: 'standard' to the options of your mux.video schema type.

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

export default createConfig({
  plugins: [muxInput({mp4_support: 'standard'})],
})

Currently, mp4_support is the only supported MUX option and this supports a value of either standard or none (the default).

Contributing

Issues are actively monitored and PRs are welcome. When developing this plugin the easiest setup is:

  1. Fork this repo.
  2. Create a studio v3 project: npm create sanity@dev-preview. Follow the prompts, starting out with the blog template is a good way to go.
  3. cd into your project directory, run npm install && npm start - your sanity studio should be running on http://localhost:3333.
  4. cd into the plugins directory of your project.
  5. Fork this repo and clone your fork into the plugins directory inside your project git clone [email protected]:your-fork/sanity-plugin-mux-input.git.
  6. Open sanity.json, go to the plugins array and add mux-input.
  7. Re-start the sanity studio server with npm start.
  8. Edit schemas/post.js and add follow the plugin documentation to add a mux.video type field.
  9. Your studio should reload, and now when you edit the plugin code it should reload the studio, when you're done creating a branch, put in a PR and a maintainer will review it. Thank you!

Publishing

Run the "CI" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

On the studio-v2 branch this will result in:

  • a new version on the latest dist-tag.
  • running yarn add sanity-plugin-mux-input or npm i sanity-plugin-mux-input will fetch the new version.
  • running sanity install mux-input will fetch the new version.
  • studio-v3 users are unaffected.

On the main branch this will result in:

  • a new prerelease version on the studio-v3 dist-tag.
  • running yarn add sanity-plugin-mux-input@studio-v3 or npm i sanity-plugin-mux-input@studio-v3 will fetch the new version.
  • running sanity install mux-input won't fetch the new version.

After Studio v3 turns stable this behavior will change. The v2 version will then be available on the studio-v2 dist-tag, and studio-v3 is upgraded to live on latest.

Test

npm test

sanity-plugin-mux-input's People

Contributors

dependabot[bot] avatar dylanjha avatar erikpena avatar hdoro avatar jaredsmith avatar kimpaow avatar mariuslundgard avatar renovate[bot] avatar rexxars avatar robinpyon avatar runeb avatar semantic-release-bot avatar skogsmaskin avatar snorrees avatar stipsan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.