Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mikael Ekström 14 posts 114 karma points
    Oct 28, 2017 @ 14:51
    Mikael Ekström
    0

    Building a macro for embeding videos

    I want to build a macro that lets the user pic a media-file (video) and then embeds it in the page.

    I want to use a macro so i can use it in the grid-system.

    My initial plan is to use the video tag to do it and use mp4 files because the work in almost every browser.

    How do i let the user select a media object in the macro config and how do i make sure the video scales properly depending on screen resolution?

    KR, Mikael

  • Martin Aguirre 42 posts 210 karma points
    Oct 30, 2017 @ 19:21
    Martin Aguirre
    0

    hi Mikael If you use a HTML video tag ("Video") in the partial view, the video rezise automatically.

     var MediaId = Model.MacroParameters["Video"];
        var media = Umbraco.Media(MediaId);
    
     var MediaId2 = Model.MacroParameters["Image"];
        var media2 = Umbraco.Media(MediaId2);
    
    
    <a href="@url" target="@target">                         
    
                                    <video controls autoplay controlsList="nodownload" width="100%" height="100%" controls
                                poster=@media2.umbracoFile >
      <source src=@media.umbracoFile type="video/mp4" style="width:100%;">
    </video>
    

    Finally in the macro parameters add an Image Media Picker to allow user select the video.

    Regards. Martin

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies