Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label Brightcove. Show all posts
Showing posts with label Brightcove. Show all posts

Sunday, August 13, 2017

How to render Brightcove video programmatically using sitecore item




Brightcove and Sitecore using CSharp
Brightcove and Sitecore using CSharp


It’s very easy to render Brightcove video through HTML as

<iframe src="//players.brightcove.net/4234/default_default/index.html?videoId=1111" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>

But do you know how to render it through programmatically?

Let’s suppose you are getting video item id and player id through Sitecore in your MVC view as

var playerHtml = string.Empty;
<div>
@{
    playerHtml = HelperClass.Instance().GetVideoPlayerMarkup(Model.VideoItemGuidId, Model.PlayerGuidId, 170, 300);
}
<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
@Html.Raw(playerHtml)
<script type="text/javascript">
    brightcove.createExperiences();
</script>
</div>

This view calling GetVideoPlayerMarkup() method which accept 4 parameters – video item id, player item id, video player’s height and width.

You need to include below namespace for using this method

using Sitecore.MediaFramework.Pipelines.MediaGenerateMarkup;
using Sitecore.MediaFramework.Players;

Here is a C# code for this method as

public virtual string GetVideoPlayerMarkup(ID videoItemId, ID playerItemId, int height, int width)
{
    var playerHtml = string.Empty;
    PlayerProperties playerProperties = new PlayerProperties()
    {
        ItemId = videoItemId,
        PlayerId = playerItemId,
        Height = height,
        Width = width
    };
    MediaGenerateMarkupArgs args = new MediaGenerateMarkupArgs()
    {
        MarkupType = MarkupType.Html,
        Properties = playerProperties
    };
    MediaGenerateMarkupPipeline.Run(args);
    if (!args.Aborted)
    {
        playerHtml = args.Result.Html;
    }
    return playerHtml;
}

That’s it. Now when you render this view you will get the Brightcove video on the browser.

I hope you like this Sitecore-Brightcove integration through code. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this code if it’s useful for you.

Sunday, June 18, 2017

How to replace Brightcove Adobe Flash player with HTML5 player in Sitecore


Use HTL5 player of Brightcove in Sitecore
Use HTL5 player of Brightcove in Sitecore

One of our site is using Brightcove Adobe Flash player which we have to replace with new Brightcove player which support HTML5. 
 
Follow below steps to configure Brightcove Video Cloud running as an HTML5 player

  • Step 1: Please navigate to section "Brightcove.StorageService" and change the "baseUrl" param value with your website URL and also set the "ContentDatabaseName" and "PublishDatabaseName" param values from Sitecore.MediaFramework.Services.Brightcove.Extended.config.disabled config file.
  • Step 2: Enable the config file named as "Sitecore.MediaFramework.Services.Brightcove.Extended.config.disabled".
  • Step 3: We need to add mimetype "text/vtt" with extension (.vtt) in IIS.
  • Add new player at “/sitecore/media library/Media Framework/Accounts/Default/Players” with unique player id.
  • Update “Default Video Player” field and “Default Playlist Player” to new player at “/sitecore/media library/Media Framework/Accounts/Default/Settings
  • Include “<script src="//players.brightcove.net/<licence id>/<Player_Id>_default/index.min.js"></script>” on all pages where you want to show Brightcove videos.
  • Publish all the Brightcove items
  • Test the page on which Brightcove videos are rendering.
I hope you like this Sitecore article. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this article if it’s useful for you.