0

Hi,

I am trying to render a video using <video> tag and it expects a url to video file. Looks very straight forward this way but can anyone suggest how I can provide Experience Editor support using Glass().Editable(). The content editor should be able to select the video file from Media Library and it should load the selected video file in Experience Editor. For Images there is out-of-the-box RenderImage() method available. How to achieve this for rendering video?

Please if anyone can help. Thanks in advance.

Parry

1
  • Your video field, is it one field only? or multiple fields for every extension?
    – Marek Musielak
    Dec 15, 2021 at 10:34

1 Answer 1

2

To open it into Experience Editor, you can add the below piece of code or wrap up your HTML code in Glass Mapper @using:

@using (Html.Glass().BeginEditFrame(Model, "Edit video field", x => x.VideoFile))
{
    <div style="float:left; padding-right:20px">
        <video width="320" height="240" controls>
            <source src="@Model.VideoFile" type="video/mp4" />
            <source src="@Model.VideoFile" type="video/ogg" />
            your custom message
        </video>
    </div>
}

If you have more than one video field for each extension. Your code will be:

@using (Html.Glass().BeginEditFrame(Model, "Edit video fields", x => x.VideoFileA, x => x.VideoFileB))
{
  your HTML
}

You don't need to create any custom Experience Button or Frame for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.