5

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.

Thomas Taylor
  • 555
  • 4
  • 12

2 Answers2

9

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

Thomas Taylor
  • 555
  • 4
  • 12
0

I don't think that you can overwrite default properties with those parameters.

Sitecore will parse those parameters and add them as a KeyValuePair<string, object> object. You can access this object via Rendering.Parameters.

If you wan't to set up your own Datasource and Parameters you would have to use the presentation details in Sitecore and set the Datasource there.

Fabian
  • 394
  • 1
  • 6
  • I disagree http://ctor.io/specify-datasource-item-of-a-statically-binded-rendering/ – xoail Dec 17 '14 at 19:22
  • @xoail I looked inside the SitecoreHelper class and this is what it does: `EnumerableExtensions.Each>((IEnumerable>) TypeHelper.GetProperties(parameters), (Action>) (pair => rendering.Properties[pair.Key] = ObjectExtensions.ValueOrDefault(pair.Value, (Func) (o => o.ToString()))));` Seems to me that it adds the parameters as properties to the rendering. I can't find anything that overwrites existing properties. – Fabian Dec 18 '14 at 09:16
  • As a work around I might be able to add the Embed Media (with an existing DS I could modify) to a placeholder and only show it as a conditional. I might try this approach... giving Sitecore Support like 1-2 more days to have an answer – Thomas Taylor Dec 18 '14 at 19:11