Retrieving AssetDocuments and creating JWT tokens for playback in Sanity Mux plugin
6 replies
Last updated: Feb 9, 2022
J
Hello guys. Anybody here used sanity mux plugin before? How do i retrieve a complete AssetDocument. My groq query is
playAllVideo": {1 item
"asset":{1 item
"_ref":"79d4e7b5-e736-46cc-9371-8c59f85fdabe"}
}
playAllVideo": {1 item
"asset":{1 item
"_ref":"79d4e7b5-e736-46cc-9371-8c59f85fdabe"}
}
Feb 7, 2022, 9:51 AM
J
This is an entry that we are getting from typing * [ _type == “watch” ]:
We would like to retrieve a complete AssetDocument from all the “episodeVideo” fields in “episodes” array.
[ { “_createdAt”: “2022-01-23T12:09:39Z”, “_id”: “6c5d1636-aa69-4ec6-a154-b47e3a1e7383”, “_rev”: “1mkF0t783lKYmfwjq99bds”, “_type”: “watch”, “_updatedAt”: “2022-02-07T08:44:52Z”, “comingSoon”: false, “episodes”: [ { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-6838f3071da108f09bf64db5880b5acd821e0eda-1024x1024-svg”, “_type”: “reference” } }, “_key”: “f9129608a584”, “_type”: “NewEpisode”, “episodeTitle”: “Play All Episodes”, “episodeVideo”: { “asset”: { “_ref”: “79d4e7b5-e736-46cc-9371-8c59f85fdabe” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-1b27444353d08336d4ccc82bdf2f7fad844b0674-1024x1024-svg”, “_type”: “reference” } }, “_key”: “20fe4746e343”, “_type”: “NewEpisode”, “episodeTitle”: “Bunny and the Hat”, “episodeVideo”: { “asset”: { “_ref”: “73244cdf-c981-41af-8a79-440e6428cd33” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-1e02bcfd8323ec9d435235558754987d5adaaa1a-1024x1024-svg”, “_type”: “reference” } }, “_key”: “e5a0a6cb2e6e”, “_type”: “NewEpisode”, “episodeTitle”: “Sad Clown”, “episodeVideo”: { “asset”: { “_ref”: “94b1db8c-2aa8-4c3b-b9de-470824b8ac1f” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-b26a7d3feb9aeec1fe9a380fe897a2ec266ea50d-1024x1024-svg”, “_type”: “reference” } }, “_key”: “a187888e5b81”, “_type”: “NewEpisode”, “episodeTitle”: “On the Ice”, “episodeVideo”: { “asset”: { “_ref”: “06123ccc-52f2-4c24-8061-76b2bc5eff07” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-9c4b8949335be3d30a00acba0418bfe78a640f22-1024x1024-svg”, “_type”: “reference” } }, “_key”: “559c6efdc0fe”, “_type”: “NewEpisode”, “episodeTitle”: “Monkey Big Band”, “episodeVideo”: { “asset”: { “_ref”: “813501df-faa1-4741-81e4-bbc92770e57f” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-754d83fab3ee75d59a98eb26a878058406b93bdc-1024x1024-svg”, “_type”: “reference” } }, “_key”: “851708e7d985”, “_type”: “NewEpisode”, “episodeTitle”: “Teddy Bikes”, “episodeVideo”: { “asset”: { “_ref”: “dabcab93-fbe6-479c-b3a4-19b712f43814” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-450c778abea729ef689c17b52c28e4e052d7ee8f-1024x1024-svg”, “_type”: “reference” } }, “_key”: “2cc631a05535”, “_type”: “NewEpisode”, “episodeTitle”: “The King on Fire”, “episodeVideo”: { “asset”: { “_ref”: “130a00c3-4565-44b3-9f8c-cb80ef07e8e7” } } }, { “EpisodeLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-448afbbe6f821694b2b55d733ef26f507d37445d-1024x1024-svg”, “_type”: “reference” } }, “_key”: “d8b11551d5d6”, “_type”: “NewEpisode”, “episodeTitle”: “Throw and Spin”, “episodeVideo”: { “asset”: { “_ref”: “5cf52f4d-9d70-4703-919c-04849ddd962b” } } } ], “playAllVideo”: { “asset”: { “_ref”: “79d4e7b5-e736-46cc-9371-8c59f85fdabe” } }, “premium”: false, “seriesDescription”: “Look! The monkey is playing the drums. And the bunny disappears in the hat. And there is much more. Wow!“, “seriesLogo”: { “_type”: “image”, “asset”: { “_ref”: “image-6838f3071da108f09bf64db5880b5acd821e0eda-1024x1024-svg”, “_type”: “reference” } }, “seriesTitle”: “Circus”, “slug”: { “_type”: “slug”, “current”: “circus” } } ]
We would like to retrieve a complete AssetDocument from all the “episodeVideo” fields in “episodes” array.
Feb 8, 2022, 7:46 AM
J
We solved it already, thanks. Now we need to create a JWT token for the playback
Feb 8, 2022, 9:36 AM
A
Awesome! Please let us know if we can help with anything else.
Feb 8, 2022, 9:48 AM
E
Thank you so much
We were just wondering - we are also going to stream audio files only on our platform. Will the Sanity Mux Player support them? Many thanks!
user E
!We were just wondering - we are also going to stream audio files only on our platform. Will the Sanity Mux Player support them? Many thanks!
Feb 9, 2022, 9:21 AM
A
Hi Emily. It looks like it should work 👍.
You’ll have a unified workflow for both your audio and video assets. Just like how the Mux Video API makes it easy to stream video, the same API now makes audio streaming easy. The same API call works whether it’s audio or video so you can send us either with no changes to workflow on your side.https://mux.com/blog/have-you-heard-we-support-audio-only-files-too/
Feb 9, 2022, 10:52 AM
J
that a great news!
Feb 9, 2022, 1:00 PM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.