sanity-io / sanity-plugin-mux-input

An input component that integrates Sanity Studio with MUX.com video encoding/hosting service.
https://mux.com
MIT License
45 stars 55 forks source link

No playbackid returned from sanity query #335

Closed carstensbix closed 4 months ago

carstensbix commented 7 months ago

I only get this information returned from my sanity query: (it's an mp4 i uploaded), i am on localhost

video: { _type: 'mux.video', asset: { _ref: '938955fe-0d39-4011-9a70-a7dafb4866d2', _type: 'reference', _weak: true } },

How can i play an video without the playbackId? Can i use the _ref in any way?

droplab commented 7 months ago

you have to do a join on the _reference field to get the actual mux video data

video
{
   ...,
   "asset": asset->
}
hdoro commented 4 months ago

Thank you @droplab for the help!

@carstensbix as Mike pointed out above, you need to expand the video document reference in your Sanity query. You can find an example in our Codesandbox demo:

const query = /* groq */ `*[_type == "trailer"][0]{
  title,
  "playbackId": video.asset->playbackId
}`

Please refer to References and Joins in Sanity's documentation for more information.