jacksorjacksor (Richard Jackson)
08/08/2024, 8:16 PMMediaPicker3
, with allowed type being the built-in umbracoMediaAudio
.
However, MediaPicker3
is, as [per docs](https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3), returning MediaWithCrops
- this implies that MediaPicker3
is intended for images specifically, not other types of media (not audio or video).
Could someone please give me direction as to:
1. What would be the most appropriate editor to use for an author to upload/select audio files?
2. What the Razor would look like to get an umbracoMediaAudio
property from whatever is returned in 1.
I also tried casting the MediaWithCrops
to type UmbracoMediaAudio
but that returned null
.
Any direction would be greatly appreciated! Various code snippets included, can provide more details if required.
Cheers!
Rich
Umbraco 13.4.1
https://cdn.discordapp.com/attachments/1271200299041816606/1271200299394269265/image.png?ex=66b67909&is=66b52789&hm=99214c089e934f27021b06940cfee9839594e1e77235aa614878c18052b6a4c3&
https://cdn.discordapp.com/attachments/1271200299041816606/1271200299868098652/image.png?ex=66b67909&is=66b52789&hm=1a551ab120dd4099c2271dfda8bd02acece02610d63555ce7ee5b8ffe0c63c0e&
https://cdn.discordapp.com/attachments/1271200299041816606/1271200300149248030/image.png?ex=66b67909&is=66b52789&hm=a2f765742f26248bcfad76c8f72049d89fabacf357cc9df8e2fb2a15168e5c22&rasmusjp
08/08/2024, 8:21 PMjacksorjacksor (Richard Jackson)
08/08/2024, 8:28 PMrasmusjp
08/08/2024, 8:34 PMrasmusjp
08/08/2024, 8:38 PMjacksorjacksor (Richard Jackson)
08/08/2024, 8:44 PM.UmbracoFile
on the output of the MediaPicker, which is a property of UmbracoMediaAudio
, none of which is, to my knowledge, image specific.
I'll happily raise a discussion, I just wanted to check here first - thanks for your input so farrasmusjp
08/08/2024, 8:51 PMjacksorjacksor (Richard Jackson)
08/08/2024, 8:53 PMrasmusjp
08/08/2024, 9:09 PMNik
08/08/2024, 10:02 PMvar audio = MyContent.MediaPickerProperty?.Content is UmbracoMediaAudio umbracoMediaAudio ? umbracoMediaAudio : null;
jacksorjacksor (Richard Jackson)
08/09/2024, 7:30 AMjacksorjacksor (Richard Jackson)
08/09/2024, 8:03 AMvar audioItems = Model.MultipleMediaPicker;
[...]
@foreach (var audioItem in audioItems)
{
var audioItemContent = audioItem.Content as UmbracoMediaAudio;
if(audioItemContent is null){ continue; }
<h1>Audio: @audioItemContent.UmbracoFile</h1>
<audio controls>
<source src="@audioItemContent.UmbracoFile" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
}
(Will definitely be writing up a blog article about this when I've explored more!)jacksorjacksor (Richard Jackson)
08/09/2024, 8:03 AMkdx-perbol
08/09/2024, 9:57 AMRachel D
08/09/2024, 10:27 AMjacksorjacksor (Richard Jackson)
08/09/2024, 12:19 PM