Search code examples
.netrazorsitecorebrightcove

Passing parameters to a Razor View rendering in Sitecore


I'm trying to render out the brightcove media player right now while passing a dynamic video id. The brightcoveData.Id is a valid guid but I can't seem to get the parameters passing properly so that the Rendering understands it. I get an error from this component saying "Media item are not selected."

var embedMedia = new System.Collections.Specialized.NameValueCollection();
            embedMedia.Add("playerId", "E7766078969C3AB892DD158E0E7230B9");
            embedMedia.Add("width", "400");
            embedMedia.Add("height", "300");

            @Html.Sitecore().Rendering("/sitecore/layout/Renderings/Media Framework/Embed Media", new
                               {
                                   DataSource = brightcoveData.Id,
                                   Parameters = embedMedia
                               })

Any help would be appreciated. Thanks.


Solution

  • Ok, after talking to Sitecore Support I got an answer:

    @Html.Sitecore().Rendering("/sitecore/layout/Renderings/Media Framework/Embed Media", new
                                   {
                                       DataSource = brightcoveData.Id,
                                       Parameters = "playerid=E7766078969C3AB892DD158E0E7230B9&height=300&width=400"
                                   })
    

    brightcoveData.Id is just a guid string = "{XXXX-...-etc}". playerid is the Sitecore item id for the player you're using.

    That's what the final code looks like and it works great! Thanks everyone